Skip to content

Commit 331fd7e

Browse files
fredjtniavasha
authored andcommitted
Update nmap module
1 parent 71b3d62 commit 331fd7e

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

modules/sfp_tool_nmap.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,6 @@ def handleEvent(self, event):
149149
self.debug(f"Error running Nmap: {stderr}, {stdout}")
150150
return
151151

152-
if "No exact OS matches for host" in content or "OSScan results may be unreliable" in content:
153-
self.debug(f"Couldn't reliably detect the OS for {eventData}")
154-
return
155152
except Exception as e:
156153
self.error(f"Unable to run Nmap: {e}")
157154
return
@@ -161,6 +158,10 @@ def handleEvent(self, event):
161158
return
162159

163160
if eventName == "IP_ADDRESS":
161+
if "No exact OS matches for host" in content or "OSScan results may be unreliable" in content:
162+
self.debug(f"Couldn't reliably detect the OS for {eventData}")
163+
return
164+
164165
try:
165166
opsys = None
166167
for line in content.split('\n'):
@@ -179,14 +180,20 @@ def handleEvent(self, event):
179180
for line in content.split('\n'):
180181
opsys = None
181182
if "scan report for" in line:
182-
currentIp = line.split("(")[1].replace(")", "")
183-
if "OS details:" in line:
184-
junk, opsys = line.split(": ")
185-
186-
if opsys and currentIp:
183+
if "(" in line:
184+
currentIp = line.split("(")[1].replace(")", "")
185+
else:
186+
currentIp = line.split(" for ")[1]
187187
ipevent = SpiderFootEvent("IP_ADDRESS", currentIp, self.__name__, event)
188188
self.notifyListeners(ipevent)
189+
elif "OS details:" in line:
190+
opsys = line.split(": ")[1]
189191

192+
elif "No exact OS matches for host" in line or "OSScan results may be unreliable" in line:
193+
self.debug(f"Couldn't reliably detect the OS for {currentIp}")
194+
currentIp = None
195+
196+
if opsys and currentIp:
190197
evt = SpiderFootEvent("OPERATING_SYSTEM", opsys, self.__name__, ipevent)
191198
self.notifyListeners(evt)
192199
currentIp = None

0 commit comments

Comments
 (0)