Skip to content

SpiderFoot automates OSINT for threat intelligence and mapping your attack surface.

Respect throttling.

Steve91cc7e606855
diff --git a/modules/sfp_pwned.py b/modules/sfp_pwned.py
index 7f5e3945..2c8e2658 100644
--- a/modules/sfp_pwned.py
+++ b/modules/sfp_pwned.py
@@ -11,6 +11,7 @@
import sys
import json
+import time
from sflib import SpiderFoot, SpiderFootPlugin, SpiderFootEvent
class sfp_pwned(SpiderFootPlugin):
@@ -66,12 +67,18 @@ class sfp_pwned(SpiderFootPlugin):
url = "https://haveibeenpwned.com/api/v2/breachedaccount/" + qry
hdrs = { "Accept": "application/vnd.haveibeenpwned.v2+json" }
+ # https://haveibeenpwned.com/API/v2#RateLimiting
+ time.sleep(1.5)
res = self.sf.fetchUrl(url, timeout=self.opts['_fetchtimeout'],
useragent="SpiderFoot", headers=hdrs)
- if res['code'] == 404:
+ if res['code'] in [ 404, "404" ]:
return None
+ if res['code'] in [ 429, "429" ]:
+ # Back off a little further
+ time.sleep(2)
+
try:
ret = json.loads(res['content'])
except Exception as e: