mirror of
https://github.com/jayofelony/pwnagotchi.git
synced 2025-07-01 18:37:27 -04:00
enabled wigle to use .geo.json and .paw-gps.json files
This commit is contained in:
@ -20,6 +20,12 @@ def _extract_gps_data(path):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
if path.endswith('.geo.json'):
|
||||||
|
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:
|
with open(path, 'r') as json_file:
|
||||||
return json.load(json_file)
|
return json.load(json_file)
|
||||||
except OSError as os_err:
|
except OSError as os_err:
|
||||||
@ -68,6 +74,8 @@ def _send_to_wigle(lines, api_key, donate=True, timeout=30):
|
|||||||
Uploads the file to wigle-net
|
Uploads the file to wigle-net
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
logging.info(lines)
|
||||||
|
|
||||||
dummy = StringIO()
|
dummy = StringIO()
|
||||||
|
|
||||||
for line in lines:
|
for line in lines:
|
||||||
@ -79,7 +87,7 @@ 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'}
|
||||||
|
logging.info(dummy.getvalue())
|
||||||
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,12 +125,14 @@ 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):
|
||||||
"""
|
"""
|
||||||
Called in manual mode when there's internet connectivity
|
Called in manual mode when there's internet connectivity
|
||||||
"""
|
"""
|
||||||
if not self.ready or self.lock.locked():
|
if not self.ready or self.lock.locked():
|
||||||
|
logging.info("WIGLE: error with api key")
|
||||||
return
|
return
|
||||||
|
|
||||||
from scapy.all import Scapy_Exception
|
from scapy.all import Scapy_Exception
|
||||||
@ -134,7 +144,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 +153,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:
|
||||||
|
if gps_file.endswith('.gps.json'):
|
||||||
pcap_filename = gps_file.replace('.gps.json', '.pcap')
|
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