Skip to content

Commit

Permalink
sfp_shodan: Set error state when reaching API limits.
Browse files Browse the repository at this point in the history
  • Loading branch information
smicallef committed Nov 2, 2022
1 parent 3b8bdbb commit ab1362d
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions modules/sfp_shodan.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ def queryHost(self, qry):
)
time.sleep(1)

if res['code'] in ["403", "401"]:
self.error("SHODAN API key seems to have been rejected or you have exceeded usage limits.")
self.errorState = True
return None

if res['content'] is None:
self.info(f"No SHODAN info found for {qry}")
return None
Expand Down Expand Up @@ -124,6 +129,12 @@ def searchHosts(self, qry):
useragent="SpiderFoot"
)
time.sleep(1)

if res['code'] in ["403", "401"]:
self.error("SHODAN API key seems to have been rejected or you have exceeded usage limits.")
self.errorState = True
return None

if res['content'] is None:
self.info(f"No SHODAN info found for {qry}")
return None
Expand Down Expand Up @@ -152,6 +163,12 @@ def searchHtml(self, qry):
useragent="SpiderFoot"
)
time.sleep(1)

if res['code'] in ["403", "401"]:
self.error("SHODAN API key seems to have been rejected or you have exceeded usage limits.")
self.errorState = True
return None

if res['content'] is None:
self.info(f"No SHODAN info found for {qry}")
return None
Expand Down

0 comments on commit ab1362d

Please sign in to comment.