| 1 | #!/usr/bin/env perl |
| 2 | use strict; |
| 3 | use warnings; |
| 4 | use IO::Socket::INET; |
| 5 | use LWP::Simple; |
| 6 | |
| 7 | our $g_client = 'petella'; |
| 8 | our $g_client_version = '0.1'; |
| 9 | $g_client = 'LimeWire'; |
| 10 | $g_client_version = '5.1.2'; |
| 11 | our %g_cache; |
| 12 | |
| 13 | #my $sock = IO::Socket::INET->new(PeerAddr => 'localhost', PeerPort => '80'); |
| 14 | #my $sock = IO::Socket::INET->new('localhost:80'); |
| 15 | #print $sock "GET / HTTP/1.1\r\nHost: localhost\r\nConnection: close\r\n\r\n"; |
| 16 | #while(<$sock>) { print $_; STDOUT->flush; } $sock->close; |
| 17 | |
| 18 | my $gwc_url = 'http://gwc.lame.net/gwcii.php'; |
| 19 | foreach( split(/\n/, get($gwc_url."?client=$g_client&version=$g_client_version&hostfile=1")) ) { |
| 20 | my($ip, $port) = split(/:/, $_); |
| 21 | $ip =~ s/[^0-9\.]//; |
| 22 | $port =~ s/[^0-9]//; |
| 23 | $g_cache{$ip}=$port; |
| 24 | } |
| 25 | |
| 26 | while (my($ip, $port) = each(%g_cache)){ |
| 27 | print "connecting to gnutella:$ip:$port\n"; |
| 28 | #my $sock = IO::Socket::INET->new('10.127.85.96:35301'); |
| 29 | my $sock = IO::Socket::INET->new(PeerAddr => $ip, PeerPort => $port); |
| 30 | print $sock "GNUTELLA CONNECT/0.6\r\n". |
| 31 | "User-Agent: $g_client/$g_client_version\r\n". |
| 32 | "X-Ultrapeer: False\r\n". |
| 33 | "X-Query-Routing: 0.1\r\n\r\n"; |
| 34 | while(<$sock>) { |
| 35 | print $_; |
| 36 | STDOUT->flush; |
| 37 | } |
| 38 | $sock->close; |
| 39 | } |
| 40 | |
| 41 | |
| 42 | |