Jul 27, 2001, 9:50 AM
Post #2 of 6
Port Scanner: Do it yourself if you really have to and never ask for help. It's a simple 3-liner if you know what you're doing but I guess it *is* way over your head.
Ok, let's do something more mature and explain how to do a port scanner and maybe a one-line nuke to go with it.
use CGI 'remote_host';
print "Content-type: text/htm\n\n<pre>";
IO::Socket::INET->new(PeerHost => remote_host(), PeerPort => $_)
&& print "Port $_ Open\n"
So, what are we doing in the previous program? We are iterating over port values (0..1024), trying to open a socket with remote host we got from CGI's remote_host method. If opening the new socket succeeds, we print "Port n Open\n", otherwise, we do nothing and move on to the next port.
Now, I would like to clear something please, I'm not against helping people for I do that all the time and whenever I can. However, I don't think asking for a port scanner is a good idea. So, unless you're a sysadmin who would like to monitor a few machines for running services, you really should not need a port scanner. Using it to probe visitors' machines is probably a questionable behavior. If you were a sysadmin, the question you asked would've been different and I don't want to list all possible ways of asking about how to monitor machines or how to open a socket or how to connect.
Sorry all for being rude perhaps in the first post. If anybody has anything else to add, I'm here to listen.
(This post was edited by abstracts on Jul 27, 2001, 12:54 PM)