Weblog entry #11 for nicc777
I recently wanted to check which servers on a large sub-net was listening on port 22/tcp.
Now nmap is obviously the tool to use, but the output was very long, and not all that clear. Here is a quick one liner I did, and maybe some one else can use this as well.
$ nmap -P0 -sT -p22 10.0.102.0/23 | perl -e 'while(<>){ chomp; push( @l, $_ ); } $lc = -1; foreach $t ( @l ) { $lc++; if( $t =~ /Interesting ports on (\d+\.\d+\.\d+\.\d+)/ ) { $ip = $1; $nlc = $lc + 2; if( $l[$nlc] =~ /open/ ) { print "IP: $ip\t\t$l[$nlc]\n"; } } }'
IP: 10.0.102.3 22/tcp open ssh
IP: 10.0.102.4 22/tcp open ssh
IP: 10.0.102.5 22/tcp open ssh
IP: 10.0.102.54 22/tcp open ssh
IP: 10.0.102.57 22/tcp open ssh
IP: 10.0.102.58 22/tcp open ssh
IP: 10.0.102.59 22/tcp open ssh
IP: 10.0.102.69 22/tcp open ssh
IP: 10.0.102.250 22/tcp open ssh
IP: 10.0.102.251 22/tcp open ssh
IP: 10.0.103.54 22/tcp open ssh
IP: 10.0.103.57 22/tcp open ssh
IP: 10.0.103.58 22/tcp open ssh
IP: 10.0.103.59 22/tcp open ssh
IP: 10.0.103.69 22/tcp open ssh
Comments on this Entry
-oG -you don't have to fiddle around so much, since that writes the result in 'grep-able' form in one line per host.
Kind regards
--
Debian GNU/Linux on an IBM Thinkpad T43p
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]