Index: nse_main.cc =================================================================== --- nse_main.cc (revision 26658) +++ nse_main.cc (working copy) @@ -290,6 +290,7 @@ setbfield(L, -1, "scripthelp", o.scripthelp); setsfield(L, -1, "script_dbpath", SCRIPT_ENGINE_DATABASE); setsfield(L, -1, "scriptargs", o.scriptargs); + setsfield(L, -1, "scriptargsfile", o.scriptargsfile); setsfield(L, -1, "NMAP_URL", NMAP_URL); } Index: NmapOps.h =================================================================== --- NmapOps.h (revision 26658) +++ NmapOps.h (working copy) @@ -330,6 +330,7 @@ #ifndef NOLUA int script; char *scriptargs; + char *scriptargsfile; int scriptversion; int scripttrace; int scriptupdatedb; Index: nmap.cc =================================================================== --- nmap.cc (revision 26658) +++ nmap.cc (working copy) @@ -628,6 +628,8 @@ {"script_updatedb", no_argument, 0, 0}, {"script-args",required_argument,0,0}, {"script_args",required_argument,0,0}, + {"script-args-file",required_argument,0,0}, + {"script_args_file",required_argument,0,0}, {"script-help",required_argument,0,0}, {"script_help",required_argument,0,0}, #endif @@ -656,6 +658,8 @@ o.chooseScripts(optarg); } else if (optcmp(long_options[option_index].name,"script-args")==0){ o.scriptargs=strdup(optarg); + } else if (optcmp(long_options[option_index].name,"script-args-file")==0){ + o.scriptargsfile=strdup(optarg); } else if (optcmp(long_options[option_index].name, "script-trace") == 0) { o.scripttrace = 1; } else if (optcmp(long_options[option_index].name, "script-updatedb") == 0){ Index: nse_main.lua =================================================================== --- nse_main.lua (revision 26658) +++ nse_main.lua (working copy) @@ -986,6 +986,19 @@ end end nmap.registry.args = parse_table("{"..args.."}", 1); + -- Check if user wants to read scriptargs from a file + if cnse.scriptargsfile ~= nil then --scriptargsfile path/to/file + local t, path = cnse.fetchfile_absolute(cnse.scriptargsfile) + assert(t == 'file', format("%s is not a file", path)) + local argfile = assert(open(path, 'r')); + local argstring = argfile:read("*a") + argstring = gsub(argstring,"\n",",") + local tmpargs = parse_table("{"..argstring.."}",1) + for k,v in pairs(nmap.registry.args) do + tmpargs[k] = v + end + nmap.registry.args = tmpargs + end end -- Update Missing Script Database?