From bece275e49ba47f3c242977fbd1a88d166deccc3 Mon Sep 17 00:00:00 2001 From: rellisreal Date: Mon, 8 Dec 2025 12:31:26 +0800 Subject: [PATCH] Created shodan sample class, add a few details on breachapi --- .../customfunc/{breach.py => breachapi.py} | 9 ++++- API/back_api/customfunc/shodanapi.py | 39 +++++++++++++++++++ 2 files changed, 46 insertions(+), 2 deletions(-) rename API/back_api/customfunc/{breach.py => breachapi.py} (83%) create mode 100644 API/back_api/customfunc/shodanapi.py diff --git a/API/back_api/customfunc/breach.py b/API/back_api/customfunc/breachapi.py similarity index 83% rename from API/back_api/customfunc/breach.py rename to API/back_api/customfunc/breachapi.py index 3bfdfde..1915119 100644 --- a/API/back_api/customfunc/breach.py +++ b/API/back_api/customfunc/breachapi.py @@ -4,8 +4,9 @@ from dotenv import load_dotenv -# Refernce : https://breachdirectory.com/api_documentation -# ToDO: Accept API from Database & Pass data back into database +# Reference : https://breachdirectory.com/api_documentation +# To DO: Accept API from Database & Pass data back into database +# How T Call: Provide target email when creating object, use getBreachData method for automatic call / return load_dotenv() @@ -52,3 +53,7 @@ def handleRedirect(self): def readResponse(self): data = self.res.read() return data.decode("utf-8") + + def setAPI(self, apikey): + # To DO Set API in the DB + pass diff --git a/API/back_api/customfunc/shodanapi.py b/API/back_api/customfunc/shodanapi.py new file mode 100644 index 0000000..5fdc734 --- /dev/null +++ b/API/back_api/customfunc/shodanapi.py @@ -0,0 +1,39 @@ +import os + +from dotenv import load_dotenv +from shodan import Shodan + +load_dotenv() + +# To DO: Accept API from Database & Pass data back into database +# Needs API key returns DICT + + +class ShodanClass: + def __init__(self, url=None, ip=None): + self.api = os.getenv("SHODAN_API") + self.shodaninstance = Shodan(f"{self.api}") + self.url = url + self.ip = ip + + def urlWorkflow(self): + # requires paid API + if self.url is None: + return "Please supply a URL" + + search_value = self.shodaninstance.search(f"{self.url}") + return search_value + + def ipWorkflow(self): + if self.ip is None: + return "Please supply an IP" + + ip_value = self.shodaninstance.host(f"{self.ip}") + return ip_value + + def setAPI(self, apikey): + # To DO Set API in the DB + pass + + +# Retrive from Dictionary: print(value.get("hostnames"))