1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
|
#!/usr/bin/perl
use lib "blib/lib";
use IO::Socket::Socks;
use IO::Select;
use FileHandle;
$| = 1;
my $socks = new IO::Socket::Socks(ProxyAddr=>"127.0.0.1",
ProxyPort=>"8888",
SocksDebug=>0,
Listen=>1,
RequireAuth=>1,
UserAuth=>\&auth
);
print $socks,"\n";
my $select = new IO::Select($socks);
while(1)
{
if ($select->can_read())
{
my $client = $socks->accept();
if (!defined($client))
{
print "ERROR: $SOCKS_ERROR\n";
next;
}
my $command = $client->command();
if ($command->[0] == 1)
{
print "connect!\n";
$client->command_reply(0,"127.0.0.1","4000");
}
my $buff;
$client->sysread($buff,1024);
print $buff,"\n";
$client->close();
}
}
print $socks,"\n";
sub auth
{
my $user = shift;
my $pass = shift;
print "user($user) pass($pass)\n";
return 1 if (($user eq "foo") && ($pass eq "bar"));
return 0;
}
|