mirror of
https://github.com/nmap/nmap.git
synced 2026-01-04 13:49:03 +00:00
Update --script-args to note that many scripts qualify their arguments with the script name, and that you can pass unqualified arguments to affect every script using that name. Also updated scripting.xml to emphasize that instead of using nmap.registry.args directly, scripts should get their arguments with stdnse.get_script_args. Regenerated the nroff too after making these changes to the source XML
This commit is contained in:
@@ -2,12 +2,12 @@
|
||||
.\" Title: nmap-update
|
||||
.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author]
|
||||
.\" Generator: DocBook XSL Stylesheets v1.76.1 <http://docbook.sf.net/>
|
||||
.\" Date: 02/25/2012
|
||||
.\" Date: 03/01/2012
|
||||
.\" Manual: nmap-update Reference Guide
|
||||
.\" Source: nmap-update
|
||||
.\" Language: English
|
||||
.\"
|
||||
.TH "NMAP\-UPDATE" "1" "02/25/2012" "nmap\-update" "nmap\-update Reference Guide"
|
||||
.TH "NMAP\-UPDATE" "1" "03/01/2012" "nmap\-update" "nmap\-update Reference Guide"
|
||||
.\" -----------------------------------------------------------------
|
||||
.\" * Define some portability stuff
|
||||
.\" -----------------------------------------------------------------
|
||||
|
||||
11
docs/nmap.1
11
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: 02/25/2012
|
||||
.\" Date: 03/01/2012
|
||||
.\" Manual: Nmap Reference Guide
|
||||
.\" Source: Nmap
|
||||
.\" Language: English
|
||||
.\"
|
||||
.TH "NMAP" "1" "02/25/2012" "Nmap" "Nmap Reference Guide"
|
||||
.TH "NMAP" "1" "03/01/2012" "Nmap" "Nmap Reference Guide"
|
||||
.\" -----------------------------------------------------------------
|
||||
.\" * Define some portability stuff
|
||||
.\" -----------------------------------------------------------------
|
||||
@@ -1354,9 +1354,10 @@ http\-\&.
|
||||
Lets you provide arguments to NSE scripts\&. Arguments are a comma\-separated list of
|
||||
name=value
|
||||
pairs\&. Names and values may be strings not containing whitespace or the characters \(oq{\(cq, \(oq}\(cq, \(oq=\(cq, or \(oq,\(cq\&. To include one of these characters in a string, enclose the string in single or double quotes\&. Within a quoted string, \(oq\e\(cq escapes a quote\&. A backslash is only used to escape quotation marks in this special case; in all other cases a backslash is interpreted literally\&. Values may also be tables enclosed in
|
||||
{}, just as in Lua\&. A table may contain simple string values or more name\-value pairs, including nested tables\&. A complex example of script arguments is
|
||||
.\" --script-args: example of .sp .if n \{\ .RS 4 .\} .nf \fB\-\-script\-args \*(Aquser=foo,pass=",{}=bar",whois={whodb=nofollow+ripe},userdb=custom\*(Aq\fR .fi .if n \{\ .RE .\}
|
||||
The online NSE Documentation Portal at
|
||||
{}, just as in Lua\&. A table may contain simple string values or more name\-value pairs, including nested tables\&. Many scripts qualify their arguments with the script name, as in
|
||||
xmpp\-info\&.server_name\&. You may use that full qualified version to affect just the specified script, or you may pass the unqualified version (server_name
|
||||
in this case) to affect all scripts using that argument name\&. A script will first check for its fully qualified argument name (the name specified in its documentation) before it accepts an unqualified argument name\&. A complex example of script arguments is
|
||||
\fB\-\-script\-args \*(Aquser=foo,pass=",{}=bar",whois={whodb=nofollow+ripe},xmpp\-info\&.server_name=localhost\*(Aq\fR\&. The online NSE Documentation Portal at
|
||||
\m[blue]\fB\%http://nmap.org/nsedoc/\fR\m[]
|
||||
lists the arguments that each script accepts\&.
|
||||
.RE
|
||||
|
||||
@@ -2398,14 +2398,8 @@ escapes a quote. A backslash is only used to escape quotation marks in this
|
||||
special case; in all other cases a backslash is interpreted literally. Values
|
||||
may also be tables enclosed in <literal>{}</literal>, just as in Lua. A table
|
||||
may contain simple string values or more name-value pairs, including nested
|
||||
tables. A complex example of script arguments is
|
||||
<informalexample>
|
||||
<indexterm><primary><option>--script-args</option></primary><secondary>example of</secondary></indexterm>
|
||||
<literallayout>
|
||||
<command>--script-args 'user=foo,pass=",{}=bar",whois={whodb=nofollow+ripe},userdb=custom'</command>
|
||||
</literallayout>
|
||||
</informalexample>
|
||||
The online NSE Documentation Portal at <ulink url="http://nmap.org/nsedoc/"/>
|
||||
tables. Many scripts qualify their arguments with the script name, as in <literal>xmpp-info.server_name</literal>. You may use that full qualified version to affect just the specified script, or you may pass the unqualified version (<literal>server_name</literal> in this case) to affect all scripts using that argument name. A script will first check for its fully qualified argument name (the name specified in its documentation) before it accepts an unqualified argument name. A complex example of script arguments is
|
||||
<option>--script-args 'user=foo,pass=",{}=bar",whois={whodb=nofollow+ripe},xmpp-info.server_name=localhost'</option>. The online NSE Documentation Portal at <ulink url="http://nmap.org/nsedoc/"/>
|
||||
lists the arguments that each script accepts.
|
||||
</para>
|
||||
</listitem>
|
||||
|
||||
@@ -959,8 +959,9 @@ http://nmap.org/nsedoc/scripts/afp-showmount.html
|
||||
<option>--script-args</option> option. The arguments describe a table of
|
||||
key-value pairs and possibly array values. The arguments are provided to
|
||||
scripts as a table in the registry called
|
||||
<varname>nmap.registry.args</varname>.
|
||||
<varname>nmap.registry.args</varname>, though they are normally accessed through the <literal>stdnse.get_script_args</literal> function.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
The syntax for script arguments is similar to Lua's table constructor
|
||||
syntax. Arguments are a comma-separated list of
|
||||
@@ -984,6 +985,27 @@ http://nmap.org/nsedoc/scripts/afp-showmount.html
|
||||
script, in a table named after the script. That is what is happening with
|
||||
the <varname>whois</varname> table in the example below.
|
||||
</para>
|
||||
|
||||
<para>Script arguments are often qualified with the relevant
|
||||
script name so that a user doesn't unintentially affect multiple
|
||||
scripts with a single generic name. For example, you can set
|
||||
the timeout for responses to the
|
||||
<literal>broadcast-ping</literal> script (and only that script)
|
||||
by setting <literal>broadcast-ping.timeout</literal> to the
|
||||
number of milliseconds you're willing to wait. Sometimes,
|
||||
however, you want a script argument applied more widely. If you
|
||||
remove the qualification and specify just
|
||||
<literal>timeout=250</literal>, you will be setting the value
|
||||
for more than a dozen scripts in addition to
|
||||
<literal>broadcast-ping</literal>. You can even combine
|
||||
qualified and unqualified arguments, and the most specific match
|
||||
takes precedence. For example, you could specify
|
||||
<literal>rlogin-brute.timeout=20000,timeout=250</literal>. In
|
||||
that case, the timeout will be 20,000 for the
|
||||
<literal>rlogin-brute</literal> scripts, and 250 for all other
|
||||
scripts which support this variable
|
||||
(<literal>broadcast-ping</literal>,
|
||||
<literal>lltd-discovery</literal>, etc.)</para>
|
||||
|
||||
<para>Rather than pass the arguments on the command line with
|
||||
<option>--script-args</option>, you may store them in a file
|
||||
@@ -999,7 +1021,7 @@ http://nmap.org/nsedoc/scripts/afp-showmount.html
|
||||
<informalexample>
|
||||
<indexterm><primary><option>--script-args</option></primary><secondary>example of</secondary></indexterm>
|
||||
<literallayout>
|
||||
<command>nmap -sC --script-args 'user=foo,pass=",{}=bar",whois={whodb=nofollow+ripe},userdb=custom'</command>
|
||||
<command>nmap -sC --script-args 'user=foo,pass=",{}=bar",whois={whodb=nofollow+ripe},xmpp-info.server_name=localhost'</command>
|
||||
</literallayout>
|
||||
</informalexample>
|
||||
Notice that the script arguments are surrounded in single quotes. For the
|
||||
@@ -1014,13 +1036,12 @@ nmap.registry.args = {
|
||||
whois = {
|
||||
whodb = "nofollow+ripe"
|
||||
},
|
||||
userdb="custom"
|
||||
xmpp-info.server_name="localhost"
|
||||
}
|
||||
</programlisting>
|
||||
You could then access the username <literal>"foo"</literal> inside
|
||||
your script with this statement:
|
||||
While you could access the values directly from <literal>nmap.registry.args</literal>, it is normally better to use the <literal>stdnse.get_script_args</literal> function like this:
|
||||
<programlisting>
|
||||
local username = nmap.registry.args.user
|
||||
local server_name = stdnse.get_script_args("xmpp-info.server_name")
|
||||
</programlisting>
|
||||
</para>
|
||||
<para>
|
||||
|
||||
@@ -2,12 +2,12 @@
|
||||
.\" Title: zenmap
|
||||
.\" Author: [see the "Authors" section]
|
||||
.\" Generator: DocBook XSL Stylesheets v1.76.1 <http://docbook.sf.net/>
|
||||
.\" Date: 02/25/2012
|
||||
.\" Date: 03/01/2012
|
||||
.\" Manual: Zenmap Reference Guide
|
||||
.\" Source: Zenmap
|
||||
.\" Language: English
|
||||
.\"
|
||||
.TH "ZENMAP" "1" "02/25/2012" "Zenmap" "Zenmap Reference Guide"
|
||||
.TH "ZENMAP" "1" "03/01/2012" "Zenmap" "Zenmap Reference Guide"
|
||||
.\" -----------------------------------------------------------------
|
||||
.\" * Define some portability stuff
|
||||
.\" -----------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user