Torrent files, also known as seeds, are used to record the information required by bt downloads. However, with the great development of the Internet, some people inject some evil information into a small torrent file, and the seeds have become synonymous with evil. In 2012, a Japanese film named ABS-130 caused the network vibration, the network has appeared "the original kind like a dog, now * Too ugly" phenomenon, it became a major Internet Event in 2012.
In 2014, net operations were in full swing, and various Internet companies set an exemplary rate. At the moment, XX cloud and X Lei both refused the seeds of evil. Long live the net action !! (Return to my teacher Cang !!)
All major online storage and download applications extract key information from the seeds and reject the seeds. Where exactly are these key information hidden? Let's take a look.
Seed file structure
The following content is from Wikipedia.
The. torrent seed file is essentially a text file, which contains Tracker information and file information. Tracker information is mainly the address of the Tracker server required for BT download and the settings for the Tracker server. The file information is generated based on the calculation of the target file, the calculation result is encoded according to the Bencode rules in the BitTorrent protocol. The main principle is to divide the downloaded files into equal blocks, which must be an integer of 2 K to the power of 2 k (because it is a virtual block, files are not generated on the hard disk), and the index information and Hash Verification Code of each block are written into the seed file. Therefore, the seed file is the "Index" of the downloaded file ".
Is a typical seed structure. The identified evil keywords are hidden in name and file. Name contains the name of the seed, for example:Abcd-123 sexy XXXX. The path in the file contains information about all the files to be downloaded, for example:The latest address in caoxcommunity. txtAnd so on.
Node. js and parse-torrent Libraries
In order to find the evil information in the seeds, we have invited the Node. js and parse-torrent libraries as assistants.
Lab preparation:
Seed one install one Node. js computer
First, we use npm to install the parse-torrent library, which helps us quickly find information in the seeds.
npm install parse-torrent
var fs = require("fs");var parseTorrent = require('parse-torrent');var info = parseTorrent(fs.readFileSync('my.torrent'));console.log(info);
This library will parse the seed information and return it to us as an object.
View results:
Name:
Files:
We can see that the name and files parsed by the parse-torrent library are stored in Buffer format.
Seed cleaning
How to clean the evil information in the seeds and put the evil seeds in the cradle, the most important thing is to clear the information of the path in the name and files.
Function cleanInfo (info) {// encrypt the seed name with md5. name = md5 (info. name); info ['name. UTF-8 '] = md5 (info ['name. UTF-8 ']); var files = info. files; for (var I = 0; I <files. length; I ++) {var file = files [I]; for (var key in file) {if (key = "path" | key = "path. UTF-8 ") {for (var j = 0; j <file [key]. length; j ++) {var text = file [key] [j]. toString (); var dotIndex = text. lastIndexOf (". "); // use md5 to encrypt the seed name file [key] [j] = md5 (text. slice (0, dotIndex) + text. slice (dotIndex, text. length) ;}}} return info ;}
// Generate a torrent file var buf = parseTorrent for the info object after cleaning. totorw.file ({info: cleanInfos [I]}); fs. writeFile (dir + "/" + cleanInfos [I]. name + ". torrent ", buf );
After this, our evil seed file becomes like this:
Practical stage
First, prepare a seed for offline download of XX cloud.
At first, it was rejected.
Then run the script for cleaning.
node cleanTorrent IPTD-XXX.torrent
Download successful!
The script source code is put here. You have to check my download content !!!
(** Show this to me !!!)
Last
This article is purely a technical discussion. Thank you for reading this article. Please point out the shortcomings for me.
Please take a moment to share your article with your friends or leave a comment. Thank you for your support!