def post(self, id): """ Accepts POST requests, and processes the form; Redirect to index when completed. id: Tagid of bag sent from sendText button It will lookup Client's IP and tracke GeoIP location, send message to registered user with IP GeoLocationa and TagID. """ # Get Client/visitor's IP. if request.headers.getlist("X-Forwarded-For"): ip = request.headers.getlist("X-Forwarded-For")[0] else: ip = request.remote_addr # if app is running on localhost, it will get 127.0.0.1 which private ip and cannot find IpGeo data. So taking default PublicIP if ip == '172.17.0.1' or ip == '127.0.0.1': ip = '76.27.220.107' #look GeoDat from IP response = ipdata.lookup(ip) # From response we can get lot more Geo data, for here just taking CIty and Country. city = response['city'] country_name = response['country_name'] # Preparing text for sending message text = "Hello we found you bag with Tag: %s at City: %s, country: %s use by IP:%s !" % ( str(id), str(city), str(country_name), str(ip)) model = gbmodel.get_model() # sending text to below number for twilio client message = Client.messages.create(to="+19716786802", from_="+12679152751", body=text) return redirect(url_for('index'))
#!/usr/bin/env python from ipdata import ipdata from pprint import pprint f = open('/home/cam/projects/project_secrets/geo.key', 'r') #print(f) # debugging#don't print API keys apiKey = f.readline().strip() # strips away \n at EOL ipdata = ipdata.IPData(apiKey) # api key goes here # gonna do this manually to get everything online ipAsk = input("Enter IP Address: ") #ipdata = ipdata.IPData('') #api key response = ipdata.lookup(ipAsk) #ip address - this will be !manual later #pprint(response) with open(
token = 'your token key' ipdata = ipdata.IPData(token) ips = [ '106.13.182.60', # '49.234.10.207', # '120.31.138.70', # '112.85.42.185', # '157.230.47.57', # '119.57.120.107', # '113.108.168.215', # '120.98.1.180', # '83.56.44.200', # '119.226.11.100', # '104.248.246.8', '37.213.204.135' ] l = [] for i in ips: response = ipdata.lookup(i, fields=[ 'ip', 'asn', 'calling_code', 'city', 'continent_code', 'continent_name', 'country_code', 'country_name', 'is_eu', 'latitude', 'longitude', 'postal', 'region', 'region_code', 'status', 'threat' ]) l.append(response) #print(i, "={}".format(response)) print(l)
elif len(email_input) == 0: pass except (KeyError,NameError): st.error("Invalid Email, Check Email Again") except (ConnectionError): dv.svg_assets(image="Assets/404.svg") dv.page_404() # IP if tools_choice == "IP": # IP API endpoint - http://api.cybercure.ai/feed/search?value= try: ip_input = st.text_input('Input IP Address',) # Create an instance of an ipdata object. Replace "config.ip_api_key" with your API Key ipdata = ipdata.IPData(ip_secret) ip_response = ipdata.lookup("{}".format(ip_input.lstrip())) # drawing IP locality map. Append Lat and Lon values to empty list geo_loc= [ip_response.get("latitude"),ip_response.get("longitude"),ip_response.get("country_name"),ip_response.get("city")] # verify from nested dictionary, to be included in "is_Threat" column in table is_threat = ip_response["threat"]["is_known_attacker"] # 0 = Harmless , 1= Harmful if is_threat == 0: geo_loc.append("No Threat Detected") else: geo_loc.append("Threat Detected") # draw table with column names and values ip_map = [geo_loc[0], geo_loc[1], geo_loc[2], geo_loc[3], geo_loc[4]] if len(ip_input) == 0: pass else:
#!/usr/bin/env python from ipdata import ipdata from pprint import pprint with open('../../secrets/geo.key') as key: key.readline().strip() ipdata = ipdata.IPData(key) ipinput = raw_input("Enter IP address: ") response = ipdata.lookup(ipinput)