in reply to Re: Code optomization
in thread Code optomization
#!/usr/bin/perl # ProxyHunter 0.2 # By Sock (http://www.socklabs.com) # ChangeLog # 18.5.2004 First release use strict; use warnings; use LWP::UserAgent; use HTTP::Request::Common; use Getopt::Long; my $opt_page = 1; our %info = (version => "0.3", format => 0, agent => "Sock's Proxy Hunter/0.3", clear => 0, anonymous => 0, spranonymous => 1, elite => 1 ); our @data; our @marks; # Lets define the data structure for the proxy array # ip/host, port, type, country, anon level, use (0 no:1 yes) push @data, ["127.0.0.1", "8080", "http", "USA", "Anonymous", "0"]; push @data, ["127.0.0.2", "8081", "socks5", "USA", "Highly Anonymous", + "0"]; # Name, target page, clear all whitespace (1 yes, 0 no) push @marks, [1, "Stayinvisible.com", "http://www.stayinvisible.com/in +dex.pl/proxy_list?order=&offset=0", 1]; push @marks, [1, "PublicProxyServer.com", "http://www.publicproxyserve +rs.com/page1.html", 1]; push @marks, [1, "Proxy4Free.com", "http://www.proxy4free.com/page1.ht +ml", 1]; print <<"EOF"; ProxyHunter $info{version} (c) 2003-2004 Sock Released without warranty under the terms of the Artistic License. EOF our $opt_debug; our $opt_format; our $opt_verbose; GetOptions("help|?",\&showhelp, "debug", \$opt_debug, "page=s", \$opt_ +page, "output=s", \$opt_format, "verbose|v", \$opt_verbose); sub showhelp() { print << "EOF" ; Usage: $0 [options] dir1 dir2 file1 file2 ... Options: --debug Show extra debug information --spage=x Set the page to read from on the stayinvis website. Not U +sed --output=x Set the output format. See examples: [0] 192.168.1.1 80 [1] http 192.168.1.1 8080 # Highly Anonymous - Russia [2] 192.168.1.1:80\@http --help Display this help message EOF exit; } our $debug = $opt_debug; our $format = $opt_format ? $opt_format : $info{format}; our $t = 0; print "Debug option set.\n" if ($debug); #stayinvis(); markloop(); sub markloop() { foreach my $m (@marks) { if ($m->[0] == 1) { print "[+Scan] Starting engine for $m->[1]\n"; print " [Debug] Initilizing agent.\n" if ($debug); my $proxhunter = LWP::UserAgent->new(); $proxhunter->agent($info{agent}); print " [Debug] Retrieving site: $m->[2].\n" if ($debug); my $http_res = $proxhunter->request(POST $m->[2]); my $stuff = $http_res->content; print " [Debug] Error, failed.\n" and return unless ($http +_res->is_success); if ($m->[3] == 1){ print " [Debug] Removing white spaces.\n" if ($debug); $stuff =~ s/\s//g; } print " [Debug] Sifting through results.\n" if ($debug); while ($stuff =~ m/<td[^>]*>(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d +{1,3})<\/td><td[^>]*>(\d{1,5})<\/td><td[^>]*>(\w*)<\/td><td[^>]*>(\w* +)<\/td>/g) { $t++; my $use_this = 0; for ($3) { m/transparent/ && $info{clear} == 1 && do {$use_th +is = 1; last;}; m/anonymous/ && $info{anonymous} == 1 && do {$use_ +this = 1; last;}; m/highanonymity/ && $info{spranonymous} == 1 && do + {$use_this = 1; last;}; } # print " [Debug] Found: $1, $2, $3, $4, $5, use $use_t +his\n" if ($debug); push @data, ["$1", "$2", "http", "$3", "$4", "$use_thi +s"]; } print "[-Scan] Stopping engine for $m->[1]\n\n"; } } } #my $good_proxy_count = scalar(@good_proxies); (my $sec, my $min, my $hour, my $mday, my $mon, my $year, my $wday, my + $yday, my $isdst)=localtime(time); $mon++; my $g; my $outfile = "n$min"."h$hour"."d$mday"."m$mon".".proxylist"; print "Setting output file as $outfile.\n" if ($debug); open(fileOUT, ">>$outfile"); foreach my $d (@data) { if ($d->[5] == 1) { $g++; if ($format == 0) {print fileOUT "$d->[0]:$d->[1]\n";} if ($format == 1) {print fileOUT "$d->[2]\t$d->[0]:$d->[1] #$d->[3 +] - $d->[4]\n";} if ($format == 2) {print fileOUT "$d->[0]:$d->[1]\@$d->[2]\n";} } } close(fileOUT); print "All tasks complete. Loaded $g out of $t proxies.\n"; exit;
|
|---|