-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsamair
89 lines (71 loc) · 2.33 KB
/
samair
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/usr/bin/perl
use LWP::UserAgent;
use Getopt::Long;
my %options = ();
GetOptions(\%options, "w=s");
print q {
================================================================================
# title: Samair.ru http proxies parser and tester
# developer: code91
# e-mail: < code[at]insicuri[dot]net >
Usage: perl samair {options}
Options: -w [path] write results on a file.
================================================================================
};
my $samair = "http://www.samair.ru/proxy/time-01.htm";
my $myip = "http://www.azpoint.net/Script_vari/indirizzoIP.asp";
my $ua = LWP::UserAgent->new();
print "[+] Retrieving local ip... ";
my $response = $ua->get( $myip );
my $my_ip = parse_ips( $response->content ) or die "[-] Unable to retrieve real IP from azpoint.net\n";
print "$my_ip\n";
print "[+] Getting proxy list from samair.ru...\n";
my $resp = $ua->get( $samair );
my $res = $resp->content();
my( $proxy, @proxies );
while( $res =~ m/(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/g )
{
$proxy = $1;
push( @proxies, $proxy );
}
print "[+] Testing $#proxies proxies...\n";
foreach my $parsed_proxy( @proxies )
{
$ua->proxy( 'http', "http://$parsed_proxy/" );
my $resp2 = $ua->get( $myip );
my $proxy_ip = parse_ips( $resp2->content() );
my @parsed_proxy;
if( $resp2->is_success )
{
if ( $proxy_ip == $my_ip )
{
print "\t - $proxy_ip is a transparent proxy\n";
}
elsif ( $proxy_ip != $my_ip )
{
print "\t - $proxy_ip is an anonymous proxy\n";
push( @parsed_proxies, $proxy_ip );
}
}
}
if( $options{"w"} )
{
print "[+] Writing results in $options{'w'}...\n";
open(FILE, ">", $options{'w'}) or die ("[-] Unable to open file in <$options{'w'}> path.\n");
print FILE "@parsed_proxies";
close( FILE );
}
sub parse_ips( $ )
{
my $ip = '';
my @content = split('\n', shift);
foreach my $line( @content )
{
if( $line =~ /(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/ )
{
$ip = $1;
last;
}
}
return $ip;
}