diff --git a/README.md b/README.md index 7412ce4..6bca5ca 100644 --- a/README.md +++ b/README.md @@ -97,16 +97,64 @@ $ ronin-nmap convert scan.xml scan.json ## Examples +Performing an `nmap` scan and returning the parsed nmap XML data: + ```ruby require 'ronin/nmap' xml = Ronin::Nmap.scan(syn_scan: true, ports: [80, 443], targets: '192.168.1.*') # => # +``` + +Accessesing the nmap XML scan data: + +```ruby xml.hosts # => [#, ...] -host = xml.hosts.first -host.open_ports +host = xml.host +# => # + +xml.host.open_ports +# => [#, +# #, +# #, +# #, +# #] + +port = xml.host.open_ports.first +# => # + +port.state +# => :open + +port.protocol +# => :tcp + +port.service +# => #, #, #, #, #]>> + +port.scripts +# => {"ssh-hostkey"=>..., +# "ssh2-enum-algos"=>...} +``` + +Printing the parsed nmap XML data: + +```ruby +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 ``` ## Requirements