Last active
August 29, 2015 14:12
-
-
Save pronto/b88b36ec3bf2a9442fe6 to your computer and use it in GitHub Desktop.
python ipviking collector
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
#the websocket IP is found in the javascript of the map(if it ever changes) | |
import asyncio , websockets , json, time , asyncio ,os | |
@asyncio.coroutine | |
def hello(): | |
websocket = yield from websockets.connect('ws://64.19.78.244:443/') | |
while True: | |
greeting = yield from websocket.recv() | |
try: | |
j_v=json.loads(greeting) | |
except: | |
#sometimes something comes though that breaks things; not sure why :( | |
print("< {}".format(greeting)) | |
sys.exit(1) | |
#print(json_viking) | |
print(j_v) | |
print("IP: "+ j_v['md5']+"\t "+ j_v['city2'] +","+j_v['country2']+"\t"+j_v['svc']+"\t"+j_v['org']) | |
if __name__ == '__main__': | |
asyncio.get_event_loop().run_until_complete(hello()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
example of the raw json | |
{ | |
'latitude': '55.75', | |
'md5': '94.228.205.15', | |
'dport': '64398', | |
'longitude': '37.62', | |
'countrycode2': 'US', | |
'zerg': '', | |
'country2': 'US', | |
'type': 'ipviking.honey', | |
'city2': 'Saint Louis', | |
'country': 'RU', | |
'countrycode': 'RU', | |
'city': 'Moscow', | |
'latitude2': '38.62', | |
'svc': '64398', | |
'longitude2': '-90.35', | |
'org': 'Uniontel ZAO' | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment