Skip to content

Instantly share code, notes, and snippets.

@sdcampbell
Last active August 4, 2021 21:01
Show Gist options
  • Save sdcampbell/8b0fddfce6fc80baf4f96b38cda31e90 to your computer and use it in GitHub Desktop.
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
#!/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