Last active
August 4, 2021 21:01
-
-
Save sdcampbell/8b0fddfce6fc80baf4f96b38cda31e90 to your computer and use it in GitHub Desktop.
Extracts HTTP hosts and ports from a Nessus file and saves to files to be used with Aquatone
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
#!/usr/bin/ruby | |
require 'ruby-nessus' | |
require 'set' | |
file = ARGV[0] | |
if ARGV.length == 0 | |
raise "Usage: #{$0} /path/to/file.nessus" | |
end | |
ness = RubyNessus::Parse.new(file) | |
ips = Set.new | |
ports = Set.new | |
ness.scan.each_host do |host| | |
host.each_event do |event| | |
if event.port.service.to_s == 'www' | |
if host.hostname | |
ips << host.hostname | |
else | |
ips << host.ip | |
end | |
ports << event.port.number.to_s | |
#p event | |
end | |
end | |
end | |
File.open("nessus_http_hosts.txt", "w+") do |f| | |
f.puts ips.to_a | |
end | |
File.open("nessus_http_ports.txt", "w+") do |f| | |
f.puts ports.to_a.sort.join(",") | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment