#!/usr/bin/perl # # extorrents - extracts torrent files from Blizzard downloaders # Copyright (C) 2006 Matt Francis # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # foreach $filename (<*-downloader.exe>) { open FILE, $filename or die "Can't open $filename"; while (!eof(FILE)) { if (getc(FILE) eq "d") { read FILE, $str, 10 or last; if ($str eq "8:announce") { $filename =~ s/-downloader\.exe/-patch.torrent/; open OUTFILE, ">", $filename or die "Can't open $filename for writing"; print OUTFILE "d8:announce"; while (!eof(FILE)) { read FILE, $buffer, 65536; print OUTFILE $buffer; } close OUTFILE; print "Created $filename\n"; last; } } } close FILE; }