1

I've been lead to believe that if you decode the info_hash in a tracker GET request, you are left with the SHA1 hash of the file that is being downloaded. That makes sense to me but I'm not getting results here. Does anybody have any experience with this?

info_hash=%ab%10o%22%a8%b0%e2%a4p%27%e2U%d3j%d1F%a0%f7%05%27

This is what I'm currently working with. Clearly this is URL encoded yet URL decode gives me absolutely nothing to work with. Where am I going wrong here?

Any help is appreciated.

  • unescape('%ab%10o%22%a8%b0%e2%a4p%27%e2U%d3j%d1F%a0%f7%05%27').split('').map((e)=>{var c = e.charCodeAt(0); return (c < 10 ? '0' : '') + c.toString(16).toUpperCase()}).join('') seems to produce a valid hex-encoded SHA1 hash. Sound like you might have an issue with your code, in which case you probably want Stack Overflow. – Alexander O'Mara Aug 22 '16 at 0:47
  • Let me do some verification, it's entirely possible that I'm making an obvious mistake. – Sevaara Aug 22 '16 at 0:51
3

Nope, you can't easily get the file hash from the infohash.

The “infohash” is the SHA1 Hash over the part of a torrent file that includes:

  1. ITEM: length(size) and path (path with filename)
  2. Name: The name to search for
  3. Piece length: The length(size) of a single piece
  4. Pieces: SHA1 Hash of EVERY piece of this torrent
  5. Private: flag for restricted access

(See https://stackoverflow.com/questions/28348678/what-exactly-is-the-info-hash-in-a-torrent-file)

If you have all the other components (such as the name of the torrent), you can combine it with the data in each file you are checking, hash the whole thing, and then check if the result is the correct infohash.

| improve this answer | |
  • 1
    The info_hash is actually the SHA1 of the torrent file. Each ‘%’ is appended with 2 characters, meaning that it is a hex value. Then there are stray characters that don't fit the '%XX' format, convert those to hex and combine everything ('%' removed), then Google it. Google will return a bunch of torrent sites with that torrent present. – Sevaara Aug 22 '16 at 11:17
  • 2
    @Sevaara No, that doesn't mean it is the hash of any torrent file. Note that you can change the torrent file (add trackers) without changing the infohash :) – Navin Aug 22 '16 at 14:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.