Skip to content

Instantly share code, notes, and snippets.

@nopslider
Created July 12, 2013 13:05
Show Gist options
  • Save nopslider/5984316 to your computer and use it in GitHub Desktop.
Save nopslider/5984316 to your computer and use it in GitHub Desktop.
Nmap gnmap parser for command line foo
#!/usr/bin/perl -nl
use strict;
next if ( $_!~m/Ports\:/i );
chomp();
my @toks=split( /Ports\:\s*/i, $_ );
my $host=$toks[0];
$host=~s/\s*Host\s*\:\s*(.*?)\s*\(.*?\).*/$1/ig;
my $rest=@toks[1 .. $#toks];
foreach my $port ( split(/,/,$rest ) ) {
$port=~s/\s*(.*?)\s*/$1/ig;
$port=~s/\//,/g;
print "$host,$port";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment