ы ?
:baby:
мне нужно чтобы регулярно соксы фильтровались и оставались только те которые могут пахать .из-за того что нет реального айпи
#!/usr/bin/perl
use strict;
use lib qw(.);
use IO::Socket qw(:DEFAULT);
use LWP;
use Time::HiRes qw( time );
use Time::Local;
use DBI;
use data;
$| = 1;
my @goodproxies;
my $sock;
my $proxy;
my $ping;
my $dbh = mysql_connect();
my $sth = $dbh->prepare('SELECT data FROM jobs WHERE id = ?');
$sth->execute(0);
my $freq = $sth->fetchrow_arrayref;
@$freq[0]=~m/^FREQ (\d+)$/i;
$freq = $1/1000+0.5;
$sth = $dbh->prepare('SELECT ip, ping, port, hip, id FROM bots');
$sth->execute();
my $data;
while ($data = $sth->fetchrow_hashref){
next if (Time::Local::timelocal(localtime)-str2datetime($data->{'ping'}) > $freq);
my $ip = $data->{'ip'};
my ($a,$b,$c) = split /\./, $ip;
next if ((($a == 192) and ($b = 168)) or (($a == 172) and ($b >= 16) and ($b <= 31)) or ($a == 10));
$ip = $data->{'hip'} if ($a == 127);
$proxy = $data->{'id'};
next if ($data->{'port'} eq 0);
# $proxy~/([0-9\.]+)/;
# my ($host, $port) = ($1, $2);
eval {
local $SIG{ALRM} = sub {die};
alarm 4;
$ping = time;
$sock = IO::Socket::INET->new(PeerAddr => $ip,
PeerPort => $data->{'port'},
Proto => 'tcp',
Timeout => 2);
if (defined($sock)){
$sock->send(chr(5).chr(0).chr(0));
my $buffer;
my $rnum = $sock->recv($buffer,5);
my @res = split //, $buffer;
$sock->close;
if (ord($res[0]) == 05 ) {
$ping=int((time()-$ping)*1000);
my @a = ($proxy, $ping);
push @goodproxies, \@a;
}
}
}
}
$dbh->do('DELETE FROM socks');
$dbh->do('INSERT INTO socks SET id = ?, ping = ?', undef, @$_[0], @$_[1]) foreach (@goodproxies);
$dbh->disconnect;
exit;
sub str2datetime {
my ($buffer)=@_;
require Time::Local;
my ($sec,$min,$hours,$mday,$mon,$year);
if ($buffer =~ /^([12]\d\d\d)-([01]\d)-([0123]\d) ([012]\d):([0-5]\d):([0-5]\d)$/)
{ ($year,$mon,$mday,$hours,$min,$sec) = ($1-1900,$2,$3,$4,$5,$6);
$mon = $mon-1;
return &Time::Local::timelocal($sec,$min,$hours,$mday,$mon,$year);
}
else { return(); } # no match at all !
}
#!/usr/bin/perl
use IO::Socket qw(:DEFAULT);
my @goodproxies;
my $ping;
$host="microsoft.com";
$url="/proxies.txt";
$debug = 1;
$socket = IO::Socket::INET->new( Proto => "tcp", PeerAddr => "$host", PeerPort => "80") || die "\nCONNECTION FAILED";
print $socket "GET $url HTTP/1.1\r\n";
print $socket "Host: $host\r\n";
print $socket "Connection: close\r\n";
print $socket "\r\n\r\n";
$a=1;
while (<$socket>){
chomp;
if(/:/ && $a>7){
($ip,$port) = split (/:/,$_,2);
warn "Now checking $ip:$port\n" if $debug;
local $SIG{ALRM} = sub {die};
alarm 4;
$ping = time;
$sock = IO::Socket::INET->new(PeerAddr => $ip,
PeerPort => $port,
Proto => 'tcp',
Timeout => 2);
if (defined($sock)){
$sock->send(chr(5).chr(0).chr(0));
my $buffer;
my $rnum = $sock->recv($buffer,5);
my @res = split //, $buffer;
$sock->close;
if (ord($res[0]) == 05 ) {
$ping=int((time()-$ping)*1000);
$proxy = "$ip:$port";
my @a = ($proxy, $ping);
push @goodproxies, \@a;
warn "Nice proxy!!\n" if $debug}
else{warn "Bad Socks5 proxy :(\n" if $debug}
}
else {print "Can't connect to socks!" if $debug};
}
$a=$a+1;
}