Wednesday, 12 October 2016

XML : ruby-nmap how to create hash output instead of xml

I want to use the ruby-nmap gem to do a port scan on a number of instances. Here's what I'm currently using:

    Nmap::Program.scan do |nmap|        nmap.syn_scan = true      nmap.service_scan = true      nmap.os_fingerprint = true      nmap.xml = 'scan.xml'      nmap.verbose = true        # address[:public_ip] is my target      nmap.targets = address[:public_ip]    end    

It creates an xml file, however I would prefer it gives me json or a hash as output and does not write this to a file. Is there any easy way to do this without just reading the xml file it creates?

No comments:

Post a Comment