torsniff - a sniffer that sniffs torrents from BitTorrent network

Overview

torsniff - a sniffer that sniffs torrents from BitTorrent network

English | 简体中文

Introduction

torsniff is a torrent sniffer, it sniffs torrents that people are using to download movies, music, docs, games and so on from BitTorrent network.

A torrent has valuable information, so you can use torsniff to build your own torrent database(e.g: The Pirate Bay), or to do data mining and analyzing.

Installation

Just download latest torsniff from releases directly.

Usage

$ ./torsniff -h

Usage:
  torsniff [flags]

Flags:
  -a, --addr string        listen on given address (default all, ipv4 and ipv6)
  -d, --dir string         the directory to store the torrents (default "$HOME/torrents")
  -h, --help               help for torsniff
  -f, --friends int        max fiends to make with per second (default 500)
  -e, --peers int          max peers to connect to download torrents (default 400)
  -p, --port uint16        listen on given port (default 6881)
  -t, --timeout duration   max time allowed for downloading torrents (default 10s)
  -v, --verbose            run in verbose mode (default true)

Quick start

Use default flags:

./torsniff

Requirements

  • A host having a public IP(recommended), or UDP port forwarding/port mapping in private network/NAT
  • Allow UDP traffic get through firewall
  • Your ISP/Hosting Provider allows BitTorrent traffic(torsniff works on vultr.com)

Protocols

License

MIT

Issues
  • 运行test。出错

    运行test。出错

    buffer.js:772
        throw new RangeError('Attempt to write outside buffer bounds');
        ^
    
    RangeError: Attempt to write outside buffer bounds
        at Buffer.write (buffer.js:772:11)
        at fromString (buffer.js:238:26)
        at Function.Buffer.from (buffer.js:131:12)
        at new Buffer (buffer.js:112:17)
        at Function.encode.bytes (/usr/src/p2pspider/node_modules/bencode/lib/encode.js:45:17)
        at Function.encode.dict (/usr/src/p2pspider/node_modules/bencode/lib/encode.js:79:12)
        at Function.encode._encode (/usr/src/p2pspider/node_modules/bencode/lib/encode.js:33:18)
        at Object.encode (/usr/src/p2pspider/node_modules/bencode/lib/encode.js:9:10)
        at DHTSpider.sendKRPC (/usr/src/p2pspider/lib/dhtspider.js:27:23)
        at DHTSpider.sendFindNodeRequest (/usr/src/p2pspider/lib/dhtspider.js:52:10)
        at .<anonymous> (/usr/src/p2pspider/lib/dhtspider.js:57:14)
        at Array.forEach (native)
        at DHTSpider.joinDHTNetwork (/usr/src/p2pspider/lib/dhtspider.js:56:21)
        at .<anonymous> (/usr/src/p2pspider/lib/dhtspider.js:173:18)
        at Timeout.wrapper [as _onTimeout] (timers.js:417:11)
        at tryOnTimeout (timers.js:224:11)
    

    请问如何解决

    opened by wangtubs 12
  • 在家里局域网内的树莓派上安装

    在家里局域网内的树莓派上安装

    我在家里的树莓派2B上安装了这个包。 Internet公网=====路由器(PPPOE拨号)==== 6881端口UDP转发到内部局域网树莓派。 似乎运行比较缓慢,有时长时间无输出,不太确定是端口转发的原因还是树莓派性能原因,还是其他的原因。 树莓派2代B型,CPU 900MHZ。应该也不至于跑的很慢了。

    opened by ifengchao 10
  • 运行test问题

    运行test问题

    @Fuck-You-GFW 作者居然把之前的问题关掉了https://github.com/Fuck-You-GFW/p2pspider/issues/56,指的重开一个。我用作者推荐的vps vultr测试了下。发现确实没有之前提到的问题。不过我发现用vultr的vps跑dht程序速度很慢,一分钟只得到几个infohash,跟digitalocean家的差远了。难道之前遇到的问题是由于网络或者处理速度的问题?请作者在digitalocean vps上测试下。或者我提供vps让作者测试下。

    opened by wangtubs 9
  • name 和 piece 信息为 Buffer 开头的字符串

    name 和 piece 信息为 Buffer 开头的字符串

    { info: 
       Dict {
         files: [ [Object], [Object], [Object], [Object] ],
         name: <Buffer 41 44 33 2e 33 38 45 4e>,
         'piece length': 2097152,
         pieces: <Buffer f0 b9 7d 28 6e 3d 8a 65 be c3 ba 98 e6 54 0f d1 1e 19 a9 78 10 57 e0 f8 46 e8 9c c6 0a e4 9e 7d f0 be 0f 32 32 3b 33 62 e2 8f bd a8 eb 8b cc f8 5e c7 ... > },
      address: '90.154.234.142',
      port: 18382,
      infohash: '8a2fbdccab4779b08c3fbb090ba9fa48da86723a',
      magnet: 'magnet:?xt=urn:btih:8a2fbdccab4779b08c3fbb090ba9fa48da86723a' }
    

    请问是就这样显示还是哪里有问题?node 版本4.3.2和5.7.1都是如此

    question 
    opened by kyledh 8
  • 无法运行

    无法运行

    我先是下载工具 wget https://github.com/fanpei91/torsniff/releases/download/v0.1.0/torsniff-v0.1.0-linux-amd64 torsniff-v0.1.0-linux-amd64 字体是白色的 运行 sudo ./torsniff-v0.1.0-linux-amd64
    报错 sudo: ./torsniff-v0.1.0-linux-amd64: command not found
    请问这是什么原因

    opened by jiaqiyu543 7
  • 防止多个异步请求对同一个 infohash 进行 metadata 下载.

    防止多个异步请求对同一个 infohash 进行 metadata 下载.

    比如 A 异步请求正在下载:

    {
        infohash: 'e834c096cb8608b9fec9256ec4da8c7aad22d680',
        rinfo: {address: '192.168.1.1', port: 6881}
    }
    

    A 异步还没成功下载 metadata 或者还没下载完 metadata 的时候, 接着又来了 B 异步请求下载:

    {
        infohash: 'e834c096cb8608b9fec9256ec4da8c7aad22d680', // 跟 A 异步请求的 infohash 一样.
        rinfo: {address: '192.168.3.1', port: 6882} // 跟 A 异步请求不一样
    }
    

    在未实现这个需求的时候, 程序是又会发起 B 异步请求去下载metadata, 这就显得多余(万一 A 请求最终能成功下载 metadata呢?)

    那么, 需要一个机制, 不需要借助外部数据, 防止重复请求下载 metadata (即使借助了数据库, 也没用).

    另外, 有时候, 一个 infohash 多个 peer, 也不一定在第一个 peer 那里就能成功下载 metadata, 那么就从第二个 peer 那里请求下载, 直到下载成功或者不再有下一个 peer 的时候才会停止.

    实现这个的时候 注意内存泄露的问题.

    一旦实现了这个, 将会是质的飞跃!

    enhancement 
    opened by fanpei91 7
  • 请问为什么安装了node和git拿到源码编译之后运行报错?新手还请指导一下,谢谢

    请问为什么安装了node和git拿到源码编译之后运行报错?新手还请指导一下,谢谢

    [[email protected] w]# node p2pspider/test/index.js events.js:24 this.domain = null; ^

    TypeError: Cannot set property 'domain' of undefined at EventEmitter.init (events.js:24:15) at EventEmitter (events.js:6:21) at P2PSpider (/root/w/p2pspider/lib/index.js:10:18) at Object. (/root/w/p2pspider/test/index.js:5:11) at Module._compile (module.js:409:26) at Object.Module._extensions..js (module.js:416:10) at Module.load (module.js:343:32) at Function.Module._load (module.js:300:12) at Function.Module.runMain (module.js:441:10) at startup (node.js:134:18)

    bug question 
    opened by wadjsnkk 5
  • 不知道这样运行对不对?

    不知道这样运行对不对?

    我把release 的package下载下来 chmod +x packagename然后 就 nohup ./packagename&

    之后就没动静了... 就只有一句话的输出 running, it may take a few minutes...

    有没有什么地方有错的?之后大概需要等待几天时间会有结果出现

    opened by ellenbboe 4
  • Adding sqlite3 peer table.

    Adding sqlite3 peer table.

    This creates an sqlite3 DB if it doesn't exist, and adds a peers table with (infohash, peer) columns.

    You can then get peer counts by running:

    select infohash, count(*) from peers group by infohash;
    
    opened by dessalines 2
  • 内网转发6881

    内网转发6881

    我家里用的电信100M光线,PPPOE拨号可以得到公网IP。 在我的linux路由器上执行: iptables -t nat -A PREROUTING -p udp --dport 6881 -j DNAT --to-destination 192.168.8.168:6881 将访问公网IP的6881端口UDP协议转发到内网192.168.8.168的macbookAir上,macbookAir上再运行node test/index.js 等了10来分钟没抓到包。很想请教下局域网内还要做怎么设置?

    opened by ifengchao 2
  • PR to Dev

    PR to Dev

    • 添加了两个sample,一个使用elastic search, 一个使用leveldb。见samples。
    • 修改btclient.js。之前的版本会在短时间发起大量的请求,可能造成程序死掉。使用elastic search的时候,基本上在开始2~3分钟后就会发生。解决方法是,在每次请求之间等待一段时间。加入了对queue长度的限制。加入了对活动连接数的统计和限制。
    • 添加了fetch_queue.js。详细请见我在 #19 中的留言。这个类没有测试,如果想法正确,还得麻烦您整合测试一下。
    opened by sean-liang 2
  • Windows 10 torsniff v0.1.0 Error: read udp <port> wsarecvfrom: socket larger than buffer or keep-alive activity

    Windows 10 torsniff v0.1.0 Error: read udp wsarecvfrom: socket larger than buffer or keep-alive activity

    Windows 10 x64 with latest updates throws this, program has full in/out rights in firewall, port is forwarded on router:

    Port 60881 immediate termination:

    C:\torsniff>.\torsniff-v0.1.0-windows-amd64.exe -d "C:\torsniff\torrentfiles" -f 90 -e 90 -p 60881 -t 120s -v running, it may take a few minutes... Error: read udp [::]:60881: wsarecvfrom: A message sent on a datagram socket was larger than the internal message buffer or some other network limit, or the buffer used to receive a datagram into was smaller than the datagram itself. could not start: read udp [::]:60881: wsarecvfrom: A message sent on a datagram socket was larger than the internal message buffer or some other network limit, or the buffer used to receive a datagram into was smaller than the datagram itself.

    Port 9881 same:

    could not start: read udp [::]:9881: wsarecvfrom: The connection has been broken due to keep-alive activity detecting a failure while the operation was in progress.

    Port 5881 runs for less than a minute, network traffic is visible, no torrent files collected:

    could not start: read udp [::]:5881: wsarecvfrom: The connection has been broken due to keep-alive activity detecting a failure while the operation was in progress.

    Port 4881 immediate termination:

    could not start: read udp [::]:4881: wsarecvfrom: A message sent on a datagram socket was larger than the internal message buffer or some other network limit, or the buffer used to receive a datagram into was smaller than the datagram itself.

    Port 3881 immediate termination:

    could not start: read udp [::]:3881: wsarecvfrom: The connection has been broken due to keep-alive activity detecting a failure while the operation was in progress.

    I'm unable to say why port 5881 would run but the others don't. Netstat -an shows less than 50 ports being used in all states, all of the above ports tried are free on both computer and router.

    opened by kilves76 2
  • Can't bind to specific addresses

    Can't bind to specific addresses

    panic: listen udp4 192.168.50.68:6881: bind: cannot assign requested address
    
    goroutine 1 [running]:
    main.(*torsniff).run(0xc4200761e0)
            /Users/iTorm/go/src/github.com/fanpei91/torsniff/torsniff.go:170 +0x189
    main.main.func1(0xc42009c000, 0xc420076190, 0x0, 0x5, 0x0, 0x0)
            /Users/iTorm/go/src/github.com/fanpei91/torsniff/torsniff.go:278 +0x304
    github.com/fanpei91/torsniff/vendor/github.com/spf13/cobra.(*Command).execute(0xc42009c000, 0xc42007a010, 0x5, 0x5, 0xc42009c000, 0xc42007a010)
            /Users/iTorm/go/src/github.com/fanpei91/torsniff/vendor/github.com/spf13/cobra/command.go:762 +0x475
    github.com/fanpei91/torsniff/vendor/github.com/spf13/cobra.(*Command).ExecuteC(0xc42009c000, 0x61877d, 0x13, 0xc420082460)
            /Users/iTorm/go/src/github.com/fanpei91/torsniff/vendor/github.com/spf13/cobra/command.go:852 +0x334
    github.com/fanpei91/torsniff/vendor/github.com/spf13/cobra.(*Command).Execute(0xc42009c000, 0xc420072238, 0x61602c)
            /Users/iTorm/go/src/github.com/fanpei91/torsniff/vendor/github.com/spf13/cobra/command.go:800 +0x2b
    main.main()
            /Users/iTorm/go/src/github.com/fanpei91/torsniff/torsniff.go:289 +0x5bf
    
    
    opened by dessalines 2
Releases(v0.1.0)
Owner
Programming is the way to freedom.
null
🐈📦 nyaa.si client library for Go. Fetch Anime, Manga, Music and more torrents

?? ?? go-nyaa nyaa.si client library for Go Built on top of: gofeed - search using RSS colly - scrap torrent details page Original idea: ejnshtein/nya

Ilya Revenko 24 Apr 23, 2022
search yts.mx for torrents

movies - search yts.mx for torrents install: go build && sudo mv movies /usr/local/bin --query QUERY, -q QUERY QUERY to search --rating RAT

Luke Krikorian 3 Jan 20, 2022
Torrent client designed for seeding tens of thousands of torrents.

Gamayun This project is currently a prototype. It is not usable in any shape or form. One day, this will be an efficient BitTorrent client, handling l

Dominik Honnef 14 Jul 27, 2022
Validator node for Bittorrent Chain Network

Delivery Validator node for Bittorrent Chain Network. It uses peppermint, customized Tendermint. Install from source Make sure your have go1.11+ alrea

PanoptesDev 1 Dec 14, 2021
Packet Sniffer in golang

WirePenguin ?? A CLI Packet Sniffer in golang using Cobra and Gopacket packages much much simpler than WireShark =) You can capture packets both live

Mohammad ebrahim Adibzadeh 28 Jun 7, 2022
Full-featured BitTorrent client package and utilities

torrent This repository implements BitTorrent-related packages and command-line utilities in Go. The emphasis is on use as a library from other projec

Matt Joiner 4.4k Jul 30, 2022
🌧 BitTorrent client and library in Go

rain BitTorrent client and library in Go. Running in production at put.io. Features Core protocol Fast extension Magnet links Multiple trackers UDP tr

Cenk Altı 748 Jul 18, 2022
🐈🌐 nyaa.si terminal BitTorrent tracker

koneko - TUI Client for nyaa.si ?? ?? Download Anime, Literature, Audio, Live Action, Pictures, Software Data - go-nyaa TUI - tview Installation ?? go

Ilya Revenko 160 Jul 28, 2022
Your Fluffy and Neighbourly Bittorrent Client

Totorrent: A Fluffy and Neighbourly Bittorrent Client This is a WIP bittorrent client I've been working on for a couple of months. I think it's in a v

Abdullah Joseph 3 Jul 28, 2021
P2PDistributedHashTable - A golang Kademlia/Bittorrent DHT library that implements BEP5

This is a golang Kademlia/Bittorrent DHT library that implements BEP 5. It's typ

Suhas Aggarwal 2 Apr 10, 2022
BitTorrent client and library in Go. Running in production at put.io.

rain BitTorrent client and library in Go. Running in production at put.io. Integration of embedded gRPC framework (All APIs translated to gRPC Server-

Suhas Aggarwal 2 Apr 11, 2022
Package socket provides a low-level network connection type which integrates with Go's runtime network poller to provide asynchronous I/O and deadline support. MIT Licensed.

socket Package socket provides a low-level network connection type which integrates with Go's runtime network poller to provide asynchronous I/O and d

Matt Layher 42 Jul 3, 2022
Magma is an open-source software platform that gives network operators an open, flexible and extendable mobile core network solution.

Connecting the Next Billion People Magma is an open-source software platform that gives network operators an open, flexible and extendable mobile core

Magma 1.3k Jul 31, 2022
Optimize Windows's network/NIC driver settings for NewTek's NDI(Network-Device-Interface).

windows-ndi-optimizer[WIP] Optimize Windows's network/NIC driver settings for NewTek's NDI(Network-Device-Interface). How it works This is batchfile d

Nil Hiiragi 3 Apr 15, 2022
A simple network analyzer that capture http network traffic

httpcap A simple network analyzer that captures http network traffic. support Windows/MacOS/Linux/OpenWrt(x64) https only capture clienthello colorful

null 1 Nov 24, 2021
Zero Trust Network Communication Sentinel provides peer-to-peer, multi-protocol, automatic networking, cross-CDN and other features for network communication.

Thank you for your interest in ZASentinel ZASentinel helps organizations improve information security by providing a better and simpler way to protect

ZTALAB 6 Jul 30, 2022
🚀Gev is a lightweight, fast non-blocking TCP network library based on Reactor mode. Support custom protocols to quickly and easily build high-performance servers.

gev 中文 | English gev is a lightweight, fast non-blocking TCP network library based on Reactor mode. Support custom protocols to quickly and easily bui

徐旭 1.4k Jul 29, 2022
gNXI Tools - gRPC Network Management/Operations Interface Tools

gNxI Tools gNMI - gRPC Network Management Interface gNOI - gRPC Network Operations Interface A collection of tools for Network Management that use the

Google 216 Jul 24, 2022
Simulate network link speed

linkio linkio provides an io.Reader and io.Writer that simulate a network connection of a certain speed, e.g. to simulate a mobile connection. Quick s

Ian Kent 51 Mar 31, 2022