Nmap Security Scanner
*Intro
*Ref Guide
*Install Guide
*Download
*Changelog
*Book
*Docs
Security Lists
*Nmap Hackers
*Nmap Dev
*Bugtraq
*Full Disclosure
*Pen Test
*Basics
*More
Security Tools
*Pass crackers
*Sniffers
*Vuln Scanners
*Web scanners
*Wireless
*Exploitation
*Packet crafters
*More
Site News
Site Search:
Exploit World
Advertising
About/Contact
Credits
Sponsors:
edgeos



Nmap Hackers: Re: Skript k1dz R Us

Re: Skript k1dz R Us

From: rain.forest.puppy <rfpuppy_at_iname.com>
Date: Wed, 30 Dec 1998 21:44:02 -0600

"Look ma, no bloat!"

Jordan Ritter said:
>Far be it for me to coerce anyone out of taking the long route and >writing a bunch of C code that a few lines of sed or awk can do.

Yes, yes, yes. I feel guilty now. So, below is the perl code to parse
nmap's machine log format. And it's only in four lines. Perl hacker
I'm not, but I don't think 4 lines is to shabby. Of course, when I say
4 lines, I mean 4 lines to parse the logs. Obviously more lines of code
to add a function to do something. It will be in with the other nmap
stub files (when they're officially posted next week).

.rain.forest.puppy.

ps. I haven't been able to download nlog, so I don't know what code it
uses to parse the logs. Maybe it's better, I dunno.

--------- begin perl code ------------

while(<>){ @udp=@tcp=(), $udp=$tcp=0, $Index=$OS="";
$$2=push @$2, $1 while(m#([0-9]+)/[a-z]+/(udp|tcp)/////[,]*#g);
$$1=$2 while(m#([^ \n:]+): ([^ \n]+)#g);
$OS=$1 if(m#OS: ([^\n]+)#); #} complete code to parse nmap logfile

# 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 (arrays of ports)
# $udp, $tcp (number of ports for each)
# $Host (ip address in string format)
# $Index (Sequence Index, if avail)
# $OS (OS name, if avail)

##########################################################
# Put your code here
##########################################################

# Example/demo code

print "IP: $Host";
print " (Seq: $Index OS: $OS)" if ($OS ne "");
print "\nTotal TCP ports: $tcp\n";
print join " ", @tcp;
print "\nTotal UDP ports: $udp\n";
print join " ", @udp;
print "\n\n";

### End of your code #####################################
}
Received on Dec 30 1998

[ Nmap | Sec Tools | Mailing Lists | Site News | About/Contact | Advertising | Privacy ]