exploit the possibilities
Home Files News &[SERVICES_TAB]About Contact Add New

nms2.pl

nms2.pl
Posted Aug 17, 1999
Authored by rain forest puppy

Latest release on rfp's perl-based nmap stub. This program reads in nmap output and parses it into easy to use structures that you can use in your code.

tags | tool, perl, nmap
systems | unix
SHA-256 | 778f5df29eb9440ab9cf1fdc25aa0f4d944509189388f05e04b7d2b96d12e843

nms2.pl

Change Mirror Download
#
# Perl NMAP stub v2 (skeleton) -- tested with nmap 2.07
#
# by .rain.forest.puppy. rfpuppy@iname.com
#
# v2: changed @udp/@tcp to %udp/%tcp; added smurf and state support
#

while(<>){ %udp=%tcp={}, $udp=$tcp=0, $Index=$OS=$IP=$Name=$Host="";
(($$3{$1}=$2) && $$3++) while(m#([0-9]+)/([a-z]+)/(udp|tcp)/\w*/\w*///[,]*#g);
$$1=$2 while(m#([^ \t\n:]+):\W*([^\t\n]+)#g);
(($Smurf=$1) && next) if (m#Status: Smurf\W*\(\W*([0-9]+)#);
($Host=~m#([\w\.]+)\W*\(([^ \t]*)\)#) && (($IP=$1) && ($Name=$2)) ;
#} complete code to parse nmap machine logfile -- gained one line since v1

# Usage: cat nmap_machine_output_file | perl this_program.pl
# OR perl this_program.pl < nmap_machine_output_file
# OR perl this_program.pl nmap_machine_output_file
#
# provides %udp, %tcp (hashes; key=portnum, value=state)
# $udp, $tcp (number of ports for each)
# $IP (ip address in string format)
# $Name (reverse DNS hostname, if avail)
# $Index (Sequence Index, if avail)
# $OS (OS name, if avail)
# $Smurf (Number of smurf responses, if avail)
##########################################################
# Put your code here
##########################################################

# Example/demo code to show usage

# normal info variables
print "IP: $IP" ;
print " Hostname: $Name" if $Name;
print " (Seq: $Index OS: $OS)" if ($OS ne "");

# how to step through all ports -- unordered
print "\nTotal TCP ports: $tcp\n";
foreach $pnum (keys %tcp){
printf "%20s", "$pnum=$tcp{$pnum}";}

# how to step through all ports -- sorted
print "\nTotal UDP ports: $udp\n";
@tmp=sort {$a <=> $b} (keys %udp);
foreach $pnum (@tmp){
printf "%20s", "$pnum=$udp{$pnum}";}

# how to query if a particular port was found
print "\n** Possibly running webserver" if (exists $tcp{80});

# how to check the specific state of a port
print "\n** Telnet port open" if ($tcp{23} eq "open");

print "\n\n";

### End of your code #####################################
}

Login or Register to add favorites

File Archive:

April 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Apr 1st
    10 Files
  • 2
    Apr 2nd
    26 Files
  • 3
    Apr 3rd
    40 Files
  • 4
    Apr 4th
    6 Files
  • 5
    Apr 5th
    26 Files
  • 6
    Apr 6th
    0 Files
  • 7
    Apr 7th
    0 Files
  • 8
    Apr 8th
    22 Files
  • 9
    Apr 9th
    14 Files
  • 10
    Apr 10th
    10 Files
  • 11
    Apr 11th
    13 Files
  • 12
    Apr 12th
    14 Files
  • 13
    Apr 13th
    0 Files
  • 14
    Apr 14th
    0 Files
  • 15
    Apr 15th
    30 Files
  • 16
    Apr 16th
    10 Files
  • 17
    Apr 17th
    22 Files
  • 18
    Apr 18th
    45 Files
  • 19
    Apr 19th
    0 Files
  • 20
    Apr 20th
    0 Files
  • 21
    Apr 21st
    0 Files
  • 22
    Apr 22nd
    0 Files
  • 23
    Apr 23rd
    0 Files
  • 24
    Apr 24th
    0 Files
  • 25
    Apr 25th
    0 Files
  • 26
    Apr 26th
    0 Files
  • 27
    Apr 27th
    0 Files
  • 28
    Apr 28th
    0 Files
  • 29
    Apr 29th
    0 Files
  • 30
    Apr 30th
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2022 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close