#!/usr/bin/perl
use IO::Socket;
# ********************************************************************
# pscanner : portscan hosts using a tcp connection through
# IO::Socket module and prepackaged port-numbers RFC list
#
# Fri Oct 4 10:50:44 EDT 2002
# ********************************************************************
print "Enter the name of the server you would like to scan\n";
chomp( my $server = <STDIN> );
print "What port would you like to start at\? \(1-65000\)\n";
chomp( my $start = <STDIN> );
## Store portlist in @portlist
open( PORTLIST, "./port-numbers" ) or die "Unable to open portlist: $!
+";
my @portlist = <PORTLIST>;
close(PORTLIST);
chomp(@portlist);
foreach (@portlist) {
next if $_ =~ /^\#/;
@whatever = ( split ( /\s+/, ( split (/\//) )[0] ) );
( $service, $portnumber ) = ( @whatever[0], @whatever[1] );
$servicelist{"$portnumber"} = "$service";
}
for ( $portnumber = $start ; $portnumber <= 65000 ; $portnumber++ ) {
$sock = IO::Socket::INET->new(
PeerAddr => $server,
PeerPort => $portnumber,
Proto => 'tcp'
);
if ($sock) {
print "Connected on port $portnumber $servicelist{$portnumber}
+\n";
}
else {
# print "$port failed\n";
}
} # End for
=head1 NAME
pscanner - Scans host on TCP ports and pulls service type from RFC por
+t-numbers list
=head1 DESCRIPTION
Determines which TCP ports and services a host may be using by opening
a TCP socket connection. Used for determining what services are runni
+ng on a
specific host.
=head1 PREREQUISITE
IO::Socket module
Pre-packaged RFC port numbers list
=head1 COREQUISITE
None
=head1 README
Determines which TCP ports and services a host may be using by opening
a TCP socket connection. Used for determining what services are runni
+ng on a
specific host.
=pod OSNAMES
Unix, Linux, Win32
=pod SCRIPT CATEGORIES
Networking
=cut
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|