Module: Nmap::Scripts
- Included in:
- HostScript, Port, Postscript, Prescript
- Defined in:
- lib/nmap/scripts.rb
Instance Method Summary collapse
-
#script_data ⇒ Hash{String => Hash{String => Array<String>}}
The structured output of the NSE scripts.
-
#scripts ⇒ Hash{String => String}
The output from the NSE scripts ran against the open port.
Instance Method Details
#script_data ⇒ Hash{String => Hash{String => Array<String>}}
The structured output of the NSE scripts.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/nmap/scripts.rb', line 31 def script_data unless @script_data @script_data = {} traverse = lambda do |node| case node.name when 'script', 'table' unless node.xpath('*[@key]').empty? hash = {} node.elements.each do |element| hash[element['key']] = traverse.call(element) end hash else array = [] node.elements.each do |element| array << traverse.call(element) end array end when 'elem' node.inner_text else raise(NotImplementedError,"unrecognized XML NSE element: #{node}") end end @node.xpath('script').each do |script| @script_data[script['id']] = traverse.call(script) end end return @script_data end |
#scripts ⇒ Hash{String => String}
The output from the NSE scripts ran against the open port.
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/nmap/scripts.rb', line 11 def scripts unless @scripts @scripts = {} @node.xpath('script').each do |script| @scripts[script['id']] = script['output'] end end return @scripts end |