mirror of
https://github.com/nmap/nmap.git
synced 2026-02-06 21:46:34 +00:00
o Added the new --script-args-file option which allows you to specify
the name of a file containing all of your desired NSE script arguments. The arguments may be separated with commas or newlines and may be overridden by arguments specified on the command-line with --script-args. [Daniel Miller]
This commit is contained in:
@@ -1,5 +1,11 @@
|
||||
# Nmap Changelog ($Id$); -*-text-*-
|
||||
|
||||
o Added the new --script-args-file option which allows you to specify
|
||||
the name of a file containing all of your desired NSE script
|
||||
arguments. The arguments may be separated with commas or newlines
|
||||
and may be overridden by arguments specified on the command-line
|
||||
with --script-args. [Daniel Miller]
|
||||
|
||||
o [NSE] Added the script http-vuln-cve2009-3960 that detects and exploits the
|
||||
CVE 2009-3960 XML injection vulnerability in Adobe products. [Hani
|
||||
Benhabiles]
|
||||
|
||||
@@ -330,6 +330,7 @@ class NmapOps {
|
||||
#ifndef NOLUA
|
||||
int script;
|
||||
char *scriptargs;
|
||||
char *scriptargsfile;
|
||||
int scriptversion;
|
||||
int scripttrace;
|
||||
int scriptupdatedb;
|
||||
|
||||
12
docs/nmap.1
12
docs/nmap.1
@@ -2,12 +2,12 @@
|
||||
.\" Title: nmap
|
||||
.\" Author: [see the "Author" section]
|
||||
.\" Generator: DocBook XSL Stylesheets v1.76.1 <http://docbook.sf.net/>
|
||||
.\" Date: 01/01/2012
|
||||
.\" Date: 01/02/2012
|
||||
.\" Manual: Nmap Reference Guide
|
||||
.\" Source: Nmap
|
||||
.\" Language: English
|
||||
.\"
|
||||
.TH "NMAP" "1" "01/01/2012" "Nmap" "Nmap Reference Guide"
|
||||
.TH "NMAP" "1" "01/02/2012" "Nmap" "Nmap Reference Guide"
|
||||
.\" -----------------------------------------------------------------
|
||||
.\" * Define some portability stuff
|
||||
.\" -----------------------------------------------------------------
|
||||
@@ -1358,6 +1358,13 @@ pairs\&. Names and values may be strings not containing whitespace or the charac
|
||||
The online NSE Documentation Portal at
|
||||
\m[blue]\fB\%http://nmap.org/nsedoc/\fR\m[]
|
||||
lists the arguments that each script accepts\&.
|
||||
.RE
|
||||
.PP
|
||||
\fB\-\-script\-args\-file \fR\fB\fIfilename\fR\fR .\" --script-args-file .\" script arguments from file
|
||||
.RS 4
|
||||
Lets you load arguments to NSE scripts from a file\&. Any arguments on the command line supersede ones in the file\&. The file can be an absolute path, or a path relative to Nmap\*(Aqs usual search path (NMAPDIR, etc\&.) Arguments can be comma\-separated or newline\-separated, but otherwise follow the same rules as for
|
||||
\fB\-\-script\-args\fR, without requiring special quoting and escaping, since they are not parsed by the shell\&.
|
||||
.RE
|
||||
.PP
|
||||
\fB\-\-script\-help \fR\fB\fIfilename\fR\fR\fB|\fR\fB\fIcategory\fR\fR\fB|\fR\fB\fIdirectory\fR\fR\fB|\fR\fB\fIexpression\fR\fR\fB|all\fR\fB[,\&.\&.\&.]\fR .\" --script-help
|
||||
.RS 4
|
||||
@@ -1368,7 +1375,6 @@ script, you would run
|
||||
\fBnmap \-\-script\-help ftp\-anon\fR\&. In addition to getting help for individual scripts, you can use this as a preview of what scripts will be run for a specification, for example with
|
||||
\fBnmap \-\-script\-help default\fR\&.
|
||||
.RE
|
||||
.RE
|
||||
.PP
|
||||
\fB\-\-script\-trace\fR .\" --script-trace
|
||||
.RS 4
|
||||
|
||||
@@ -2409,7 +2409,24 @@ The online NSE Documentation Portal at <ulink url="http://nmap.org/nsedoc/"/>
|
||||
lists the arguments that each script accepts.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--script-args-file <replaceable>filename</replaceable></option>
|
||||
<indexterm significance="preferred"><primary><option>--script-args-file</option></primary></indexterm>
|
||||
<indexterm><primary>script arguments from file</primary><seealso><option>--script-args-file</option></seealso></indexterm></term>
|
||||
|
||||
<listitem>
|
||||
<para>
|
||||
Lets you load arguments to NSE scripts from a file. Any arguments on the
|
||||
command line supersede ones in the file. The file can be an absolute path,
|
||||
or a path relative to Nmap's usual search path (NMAPDIR, etc.)
|
||||
Arguments can be comma-separated or newline-separated, but otherwise follow
|
||||
the same rules as for <option>--script-args</option>, without requiring
|
||||
special quoting and escaping, since they are not parsed by the shell.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<option>--script-help <replaceable>filename</replaceable>|<replaceable>category</replaceable>|<replaceable>directory</replaceable>|<replaceable>expression</replaceable>|all<optional>,...</optional></option>
|
||||
@@ -2431,7 +2448,6 @@ lists the arguments that each script accepts.
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><option>--script-trace</option>
|
||||
<indexterm significance="preferred"><primary><option>--script-trace</option></primary></indexterm></term>
|
||||
|
||||
@@ -191,8 +191,8 @@ Black Hat Briefings in 2010.</para>
|
||||
execute by providing categories, script file names, or the name of
|
||||
directories full of scripts you wish to execute. You can customize
|
||||
some scripts by providing arguments to them via the
|
||||
<option>--script-args</option><indexterm><primary><option>--script-args</option></primary></indexterm>
|
||||
option.
|
||||
<option>--script-args</option><indexterm><primary><option>--script-args</option></primary></indexterm> and <option>--script-args-file</option><indexterm><primary><option>--script-args-file</option></primary></indexterm>
|
||||
options.
|
||||
The <option>--script-help</option><indexterm><primary><option>--script-help</option></primary></indexterm>
|
||||
shows a description of what each selected script does.
|
||||
The two remaining options,
|
||||
@@ -702,6 +702,20 @@ Nmap script database, but should be used cautiously since Nmap may contain explo
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>
|
||||
<indexterm><primary><option>--script-args-file</option></primary></indexterm>
|
||||
<option>--script-args-file <replaceable>filename</replaceable></option>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>This option is the same as
|
||||
<option>--script-args</option> except that you pass the
|
||||
arguments in a file rather than on the command-line. See
|
||||
<xref linkend="nse-args"/> for a detailed
|
||||
explanation.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>
|
||||
<indexterm><primary><option>--script-help</option></primary></indexterm>
|
||||
@@ -971,6 +985,15 @@ http://nmap.org/nsedoc/scripts/afp-showmount.html
|
||||
the <varname>whois</varname> table in the example below.
|
||||
</para>
|
||||
|
||||
<para>Rather than pass the arguments on the command line with
|
||||
<option>--script-args</option>, you may store them in a file
|
||||
(separated by commas or newlines) and specify just the file name
|
||||
with <option>--script-args-file</option>. Options specified
|
||||
with <option>--script-args</option> on the command-line take
|
||||
precedence over those given in a file. The filename may be
|
||||
given as an absolute path or relative to Nmap's usual
|
||||
search path (NMAPDIR, etc.)
|
||||
|
||||
<para>Here is a typical Nmap invocation with script arguments:
|
||||
<informalexample>
|
||||
<indexterm><primary><option>--script-args</option></primary><secondary>example of</secondary></indexterm>
|
||||
|
||||
4
nmap.cc
4
nmap.cc
@@ -629,6 +629,8 @@ void parse_options(int argc, char **argv) {
|
||||
{"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
|
||||
@@ -657,6 +659,8 @@ void parse_options(int argc, char **argv) {
|
||||
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){
|
||||
|
||||
@@ -290,6 +290,7 @@ static void open_cnse (lua_State *L)
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
13
nse_main.lua
13
nse_main.lua
@@ -1044,6 +1044,19 @@ do -- Load script arguments (--script-args)
|
||||
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?
|
||||
|
||||
Reference in New Issue
Block a user