mirror of
https://github.com/jayofelony/pwnagotchi.git
synced 2025-07-01 18:37:27 -04:00
Merge pull request #1027 from dbukovac/WigleUpdate
Enabled wigle to use .geo.json and .paw-gps.json files
This commit is contained in:
@ -20,8 +20,14 @@ def _extract_gps_data(path):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with open(path, 'r') as json_file:
|
if path.endswith('.geo.json'):
|
||||||
return json.load(json_file)
|
with open(path, 'r') as json_file:
|
||||||
|
tempJson = json.load(json_file)
|
||||||
|
d = datetime.utcfromtimestamp(int(tempJson["ts"]))
|
||||||
|
return {"Latitude": tempJson["location"]["lat"], "Longitude": tempJson["location"]["lng"], "Altitude": 10, "Updated": d.strftime('%Y-%m-%dT%H:%M:%S.%f')}
|
||||||
|
else:
|
||||||
|
with open(path, 'r') as json_file:
|
||||||
|
return json.load(json_file)
|
||||||
except OSError as os_err:
|
except OSError as os_err:
|
||||||
raise os_err
|
raise os_err
|
||||||
except json.JSONDecodeError as json_err:
|
except json.JSONDecodeError as json_err:
|
||||||
@ -79,7 +85,6 @@ def _send_to_wigle(lines, api_key, donate=True, timeout=30):
|
|||||||
'Accept': 'application/json'}
|
'Accept': 'application/json'}
|
||||||
data = {'donate': 'on' if donate else 'false'}
|
data = {'donate': 'on' if donate else 'false'}
|
||||||
payload = {'file': dummy, 'type': 'text/csv'}
|
payload = {'file': dummy, 'type': 'text/csv'}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
res = requests.post('https://api.wigle.net/api/v2/file/upload',
|
res = requests.post('https://api.wigle.net/api/v2/file/upload',
|
||||||
data=data,
|
data=data,
|
||||||
@ -117,6 +122,7 @@ class Wigle(plugins.Plugin):
|
|||||||
self.options['donate'] = True
|
self.options['donate'] = True
|
||||||
|
|
||||||
self.ready = True
|
self.ready = True
|
||||||
|
logging.info("WIGLE: ready")
|
||||||
|
|
||||||
def on_internet_available(self, agent):
|
def on_internet_available(self, agent):
|
||||||
"""
|
"""
|
||||||
@ -134,7 +140,7 @@ class Wigle(plugins.Plugin):
|
|||||||
all_files = os.listdir(handshake_dir)
|
all_files = os.listdir(handshake_dir)
|
||||||
all_gps_files = [os.path.join(handshake_dir, filename)
|
all_gps_files = [os.path.join(handshake_dir, filename)
|
||||||
for filename in all_files
|
for filename in all_files
|
||||||
if filename.endswith('.gps.json')]
|
if filename.endswith('.gps.json') or filename.endswith('.paw-gps.json') or filename.endswith('.geo.json')]
|
||||||
|
|
||||||
all_gps_files = remove_whitelisted(all_gps_files, self.options['whitelist'])
|
all_gps_files = remove_whitelisted(all_gps_files, self.options['whitelist'])
|
||||||
new_gps_files = set(all_gps_files) - set(reported) - set(self.skip)
|
new_gps_files = set(all_gps_files) - set(reported) - set(self.skip)
|
||||||
@ -143,7 +149,12 @@ class Wigle(plugins.Plugin):
|
|||||||
csv_entries = list()
|
csv_entries = list()
|
||||||
no_err_entries = list()
|
no_err_entries = list()
|
||||||
for gps_file in new_gps_files:
|
for gps_file in new_gps_files:
|
||||||
pcap_filename = gps_file.replace('.gps.json', '.pcap')
|
if gps_file.endswith('.gps.json'):
|
||||||
|
pcap_filename = gps_file.replace('.gps.json', '.pcap')
|
||||||
|
if gps_file.endswith('.paw-gps.json'):
|
||||||
|
pcap_filename = gps_file.replace('.paw-gps.json', '.pcap')
|
||||||
|
if gps_file.endswith('.geo.json'):
|
||||||
|
pcap_filename = gps_file.replace('.geo.json', '.pcap')
|
||||||
if not os.path.exists(pcap_filename):
|
if not os.path.exists(pcap_filename):
|
||||||
logging.debug("WIGLE: Can't find pcap for %s", gps_file)
|
logging.debug("WIGLE: Can't find pcap for %s", gps_file)
|
||||||
self.skip.append(gps_file)
|
self.skip.append(gps_file)
|
||||||
|
Reference in New Issue
Block a user