Skip to content

Commit

Permalink
Fixed Error Handling For Shodan & Vulner
Browse files Browse the repository at this point in the history
  • Loading branch information
tahaafarooq authored May 19, 2024
1 parent f064580 commit ec075e0
Showing 1 changed file with 26 additions and 16 deletions.
42 changes: 26 additions & 16 deletions scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,18 @@ def port_discovery(self, url):
read = ports.readlines()
return read
s.close()"""
SKey = self.params['s_key']
SApi = shodan.Shodan(SKey)
try:
SKey = self.params['s_key']
SApi = shodan.Shodan(SKey)

SInfo = SApi.host(ip)
ports = json.dumps(SInfo['ports'])
SInfo = SApi.host(ip)
ports = json.dumps(SInfo['ports'])

return ports
return ports
except shodan.exception.APITimeout:
return "Time Out! Something Went Wrong!"
except shodan.exception.APIError:
return "Shodan Key Not Authorized"

def dns_record(self, url):
domain = urlparse(url).netloc
Expand Down Expand Up @@ -203,17 +208,22 @@ def exploit_info(self, url):
if server == '':
return "No Server Version Found! Or Type!"
else:
VKey = self.params["v_key"] # get api key by going to https://vulners.com
VApi = vulners.Vulners(api_key=VKey)

search = VApi.searchExploit(server)
search = json.dumps(search, indent=2)

os.system(f"touch output_exploit_search.json")
with open(f"output_exploit_search.json", "w") as exploitResult:
exploitResult.writelines(search)

return f"Visit /output"
try:
VKey = self.params["v_key"] # get api key by going to https://vulners.com
VApi = vulners.Vulners(api_key=VKey)

search = VApi.searchExploit(server)
search = json.dumps(search, indent=2)

os.system(f"touch output_exploit_search.json")
with open(f"output_exploit_search.json", "w") as exploitResult:
exploitResult.writelines(search)

return f"Visit /output"
except requests.exceptions.HTTPError:
return "Something Went Wrong! But it works!"
except:
return "Something Went Wrong But it works!"

def mitigation_info(self, url):
payloadxss = "<script>document.write('xss');</script>"
Expand Down

0 comments on commit ec075e0

Please sign in to comment.