#!/usr/bin/perl
# this script may not work, I don't use it anymore.
# and I've made code changes without testing them.
# if it doesn't work.. fix it.
use IO::Socket::INET;
my @ids=qw/11 22 33 44 55 66 77/;
sub parse_form(\%);
sub parse_form(\%) {
my $webvar=$_[0];
my $buffer;
if ($ENV{'REQUEST_METHOD'} eq "GET") {
$buffer=$ENV{'QUERY_STRING'};
} elsif ($ENV{'REQUEST_METHOD'} eq 'POST' && $ENV{'CONTENT_TYPE'} eq "application/x-www-form-urlencoded") {
read(STDIN, $buffer, $ENV{CONTENT_LENGTH});
} else {
$buffer = $ENV{'QUERY_STRING'};
$buffer read(STDIN, $buffer, $ENV{CONTENT_LENGTH});
}
my @pairs = split(/&/, $buffer);
for (@pairs) {
my ($name, $value)=split(/=/);
$name =~ tr/+/ /;
$name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ s/'/\\'/g;
$$webvar{$name} = $value;
}
}
sub main();
sub main() {
my %webvar;
parse_form(%webvar);
my $sock = IO::Socket::INET->new(PeerAddr => 'BF2Web.gamespy.com', PeerPort => '80', Proto => 'tcp');
print $sock "GET /ASP/getunlocksinfo.aspx?pid=$webvar{'pid'} ";
print $sock "HTTP/1.1\nHost: BF2Web.gamespy.com\nUser-Agent: ";
print $sock "GameSpyHTTP/1.0\nConnection: close\n\n";
print "Content-type: text/plain\n\n";
while(my $recv=<$sock>) {
next unless $recv=~/^(?:O|H|D|\$)\s/;
if ($recv=~/^D/) {
for (@ids) {
if ($recv=~/\s$_\s/) {
$recv=~s/n/s/;
}
}
}
print $recv;
}
}
main();