From d50436def89111b54bcaf6d0628eca364b5ea688 Mon Sep 17 00:00:00 2001 From: dmiller Date: Sat, 20 Sep 2014 05:40:43 +0000 Subject: [PATCH] Let scripts set/preserve port.version.service_fp Previously, calling nmap.set_port_version would delete a service fingerprint if it existed. Now, setting probestate to anything but "hardmatched" will preserve the fingerprint, if it exists. This allows scripts (like http-server-header) to use "softmatched" to set version info but still encourage users to submit fingerprints. --- nse_nmaplib.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/nse_nmaplib.cc b/nse_nmaplib.cc index a6fc7cd40..e241b9cc0 100644 --- a/nse_nmaplib.cc +++ b/nse_nmaplib.cc @@ -572,6 +572,7 @@ static int l_set_port_version (lua_State *L) *hostname = (lua_getfield(L, 4, "hostname"), lua_tostring(L, -1)), *ostype = (lua_getfield(L, 4, "ostype"), lua_tostring(L, -1)), *devicetype = (lua_getfield(L, 4, "devicetype"), lua_tostring(L, -1)), + *service_fp = (lua_getfield(L, 4, "service_fp"), lua_tostring(L, -1)), *service_tunnel = (lua_getfield(L, 4, "service_tunnel"), lua_tostring(L, -1)); if (service_tunnel == NULL || strcmp(service_tunnel, "none") == 0) @@ -594,7 +595,8 @@ static int l_set_port_version (lua_State *L) target->ports.setServiceProbeResults(p->portno, p->proto, probestate, name, tunnel, product, version, extrainfo, hostname, ostype, devicetype, - (cpe.size() > 0) ? &cpe : NULL, NULL); + (cpe.size() > 0) ? &cpe : NULL, + probestate==PROBESTATE_FINISHED_HARDMATCHED ? NULL : service_fp); return 0; }