Eikonal Blog

2010.06.23

Memory of things disappearing > nmap stuff > getports.awk

Filed under: infosec — Tags: , — sandokan65 @ 10:50

Source: http://web.archive.org/web/20050114184017/http://www.synnergy.net/~rwx/nmap-xml-tools/getports.awk

Code:

#!/bin/awk -f 
# Lists open ports coming from nmap.
# It assumes the file is in PYX format and complies with the appropriate DTD.

function reset()
{
	protocol = "";
	portid = 0;
	state = ""
	service = "";
	in_port = 0;
}

BEGIN {
	reset();
}

/\(port$/ {
	in_port = 1;
}

/\)port$/ {
	printf("%s %u %s %s\n", protocol, portid, state, service);
	reset();
}

/^Aprotocol / {
	if (in_port)
		protocol = $2;
}

/^Aportid / {
	if (in_port)
		portid = $2;
}

/^Astate / {
	if (in_port)
		state = $2;
}

/^Aname / {
	if (in_port)
		service = $2;
}

Related here: AWK – https://eikonal.wordpress.com/2011/09/30/awk/

4 Comments »

  1. […] of things disappearing > nmap stuff > getports.awk – https://eikonal.wordpress.com/2010/06/23/memory-of-things-disappearing-nmap-stuff-getports-awk/ – an awk script listing open ports coming from […]

    Like

    Pingback by Vulnerability Assessment tools « Eikonal Blog — 2010.06.23 @ 10:53

  2. […] | Memory of things disappearing > nmap stuff > getports.awk – https://eikonal.wordpress.com/2010/06/23/memory-of-things-disappearing-nmap-stuff-getports-awk/ Share this:StumbleUponDiggRedditLike this:LikeBe the first to like this post. Leave a […]

    Like

    Pingback by Scripting languages « Eikonal Blog — 2011.09.30 @ 12:44

  3. […] | Memory of things disappearing > nmap stuff > getports.awk – https://eikonal.wordpress.com/2010/06/23/memory-of-things-disappearing-nmap-stuff-getports-awk/ Advertisement Eco World Content From Across The Internet. Featured on EcoPressed The rent […]

    Like

    Pingback by awk « Eikonal Blog — 2011.09.30 @ 12:45

  4. […] | Memory of things disappearing > nmap stuff > getports.awk – https://eikonal.wordpress.com/2010/06/23/memory-of-things-disappearing-nmap-stuff-getports-awk/ | AWK – https://eikonal.wordpress.com/2011/09/30/awk/ Share this:StumbleUponDiggRedditLike […]

    Like

    Pingback by Unix tricks « Eikonal Blog — 2012.03.14 @ 13:47


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: