I'm putting together a script that will enumerate services running in my environment. Example:
I've noticed that in order to grab the server details for HTTP, I had to put $sock->print outside of the while loop. If I leave the $sock->print inside the while loop the HEAD request will not be sent to the web server. Can someone help me to gain a better understanding of why this is different from, say, a simple banner request to port 21 or 22. Of course, I would be interested learning if there is a better approach to obtaining this type of information.my $sock = IO::Socket::INET->new(PeerAddr => $host, PeerPort => $port, Proto => $proto); if ($port == 21) { while (<$sock>) { $sock->print("blah"); my $server = $_; chomp $server; print $server; } } elsif ($port == 22) { while (<$sock>) { $sock->print("\012\012"); my $server = $_; chomp $server; print $server; } } elsif ($port == 80) { $sock->print("HEAD / HTTP/1.0\012\012"); while (<$sock>) { my $server = $_; print $server; } }
cheers, -semio
In reply to banner grabbing by semio
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |