เหตุผลที่ต้องใช้ anonymous proxy แท้
ก็เพื่อเอาไว้ใช้ เข้าเวปที่โดนห้าม, แฮกชาวบ้าน, ปั่นโหวตที่คิด ip, ปั่น view youtube ฯลฯ
proxy_check.pl
#!/usr/bin/perl -w
use LWP::UserAgent;#เรียกใช้ LWP::UserAgent
my $file = 'proxyslist.txt';#ชื่อไฟล์ที่เก็บ รายชื่อ proxy
my $DEBUG = 0;#ตั้งไปงั้นแหละ !! .. เผื่อ อยาก print ดูรายละเอียดให้ตั้งเป็น 1
my $TIMEOUT = 3;# ระยะเวลา timeout ในการโหลด หน้าเวป .. คิดเป็น วินาที
my $VERSION = '1.1';
my $UPDATE = '18/10/2012';
my @proxys = file2array($file);# โหลดไฟล์ มาเป็น array
print "[+] Load $file (".scalar(@proxys).") ip\n";# แสดงจำนวน สมาชิก ใน array @proxy
foreach my $proxy (@proxys){#วน Loop ดึงค่า ใน array มาทำงานทีละอัน
print "[+] $proxy\n";
checkProxy($proxy);#ส่งค่า $proxy ให้วิ่งเข้าไปทำงานในฟังชั่น checkProxy (บรรทัดที่ 23)
}
sub checkProxy {
my $proxy = $_[0];#รับค่าที่ส่งเข้ามา
my ($ip, $port) = split(/:/, $proxy);#แยกค่าที่ส่งเข้ามา ตรงเครื่องหมาย : เป็น ip และ port
my $browser = LWP::UserAgent->new(
timeout => $TIMEOUT #timeout ที่ประกาศไว้ที่บรรทัดที่ 7 .. เอามาใช้ตรงนี้
);
$browser->proxy('http','http://'.$proxy.'/');
my $resp = $browser->get('http://reip.stephack.com/index.php?ip='.$ip.'&port='.$port);
if($resp->is_success && $resp->status_line =~ /200/){
if($resp->content !~ /\s/){
print "=====\n";
print "[+] anonymous -> ".$proxy."\n";
print "=====\n";
open OUTFILE, ">> proxy.txt" or die "Can't open proxy.txt: $!";
print OUTFILE $proxy."\n";
close OUTFILE;
}else{
print "[-] non anonymous -> ".$resp->status_line."\n".$resp->content."\n" if($DEBUG);#แสดงค่า status_line กับ เนื้อหา content ถ้ามีการเซ็ต $DEBUG = 1
}
}else{
print "[!] not response -> ".$resp->status_line."\n".$resp->content."\n" if($DEBUG);#แสดงค่า status_line กับ เนื้อหา content ถ้ามีการเซ็ต $DEBUG = 1
}
}
sub file2array {
my @var;
open FILE, "<", $_[0] or die "[!] Can't open $_[0] : $!";
while(<FILE>){
my $line = $_;
$line=~s/\r|\n//g; #ลบ \r \n ที่มีในบรรทัดออกให้หมด
$line=~s/^\s+|\s+$//g; #ลบ ช่องว่าง (ช่องไฟ) หน้าและหลังบรรทัดออกให้หมด
$line=~s/([^\#]*)\#.*/$1/g; #remove in-line comment
next if($line=~/^#/); #ignore line comment
next if(length($line)==0); #ถ้า บรรทัดว่างเปล่า ให้ข้าม
push(@var, $line); #เก็บเข้าตัวแปล @var
}
close FILE;
return(unique(@var)); # ส่งค่า @var คืน โดยตรวจค่าใน array กับฟังชั่น unique บรรทัดที่ 62 ก่อน (ตัดซ้ำออก)
}
sub unique {
return keys %{{ map { $_ => 1 } @_ }};
}
2 comments:
ตัว LWP มันจะแตก thread ส่ง request เลยรึเปล่าครับ หรือว่า ส่วนนี้เราจะต้องเขียนเอาเอง
ต้องเขียนเอง ค๊าบ
Post a Comment