import sys ; sys.path.insert(0, '..') import binascii import array import os import md5 # Usage : python torrentToiZoneentries.py thetorrentfile # python yarrow-binary-i386-iso.torrent > list.txt def main(): f = open(sys.argv[1],'rb') size = os.path.getsize(sys.argv[1]) print "; This is the zone file entrys for torrent "+sys.argv[1] m = md5.new() f = open(sys.argv[1],'rb') x = f.read(size) m.update(x) md5sum = m.hexdigest() print "; The size of the torrent is "+str(size)+" and the md5 checksum is "+md5sum print "; The zonefilesize is "+str((size / 126)+1)+" entries a 126 bytes." f.seek(0) for i in range(0,(size / 126)): x = f.read(126) txt = binascii.b2a_hex(x) print str(i)+"_"+str((size / 126))+"_"+md5sum+" IN TXT \""+txt+"\"" x = f.read(size % 126) txt = binascii.b2a_hex(x) print str((size / 126))+"_"+str((size / 126))+"_"+md5sum+" IN TXT \""+txt+"\"" f.close() if __name__ == "__main__": main()