2012, a Japanese film called ABS-130 caused the network vibration, the network has appeared "at the outset to seek a kind of dog, now * people ugly" phenomenon, became 2012 years of the internet a big thing.
2014, net network action in full swing, the major Internet companies have made an example, the moment between XX cloud, x ray all the seeds of the evil to shut out. Long live NET Action!! (also my teacher!!) )
Each large network disk, download applications from the seeds to extract key information, the seeds shut out. Where is the key information hidden? Let's find out.
SEED file Structure
The following content is from Wikipedia
. torrent seed files are essentially text files that contain two parts of tracker information and file information. Tracker information is mainly used in BT download tracker server address and for the tracker server settings, file information is based on the calculation of the target file generated, the results according to the BitTorrent protocol Bencode rules for coding. The main principle is to divide the files that provide downloads into chunks of equal size, the block size must be 2k of the whole number of times (because it is a virtual chunk, the hard disk does not produce each block file), and the index information and hash code of each block are written into the seed file, so the seed file is the "index" of the downloaded file.
The image above is the structure of a typical seed, and the identified evil keywords are hidden in name and file. Name contains the names of the seeds, such as:abcd-123 sexy xxxx. The path in file contains information about all the files you want to download, such as the Grass X community's newest address, txt , and so on.
Node.js and Parse-torrent Libraries
In order to find out the evil information in the seeds, we have node.js and Parse-torrent library as assistants.
Experimental Preparation:
Seed one installed node.js computer one
First we use NPM to install the Parse-torrent library, which helps us quickly find information within the seed.
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 in the form of an object.
View results:
Name
Files
You can see that the information for name and files parsed with the Parse-torrent library is stored in Buffer form.
Cleaning seeds
How to clean up the evil information in the seeds, kill the seeds of evil in the cradle, the most important even if you want to clear the name and files inside the path of information.
function Cleaninfo (info) {
//MD5 the seed name with the
info.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 (".");
Encrypt the seed name with MD5
FILE[KEY][J] = MD5 (Text.slice (0,dotindex)) + Text.slice (dotindex,text.length);}}
}
return info;
}
Regenerate the cleaned info object with a torrent file
var buf = parsetorrent.totorrentfile ({
info:cleaninfos[i]
});
Fs.writefile (dir + "/" + Cleaninfos[i].name + ". Torrent", buf);
After that, our evil seed file becomes this:
Combat phase
First prepares a seed, carries on the offline downloading of XX cloud.
At first it was rejected.
Then run the script to clean it.
node cleanTorrent IPTD-XXX.torrent
The download was successful!
Script source Stacking Here, I'm going to take a look at my downloads.!!!
(* * * * all off, you show me this!!! )
At last
This article is purely technical discussion, thank you for your reading, there are deficiencies please point out for me.
Please take a moment to share the article with your friends or leave a comment. We will sincerely thank you for your support!