Created
May 10, 2015 01:49
-
-
Save activeshadow/ebb05a0935941b10864b to your computer and use it in GitHub Desktop.
Generate Markdown table of open ports from Nmap scan results
This file contains hidden or 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
host_addr = %r{Host: (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})} | |
open_port = %r{([0-9]+)/open/} | |
ports = {} | |
ARGV.each do |f| | |
File.foreach(f) do |l| | |
l.scan(host_addr) do |a| | |
l.scan(open_port) do |p| | |
ports[a.first] = [] unless ports.key?(a.first) | |
ports[a.first] << p.first.to_i | |
end | |
end | |
end | |
end | |
puts 'Host | Listening Ports' | |
puts ':--: | :-------------:' | |
ports.each do |a,p| | |
puts "#{a} | **TCP:** #{p.uniq.sort.join(', ')}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment