1
0
mirror of https://github.com/nmap/nmap.git synced 2026-02-12 16:36:34 +00:00

When using the NSE nmap.set_port_state(), check if the requested port is already in the requested state. Otherwise, "Duplicate port" messages are printed, and the inaccurate "script-set" state reason is used. This mostly just occurs when -sV is used (I first spotted this when using Brandon's nbstat.nse with -sV, although other scripts do the same thing)

This commit is contained in:
kris
2008-03-27 22:15:50 +00:00
parent 60924c7308
commit 5f81cca485
2 changed files with 10 additions and 0 deletions

View File

@@ -8,6 +8,11 @@ o Reformat Nmap COPYING file (e.g. remove C comment markers, reduce
when presented by the Windows executable (NSIS) installer. Thanks
to Jah for the patch (which was modified slightly by Fyodor).
o Changed the NSE function nmap.set_port_state() so that it checks to
see if the requested port is already in the requested state. This
prevents "Duplicate port" messages during the script scan and the
inaccurate "script-set" state reason. [Kris]
o Updated ripeQuery.nse to not print extraneous whitespace. [Kris]
Nmap 4.60

View File

@@ -371,12 +371,16 @@ static int l_set_port_state(lua_State* l, Target* target, Port* port) {
case 'o':
if (strcmp(state, "open"))
luaL_argerror (l, 4, "Invalid port state.");
if (port->state == PORT_OPEN)
goto noset;
plist->addPort(port->portno, port->proto, NULL, PORT_OPEN);
port->state = PORT_OPEN;
break;
case 'c':
if (strcmp(state, "closed"))
luaL_argerror (l, 4, "Invalid port state.");
if (port->state == PORT_CLOSED)
goto noset;
plist->addPort(port->portno, port->proto, NULL, PORT_CLOSED);
port->state = PORT_CLOSED;
break;
@@ -386,6 +390,7 @@ static int l_set_port_state(lua_State* l, Target* target, Port* port) {
port->reason.reason_id = ER_SCRIPT;
noset:
free(state);
return 0;
}