Proxy List Checker & Updater
Heya. This is another perl project, and it might be handy. If you use the internet a lot, you may eventually build and save huge proxy lists. The problem is, and this is especially true if your list consists of free proxy servers, the number of servers going on and offline all the time is really high, so sometimes it can be annoying to find a good working one. This is what this tool’s for. It’ll read a proxy list containing IP:PORT pairs and try a connection on each of them, for a specified number of seconds. If the timeout is reached, the proxy is considered temporarily dead and isn’t logged. If it connects, the program prints out the pair and logs it to the updated list. The list contains the date and time of execution within its file name. The bigger the proxy list the better, for obvious reasons, but you shouldn’t delete the original one after running a check. Proxy servers may spring back to life after a little while, so it can’t hurt to just leave them all there in the original list.
The Code
Modify this to your liking, it’s simple and straightforward. It’ll spawn 1000 (woot!) threads per “round”, which will each try to connect to a server socket (the proxy server). Change this if you like. Here it is:
#!/usr/bin/perl
use IO::Socket;
use Threads;
#-----------------------------------+
# guidjos' Proxy List Checker v1.1 |
#-----------------------------------+
if (@ARGV < 1){
print "\n\n\n Failed. Usage: $0 [proxylisttxtfile] [timeout(seconds)]. \n\n";
print " If no timeout is specified, default == 4 will be used.\n\n\n guidj0s\n";
exit;
}
@hora = localtime;
$nomelista = "proxylist_$hora[3]-$hora[4]--$hora[2]h$hora[1]m.log";
open(novalista, ">>$nomelista"); # I know, I know.
if ($ARGV[1])
{
$tout = $ARGV[1];
}
else
{
$tout = 4;
}
sub testaservidor
{
my($ip, $falha) = @_;
my $sockteste = IO::Socket::INET->new(
PeerAddr => $ip,
Proto => 'tcp',
Timeout => $falha,
Reuse => 1
);
if ($sockteste)
{
$sockteste->close();
print " $ip responded.\n\n";
print novalista "$ip";
return 1;
}
else
{
print " $ip is dead.\n\n";
return 0;
}
}
open(dados, $ARGV[0]) || die("\n\n proxy list file specified was invalid\n\n\n");
@proxies = <dados>;
close dados;
my $atual = 1;
my $vivos;
print "\n\n Starting to check proxy servers...\n\n\n ";
while ($atual <= $#proxies)
{
for my $quantas (1..1000)
{
if ($atual <= $#proxies)
{
my $crianca = threads->new(\&testaservidor, $proxies[$atual-1], $tout);
$atual++;
}
}
foreach (threads->list)
{
$resultado = $_->join;
if ($resultado)
{
$vivos++;
}
}
}
close novalista;
print "\n\n Done.\n\n $vivos out of $#proxies servers responded and were\n logged to $nomelista\n\n\n";

No trackbacks yet.