![nmap-dev logo](/images/nmap-dev-logo.png)
Nmap Development mailing list archives
Re: nmaprc.lua?
From: Jacek Wielemborek <d33tah () gmail com>
Date: Sun, 31 Aug 2014 19:16:27 +0200
31.08.2014 18:54, Jacek Wielemborek:
21.05.2013 05:16, Fyodor:On Sun, May 12, 2013 at 10:29 AM, Jacek Wielemborek <wielemborekj1 () gmail comwrote:While using Zenmap, I had the feeling that the „profiles” feature fits nicely into the CLI nmap binary. With nmaprc.lua you could define an associative array called „profiles” which would contain the presets. This way, without typing a few-lines long command, one could run nmap –profile=stealthy example.org”.Good point! I added this to the list of nmaprc ideas at https://svn.nmap.org/nmap/todo/nmap.txt Cheers, FyodorI played with this idea a bit today and wrote a sketch of a patch that adds ~/.nmaprc.lua support. Right now it's broken because I hadn't yet figured out how Nmap tells apart command-line options from target specification, but you might get the basic idea. The patch is in the attachment and should apply against the current trunk. To test it, create an ~/.nmaprc.lua file with the following contents: profiles = { ["ping"] = {"--script", "broadcast-ping", "-d"}, } Now, compile nmap and run the following command: ./nmap --profile ping Nmap has now apppended --script broadcast-ping -d to its command line and will run broadcast-ping in debug mode. As I said though, for some reason you can't mix that with target specification, so "./nmap --profile silent 8.8.8.8" isn't possible yet. The patch relies on a recursive call of parse_options() function in nmap.cc, which replaces argv with a version that has profile arguments appended to it. I know it's messy, but this allowed me to implement this feature with very little code. Please let me know if I'm breaking anything this way. I hadn't added any documentation, tests or Windows support at the moment - let me know if you're still interested in this feature and I might work on that as well. So, what do you think? Jacek
Whoops, valgrind says that I made an off-by-one error when reallocating argv. I attach the second patch, though it still doesn't fix the "targets" bug. BTW, I do know that apply_nmaprc_profile() belongs more to a separate file and should probably be split into smaller chunks that use NSE's utility functions. This is something I left for later.
Attachment:
r33625-nmaprclua-fixed.diff
Description:
Attachment:
signature.asc
Description: OpenPGP digital signature
_______________________________________________ Sent through the dev mailing list http://nmap.org/mailman/listinfo/dev Archived at http://seclists.org/nmap-dev/
Current thread:
- Re: nmaprc.lua? Jacek Wielemborek (Aug 31)
- Re: nmaprc.lua? Jacek Wielemborek (Aug 31)