#!/usr/bin/perl # # (c) Sakuramboo (2600 mag-vol 23-num 3) # # Modified and enhanced by deprecated (james@phpnasium.net) # use warnings; use IO::Socket; $port = 1; $ip = "192.168.0.2"; my $txt; for ($port = 0; $port <= 1000; $port++){ $sock = IO::Socket::INET->new(PeerAddr => $ip,PeerPort => $port,Proto => 'tcp',Timeout => '1'); if ($sock){ if ($port == 80){ print $sock "GET / HTTP/1.1\r\n"; print $sock "Host: www.example.com\r\n"; print $sock "Connection: Close\r\n\r\n"; while(<$sock>) { if ($_ =~ /Apache/) { $_ =~ s/Server\://; print "PORT 80 (opened) -- Response:$_"; } # close($sock); } } elsif ($port == 22) { while(<$sock>) { print "PORT 22 (opened) -- Response: $_"; close($sock); } } else { read($sock,$txt,1024); print $txt; # # while(<$sock>) { print "PORT $port (opened) -- Response: $_\n"; # close($sock); # } close($sock); } close ($sock); } else { # print "$port closed\n"; } }