Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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
39 changes: 39 additions & 0 deletions API/back_api/customfunc/shodanapi.py
Original file line number Diff line number Diff line change
@@ -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"))