Nmap Development mailing list archives
Bittorrent and DHT library and scripts
From: Gorjan Petrovski <mogi57 () gmail com>
Date: Tue, 2 Aug 2011 19:07:57 +0200
Hello, I've written a bittorrent library which allows the user to discover peers and nodes using a torrent file or a magnet link as well as decode . This is my first library so any comments are welcome. You may find it in the nmap-exp/gorjan/ repository under the name bittorrent.lua The workflow for using this library would be to initialize a new Torrent object, load information about it with a magnet link or a torrent file, then request the discovery of peers using trackers, and then discover peers using the DHT protocol for a certain time period. The following code illustrates how this would be achieved. <code> local filename = "/home/user/name.torrent" local torrent = bittorrent.Torrent:new() torrent:load_from_file(filename) torrent:trackers_peers() -- to load peers from the trackers torrent:dht_peers() -- to further load peers using the DHT protocol from existing peers </code> After these operations the peers and nodes can be found in the torrent.peers and torrent.nodes tables respectively. I've also implemented a script which discovers the nodes and peers for a given magnet link or a torrent file. I decided to separate the library and the script because the code is more clean and I also have another idea for discovery of nodes which I intend to implement soon. The script may be checked out from nmap-exp/gorjan/bittorrent-discovery.nse The script discovers bittorrent peers and nodes using the Bittorrent and DHT protocol when supplied with a valid torrent file or a magnet link. The peers implement the Bittorrent protocol and share the torrent, whereas the nodes implement the DHT protocol and are used to track the peers. The sets of peers and nodes are not the same, but they usually intersect. If the newtargets script-arg is supplied it adds the discovered peers as targets. usage string: nmap --script bittorrent-discovery --script-args bittorrent-discovery.torrent=<filename>, bittorrent-discovery.magnet=<magnet_link>[,bittorrent-discovery.dht_timeout=<seconds>] [,bittorrent-discovery.nodes-only][,bittorrent-discovery.peers-only][,newtargets] The script accepts 5 types of script-arguments: <torrent>, a string containing the filename of the torrent file <magnet>, a string containing the magnet link of the torrent <timeout>, desired (not actual) timeout for the DHT discovery (default = 30 s) <nodes-only>, boolean selecting whether to show only nodes <peers-only>, boolean selecting whether to show only peers Notice that if both nodes-only and peers-only arguments are supplied no output is produced Sample output: | bittorrent-peers: | Peers: | 97.88.178.168 | 89.100.184.36 | 86.185.55.212 | Total of 3 peers discovered | Nodes: | 68.103.0.189 | 67.164.32.71 | 24.121.13.69 | 207.112.100.224 | Total of 4 nodes discovered |_ Use the newtargets script-arg to add the results as targets -- Gorjan _______________________________________________ Sent through the nmap-dev mailing list http://cgi.insecure.org/mailman/listinfo/nmap-dev Archived at http://seclists.org/nmap-dev/
Current thread:
- Bittorrent and DHT library and scripts Gorjan Petrovski (Aug 02)
- Re: Bittorrent and DHT library and scripts Gorjan Petrovski (Aug 03)
- Re: Bittorrent and DHT library and scripts Toni Ruottu (Aug 03)
- Re: Bittorrent and DHT library and scripts Gorjan Petrovski (Aug 03)
- Re: Bittorrent and DHT library and scripts Shinnok (Aug 04)
- Re: Bittorrent and DHT library and scripts Gorjan Petrovski (Aug 04)
- Re: Bittorrent and DHT library and scripts Toni Ruottu (Aug 03)
- Re: Bittorrent and DHT library and scripts Patrick Donnelly (Aug 09)
- Re: Bittorrent and DHT library and scripts Gorjan Petrovski (Aug 09)
- Re: Bittorrent and DHT library and scripts Gorjan Petrovski (Aug 03)