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