data/templates/script.rb.erb
#!/usr/bin/env ruby
require 'ronin/nmap'
<%- if @script_type == :parser -%>
<%- if @xml_file -%>
xml = Ronin::Nmap.parse(<%= @xml_file.inspect %>)
<%- else -%>
xml = Ronin::Nmap.parse(ARGV[0])
<%- end -%>
<%- else -%>
xml = Ronin::Nmap.scan do |nmap|
<%- if @xml_file -%>
nmap.xml_file = <%= @xml_file.inspect %>
<%- else -%>
# nmap.xml_file = "path/to/nmap.xml"
<%- end -%>
<%- if @syn_scan -%>
nmap.syn_scan = true
<%- else -%>
# nmap.syn_scan = true
<%- end -%>
<%- if @ports -%>
nmap.ports = <%= @ports.inspect %>
<%- else -%>
# nmap.ports = [22, 80, 443, 8000..9000]
<%- end -%>
<%- case @targets.length -%>
<%- when 0 -%>
nmap.targets = ARGV[0]
<%- when 1 -%>
nmap.targets = <%= @targets[0].inspect %>
<%- else -%>
nmap.targets = <%= @targets.inspect %>
<%- end -%>
end
<%- end -%>
<% if @features[:printing] -%>
xml.each_host do |host|
puts "[ #{host.ip} ]"
host.each_port do |port|
puts " #{port.number}/#{port.protocol}\t#{port.state}\t#{port.service}"
port.scripts.each do |id,script|
puts " [ #{id} ]"
script.output.each_line { |line| puts " #{line}" }
end
end
end
<%- end -%>
<%- if @features[:import] -%>
Ronin::DB.connect
Ronin::Nmap::Importer.import(xml)
<%- end -%>