Jump to content

[SOLVED] Connecting to a bittorrent client as a peer


c000kie

Recommended Posts

Tried using fsockopen but I don't really know what to send, anybody has some knowledge about this?

 

I've also tried to look trough some "php bittorrent clients" but in fact they're not clients they're just php interfaces to clients written in python.

 

THANKS alot :)

Link to comment
Share on other sites

Well, problem is I tried that, but it's not that easy to understand..I mean I know some PHP, but @ python I really suck, they're not very different from one another but still..

 

Thing is on the BitTorrent Wiki (http://wiki.theory.org/index.php/BitTorrentSpecification#Handshake) they say when the handshake (connection between peers) is something like:

 

The handshake is a required message and must be the first message transmitted by the client. It is (49+len(pstr)) bytes long.

 

handshake: <pstrlen><pstr><reserved><info_hash><peer_id>

 

    * pstrlen: string length of <pstr>, as a single raw byte

    * pstr: string identifier of the protocol

    * reserved: eight (8) reserved bytes. All current implementations use all zeroes. Each bit in these bytes can be used to change the behavior of the protocol. An email from Bram suggests that trailing bits should be used first, so that leading bits may be used to change the meaning of trailing bits.

    * info_hash: 20-byte SHA1 hash of the info key in the metainfo file. This is the same info_hash that is transmitted in tracker requests.

    * peer_id: 20-byte string used as a unique ID for the client. This is usually the same peer_id that is transmitted in tracker requests (but not always e.g. an anonymity option in Azureus).

 

In version 1.0 of the BitTorrent protocol, pstrlen = 19, and pstr = "BitTorrent protocol".

 

Thing is I will find the info_hash in a MySQL database and the peer_id will be some fixed value taken from a client, how do I send this and all the rest? How would the syntax look like?

Link to comment
Share on other sites

Yea' that's what I'm trying to do.. because I don't really need to use it as a client but as a peer connector to verify if there really is a peer at that given IP address. (best solution against fakers that I could think at)

 

The python code is very large.. that's why I'm having trouble with understanding it..

 

Here is torrentflux: http://tf-b4rt.berlios.de/

 

The most popular PHP(interface) client.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.