Created
October 14, 2018 13:27
-
-
Save RoganDawes/327ddb1ac3988b1f69d636efdcb52afe to your computer and use it in GitHub Desktop.
Convert Masscan bin files to a series of nmap invocations
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Typical invocation would be: | |
# masscan_bin2list masscan.bin | parallel | |
# | |
# Example output from masscan_bin2list: | |
# nmap -sV -Pn -vv -n -p 443,80 -oA 10.0.0.1_V 10.0.0.1 | |
# nmap -sV -Pn -vv -n -p 135,139,445 -oA 10.0.0.2_V 10.0.0.2 | |
masscan --readscan $1 -oL - | \ | |
perl -e ' | |
use strict; | |
my %portmap; | |
while (<>) { | |
chomp; | |
next if (/^#/); | |
my @fields = split; | |
push @{ $portmap{$fields[3]} }, $fields[2]; | |
} | |
for my $ip (sort keys %portmap) { | |
print "nmap -sV -Pn -vv -n -p "; | |
print join(",", sort @{ $portmap{$ip} } ); | |
print " -oA ${ip}_V ${ip}\n"; | |
} | |
' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment