def __init__(self, ipLat, ipLong, projName): self.__projName = projName self.__ROOT_DIR = os.path.dirname(os.path.abspath(__file__)) self.__retrieveBingApi = ApiChecker() self.__ipLat = ipLat self.__ipLong = ipLong self.__baseMap = "https://dev.virtualearth.net/REST/V1/Imagery/Map/Road/" + self.__ipLat + "%2C" + self.__ipLong + "/14?mapSize=640,480&mapLayer=TrafficFlow&format=jpeg&pushpin=" + self.__ipLat + "," + self.__ipLong + ";60;&key=" + self.__retrieveBingApi.getBingApi( )
def __init__(self, reqUri, projName): self.__projName = projName self.__retrieveIpInfoApi = ApiChecker() self.__accessToken = self.__retrieveIpInfoApi.getIpInfoKEY() self.__handler = ipinfo.getHandler(self.__accessToken) self.__reqUri = reqUri try: self.__details = self.__handler.getDetails(self.__reqUri) except Exception: print(Fore.RED + "\n\t\t [!] An Error has occured!") print(Fore.YELLOW + "\n\t\t [i] Retrying...") self.__details = self.__handler.getDetails(self.__reqUri) #hostname try: if self.__details.hostname == None or self.__details.hostname == '': self.__hostname = "None" else: self.__hostname = self.__details.hostname except AttributeError as hostErr: self.__hostname = "None" #city if self.__details.city == None or self.__details.city == '': self.__city = "None" else: self.__city = self.__details.city #region if self.__details.region == None or self.__details.region == '': self.__region = "None" else: self.__region = self.__details.region #country if self.__details.country == None or self.__details.country == '': self.__country = "None" else: self.__country = self.__details.country #postal if self.__details.postal == None or self.__details.postal == '': self.__postal = "None" else: self.__postal = self.__details.postal #latitude if self.__details.latitude == None or self.__details.latitude == '': self.__latitude = "0" else: self.__latitude = self.__details.latitude #longitude if self.__details.longitude == None or self.__details.longitude == '': self.__longitude = "0" else: self.__longitude = self.__details.longitude #get asn number try: if self.__details.org == None or self.__details.org == '': self.__asnName = "None" else: self.__asnNum = self.__details.org.split()[ 0] #get the asn number only except AttributeError: self.__asnNum = "None" #get other asn details try: self.__asn = ASNGetter(self.__asnNum) self.__asnCompany = self.__asn.getAsnCompany() self.__asnWebsite = self.__asn.getAsnWebsite() self.__asnName = self.__asn.getAsnName() except Exception as asnErr: print(Fore.RED + "\n\t\t [!]ERROR!", asnErr) #get map static image try: self.__mapGetter = MapGetter(self.__latitude, self.__longitude, self.__projName) self.__locMap = self.__mapGetter.getMap() except Exception as mapErr: print(Fore.RED + "\n\t\t [!]ERROR!", mapErr)
class MapGetter(): def __init__(self, ipLat, ipLong, projName): self.__projName = projName self.__ROOT_DIR = os.path.dirname(os.path.abspath(__file__)) self.__retrieveBingApi = ApiChecker() self.__ipLat = ipLat self.__ipLong = ipLong self.__baseMap = "https://dev.virtualearth.net/REST/V1/Imagery/Map/Road/" + self.__ipLat + "%2C" + self.__ipLong + "/14?mapSize=640,480&mapLayer=TrafficFlow&format=jpeg&pushpin=" + self.__ipLat + "," + self.__ipLong + ";60;&key=" + self.__retrieveBingApi.getBingApi( ) def getMap(self): try: __map = open( self.__ROOT_DIR + "\\temp\\" + self.__projName + "\\maps.jpg", "wb") __rawMap = requests.get(self.__baseMap) __map.write(__rawMap.content) __map.close() except Exception as mapE: print(Fore.RED + "\n\t\t [!] An Error has Occured!", mapE)
def __init__(self, urlIp): self.__urlIp = urlIp self.__getApi = ApiChecker()
class SingleIP(): def __init__(self, urlIp): self.__urlIp = urlIp self.__getApi = ApiChecker() def main(self): __reqUri = self.__urlIp __baseReqUrl = "http://api.ipstack.com/" + __reqUri + "?access_key=" + self.__getApi.getIpStackApi( ) + "&format=1" __response = requests.get(__baseReqUrl) __rawJson = __response.json() __availability = __rawJson['type'] __reqType = socket.gethostbyname(__reqUri) if __availability == None: print(Fore.RED + "\n\t\t [!] The Website / IP cannot be accessed." + Fore.YELLOW + " Retrying..." + Style.RESET_ALL) else: sipProjName = "New Proj" try: while sipProjName != None: print(Fore.BLUE) sipProjName = input("\n\t\t [|] Enter PROJECT Name #:> ") if sipProjName == "" or sipProjName == None: pass else: __webIP = json.loads(__response.text)['ip'] print(Fore.YELLOW + "\n\t\t [+] Getting INFORMATION of " + Fore.CYAN + __reqUri) if __reqType == __reqUri: print(Fore.LIGHTYELLOW_EX + "\n\t\t [+] IP Address: " + Fore.CYAN + __reqUri) else: print(Fore.LIGHTYELLOW_EX + "\n\t\t [+] Web HOSTNAME: " + Fore.CYAN + __reqUri) if __availability == 'ipv4' or __availability == 'ipv6': if __availability == 'ipv4': print(Fore.LIGHTYELLOW_EX + "\t\t [i] IPV4: " + Fore.CYAN + __rawJson['ip']) elif __availability == 'ipv6': print(Fore.LIGHTYELLOW_EX + "\t\t [i] IPV6: " + Fore.CYAN + __rawJson['ip']) #generate HTML Output Document print( Fore.YELLOW + "\n\t\t [i] Generating HTML Document Report") sipProj = MainCompiler(__webIP, sipProjName) sipProj.startGetter() else: print( Fore.LIGHTRED_EX + "\t\t [i] Unknown URI(Uniform Resource Identifier) Type" ) except Exception: pass
import sys sys.path.append('../') from inc.api import ApiChecker print(ApiChecker.test())