mirror of
https://github.com/jayofelony/pwnagotchi.git
synced 2025-07-01 18:37:27 -04:00
Version 2.3.4
Signed-off-by: Jeroen Oudshoorn <oudshoorn.jeroen@gmail.com> Signed-off-by: Jeroen Oudshoorn <oudshoorn.jeroen@gmail.com>
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
import json
|
||||
import logging
|
||||
import requests
|
||||
import websockets
|
||||
import backoff
|
||||
|
||||
from requests.auth import HTTPBasicAuth
|
||||
import asyncio # Add asyncio for async functionality
|
||||
@ -39,6 +39,7 @@ class Client(object):
|
||||
r = requests.get("%s/%s" % (self.url, sess), auth=self.auth)
|
||||
return decode(r)
|
||||
|
||||
@backoff.on_exception(backoff.expo, requests.exceptions.ConnectionError, max_tries=10)
|
||||
async def start_websocket(self, consumer):
|
||||
s = "%s/events" % self.websocket
|
||||
while True:
|
||||
@ -59,6 +60,7 @@ class Client(object):
|
||||
logging.exception("Other error while opening websocket (%s) with parameter %s", e, s)
|
||||
await asyncio.sleep(1) # Sleep for x seconds before reconnecting
|
||||
|
||||
@backoff.on_exception(backoff.expo, requests.exceptions.ConnectionError, max_tries=10)
|
||||
def run(self, command, verbose_errors=True):
|
||||
for _ in range(0, 2):
|
||||
try:
|
||||
|
@ -85,8 +85,5 @@ class Peer(object):
|
||||
def epoch(self):
|
||||
return self.adv.get('epoch', 0)
|
||||
|
||||
def full_name(self):
|
||||
return '%s@%s' % (self.name(), self.identity())
|
||||
|
||||
def is_closer(self, other):
|
||||
return self.rssi > other.rssi
|
||||
|
@ -1,4 +1,5 @@
|
||||
import _thread
|
||||
# import _thread
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
import logging
|
||||
import time
|
||||
|
||||
@ -41,7 +42,9 @@ class AsyncAdvertiser(object):
|
||||
|
||||
def start_advertising(self):
|
||||
if self._config['personality']['advertise']:
|
||||
_thread.start_new_thread(self._adv_poller, ())
|
||||
# _thread.start_new_thread(self._adv_poller, ())
|
||||
with ThreadPoolExecutor(max_workers=4) as executor:
|
||||
executor.submit(self._adv_poller)
|
||||
|
||||
grid.set_advertisement_data(self._advertisement)
|
||||
grid.advertise(True)
|
||||
|
@ -8,7 +8,7 @@ Profile
|
||||
{% block script %}
|
||||
$(function(){
|
||||
$('#qrcode').qrcode({
|
||||
text: 'https://pwnagotchi.ai/pwnfile/#{{ fingerprint }}',
|
||||
text: 'https://opwngrid.xyz/search/{{ fingerprint }}',
|
||||
render: 'div',
|
||||
mode: 0,
|
||||
size: 400,
|
||||
@ -25,7 +25,7 @@ $(function(){
|
||||
|
||||
<label for="fingerprint">Fingerprint</label>
|
||||
<h4 id="fingerprint">
|
||||
<a href="https://pwnagotchi.ai/pwnfile/#{{ fingerprint }}" target="_blank">{{ fingerprint }}</a>
|
||||
<a href="https://opwngrid.xyz/search/{{ fingerprint }}" target="_blank">{{ fingerprint }}</a>
|
||||
</h4>
|
||||
<div id="qrcode"></div>
|
||||
|
||||
|
@ -60,7 +60,7 @@ class DottedTomlEncoder(TomlEncoder):
|
||||
else:
|
||||
retstr += (pre + qsection + " = " +
|
||||
str(self.dump_value(value)) + '\n')
|
||||
return (retstr, self._dict())
|
||||
return retstr, self._dict()
|
||||
|
||||
|
||||
def parse_version(version):
|
||||
@ -75,6 +75,7 @@ def remove_whitelisted(list_of_handshakes, list_of_whitelisted_strings, valid_on
|
||||
Removes a given list of whitelisted handshakes from a path list
|
||||
"""
|
||||
filtered = list()
|
||||
|
||||
def normalize(name):
|
||||
"""
|
||||
Only allow alpha/nums
|
||||
@ -96,7 +97,6 @@ def remove_whitelisted(list_of_handshakes, list_of_whitelisted_strings, valid_on
|
||||
return filtered
|
||||
|
||||
|
||||
|
||||
def download_file(url, destination, chunk_size=128):
|
||||
import requests
|
||||
resp = requests.get(url)
|
||||
@ -106,6 +106,7 @@ def download_file(url, destination, chunk_size=128):
|
||||
for chunk in resp.iter_content(chunk_size):
|
||||
fd.write(chunk)
|
||||
|
||||
|
||||
def unzip(file, destination, strip_dirs=0):
|
||||
os.makedirs(destination, exist_ok=True)
|
||||
with ZipFile(file, 'r') as zip:
|
||||
@ -129,6 +130,7 @@ def merge_config(user, default):
|
||||
user[k] = merge_config(user[k], v)
|
||||
return user
|
||||
|
||||
|
||||
def keys_to_str(data):
|
||||
if isinstance(data,list):
|
||||
converted_list = list()
|
||||
@ -148,11 +150,13 @@ def keys_to_str(data):
|
||||
|
||||
return converted_dict
|
||||
|
||||
|
||||
def save_config(config, target):
|
||||
with open(target, 'wt') as fp:
|
||||
fp.write(toml.dumps(config, encoder=DottedTomlEncoder()))
|
||||
return True
|
||||
|
||||
|
||||
def load_config(args):
|
||||
default_config_path = os.path.dirname(args.config)
|
||||
if not os.path.exists(default_config_path):
|
||||
@ -232,14 +236,14 @@ def load_config(args):
|
||||
additional_config = toml.load(toml_file)
|
||||
config = merge_config(additional_config, config)
|
||||
|
||||
# the very first step is to normalize the display name so we don't need dozens of if/elif around
|
||||
# the very first step is to normalize the display name, so we don't need dozens of if/elif around
|
||||
if config['ui']['display']['type'] in ('inky', 'inkyphat'):
|
||||
config['ui']['display']['type'] = 'inky'
|
||||
|
||||
elif config['ui']['display']['type'] in ('papirus', 'papi'):
|
||||
config['ui']['display']['type'] = 'papirus'
|
||||
|
||||
elif config['ui']['display']['type'] in ('oledhat',):
|
||||
elif config['ui']['display']['type'] in 'oledhat':
|
||||
config['ui']['display']['type'] = 'oledhat'
|
||||
|
||||
elif config['ui']['display']['type'] in ('ws_1', 'ws1', 'waveshare_1', 'waveshare1'):
|
||||
@ -257,7 +261,7 @@ def load_config(args):
|
||||
elif config['ui']['display']['type'] in ('ws_29inch', 'ws29inch', 'waveshare_29inch', 'waveshare29inch'):
|
||||
config['ui']['display']['type'] = 'waveshare29inch'
|
||||
|
||||
elif config['ui']['display']['type'] in ('lcdhat',):
|
||||
elif config['ui']['display']['type'] in 'lcdhat':
|
||||
config['ui']['display']['type'] = 'lcdhat'
|
||||
|
||||
elif config['ui']['display']['type'] in ('dfrobot_1', 'df1'):
|
||||
@ -281,13 +285,13 @@ def load_config(args):
|
||||
elif config['ui']['display']['type'] in ('ws_213bv4', 'ws213bv4', 'waveshare_213bv4', 'waveshare213inb_v4'):
|
||||
config['ui']['display']['type'] = 'waveshare213inb_v4'
|
||||
|
||||
elif config['ui']['display']['type'] in ('spotpear24inch'):
|
||||
elif config['ui']['display']['type'] in 'spotpear24inch':
|
||||
config['ui']['display']['type'] = 'spotpear24inch'
|
||||
|
||||
elif config['ui']['display']['type'] in ('displayhatmini'):
|
||||
elif config['ui']['display']['type'] in 'displayhatmini':
|
||||
config['ui']['display']['type'] = 'displayhatmini'
|
||||
|
||||
elif config['ui']['display']['type'] in ('waveshare35lcd'):
|
||||
elif config['ui']['display']['type'] in 'waveshare35lcd':
|
||||
config['ui']['display']['type'] = 'waveshare35lcd'
|
||||
|
||||
else:
|
||||
@ -441,6 +445,7 @@ def extract_from_pcap(path, fields):
|
||||
|
||||
return results
|
||||
|
||||
|
||||
class StatusFile(object):
|
||||
def __init__(self, path, data_format='raw'):
|
||||
self._path = path
|
||||
|
@ -22,3 +22,4 @@ torch
|
||||
torchvision
|
||||
stable_baselines3
|
||||
RPi.GPIO
|
||||
backoff
|
||||
|
Reference in New Issue
Block a user