Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update nmap module #1879

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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