shell - Ruby system arguments -


I am trying to use the system to run nmap from the Ruby program. I want to avoid some arguments to prevent shell injection, so that I am using the following form:

  system ('nmap', '-sn', hostname)   

This works fine, though I want to use the -ox- option to output xml stdout the following code does not appear to be working though:

  system ('nmap', '-sn', '-oX -', hostname)   

-OX - ignore logic Is being done Anyone can suggest a workaround?

As system also saves spaces in the argument, your system In fact with the call -oX -

  nmap -sn -x \ - example.com   

Part space Gaya. Thus a valid argument for NMAP will not be considered. To fix this, you really have to give it two arguments. Here, the location will not be saved in a single argument:

  system ('nmap', '-sn', '-oX', '-', hostname)    

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -