Skip to content

Commit

Permalink
sfp_tool_whatweb: Enforce a timeout to prevent being blocked.
Browse files Browse the repository at this point in the history
  • Loading branch information
smicallef committed Feb 7, 2023
1 parent a5ac79a commit 6517c50
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions modules/sfp_tool_whatweb.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import json
import os.path
from subprocess import PIPE, Popen
from subprocess import PIPE, Popen, TimeoutExpired

from spiderfoot import SpiderFootEvent, SpiderFootPlugin, SpiderFootHelpers

Expand Down Expand Up @@ -128,8 +128,13 @@ def handleEvent(self, event):
eventData
]
try:
p = Popen(args, stdout=PIPE, stderr=PIPE)
p = Popen(args, stdout=PIPE, stderr=PIPE, timeout=300)
stdout, stderr = p.communicate(input=None)
except TimeoutExpired:
p.kill()
stdout, stderr = p.communicate()
self.debug(f"Timed out waiting for WhatWeb to finish against {eventData}")
return
except Exception as e:
self.error(f"Unable to run WhatWeb: {e}")
return
Expand Down

0 comments on commit 6517c50

Please sign in to comment.