Skip to content

Instantly share code, notes, and snippets.

@buzztiaan
Created October 11, 2020 15:06
Show Gist options
  • Save buzztiaan/88c71bf17dcf04cf1fced809cdf0bccb to your computer and use it in GitHub Desktop.
Save buzztiaan/88c71bf17dcf04cf1fced809cdf0bccb to your computer and use it in GitHub Desktop.
torrent roulette!
import time
import btdht
import binascii
import random
dht = btdht.DHT()
dht.start()
time.sleep(15)
peers = 0
while peers < 10:
torrent = format(random.randrange(16**40), '040x')
#torrent = format(1026386259810461851159327840101891921412120041165, 'x')
print (" trying ", torrent)
output = dht.get_peers(binascii.a2b_hex(torrent))
if not output is None :
print (output)
time.sleep(5)
output = dht.get_peers(binascii.a2b_hex(torrent))
print (output)
if output is None :
peers = 0
else:
print ("Found active torrent!")
peers = len(output)
print(output);
print(peers);
print(torrent);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment