Skip to content

Commit

Permalink
Update nmap module
Browse files Browse the repository at this point in the history
  • Loading branch information
fredjt authored and niavasha committed Oct 28, 2024
1 parent 71b3d62 commit 331fd7e
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions modules/sfp_tool_nmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,6 @@ def handleEvent(self, event):
self.debug(f"Error running Nmap: {stderr}, {stdout}")
return

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

if eventName == "IP_ADDRESS":
if "No exact OS matches for host" in content or "OSScan results may be unreliable" in content:
self.debug(f"Couldn't reliably detect the OS for {eventData}")
return

try:
opsys = None
for line in content.split('\n'):
Expand All @@ -179,14 +180,20 @@ def handleEvent(self, event):
for line in content.split('\n'):
opsys = None
if "scan report for" in line:
currentIp = line.split("(")[1].replace(")", "")
if "OS details:" in line:
junk, opsys = line.split(": ")

if opsys and currentIp:
if "(" in line:
currentIp = line.split("(")[1].replace(")", "")
else:
currentIp = line.split(" for ")[1]
ipevent = SpiderFootEvent("IP_ADDRESS", currentIp, self.__name__, event)
self.notifyListeners(ipevent)
elif "OS details:" in line:
opsys = line.split(": ")[1]

elif "No exact OS matches for host" in line or "OSScan results may be unreliable" in line:
self.debug(f"Couldn't reliably detect the OS for {currentIp}")
currentIp = None

if opsys and currentIp:
evt = SpiderFootEvent("OPERATING_SYSTEM", opsys, self.__name__, ipevent)
self.notifyListeners(evt)
currentIp = None
Expand Down

0 comments on commit 331fd7e

Please sign in to comment.