mirror of
https://github.com/jayofelony/pwnagotchi.git
synced 2025-07-01 18:37:27 -04:00
Small update to the build
Signed-off-by: Jeroen Oudshoorn <oudshoorn.jeroen@gmail.com>
This commit is contained in:
@ -14,6 +14,7 @@ class Example(plugins.Plugin):
|
|||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
logging.debug("example plugin created")
|
logging.debug("example plugin created")
|
||||||
|
self.options = dict()
|
||||||
|
|
||||||
# called when http://<host>:<port>/plugins/<plugin>/ is called
|
# called when http://<host>:<port>/plugins/<plugin>/ is called
|
||||||
# must return a html page
|
# must return a html page
|
||||||
@ -23,13 +24,13 @@ class Example(plugins.Plugin):
|
|||||||
|
|
||||||
# called when the plugin is loaded
|
# called when the plugin is loaded
|
||||||
def on_loaded(self):
|
def on_loaded(self):
|
||||||
logging.warning("WARNING: this plugin should be disabled! options = " % self.options)
|
logging.warning("WARNING: this plugin should be disabled! options = %s" % self.options)
|
||||||
|
|
||||||
# called before the plugin is unloaded
|
# called before the plugin is unloaded
|
||||||
def on_unload(self, ui):
|
def on_unload(self, ui):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# called hen there's internet connectivity
|
# called when there's internet connectivity
|
||||||
def on_internet_available(self, agent):
|
def on_internet_available(self, agent):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -58,7 +59,7 @@ class Example(plugins.Plugin):
|
|||||||
# or set a custom state
|
# or set a custom state
|
||||||
# agent.set_bored()
|
# agent.set_bored()
|
||||||
|
|
||||||
# called when a non overlapping wifi channel is found to be free
|
# called when a non overlapping Wi-Fi channel is found to be free
|
||||||
def on_free_channel(self, agent, channel):
|
def on_free_channel(self, agent, channel):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -103,7 +104,7 @@ class Example(plugins.Plugin):
|
|||||||
def on_association(self, agent, access_point):
|
def on_association(self, agent, access_point):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# called when the agent is deauthenticating a client station from an AP
|
# called when the agent is de-authenticating a client station from an AP
|
||||||
def on_deauthentication(self, agent, access_point, client_station):
|
def on_deauthentication(self, agent, access_point, client_station):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -112,7 +113,7 @@ class Example(plugins.Plugin):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
# called when a new handshake is captured, access_point and client_station are json objects
|
# called when a new handshake is captured, access_point and client_station are json objects
|
||||||
# if the agent could match the BSSIDs to the current list, otherwise they are just the strings of the BSSIDs
|
# if the agent could match the BSSID's to the current list, otherwise they are just the strings of the BSSIDs
|
||||||
def on_handshake(self, agent, filename, access_point, client_station):
|
def on_handshake(self, agent, filename, access_point, client_station):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import os
|
import os
|
||||||
import logging
|
import logging
|
||||||
import requests
|
import requests
|
||||||
|
import subprocess
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from threading import Lock
|
from threading import Lock
|
||||||
from pwnagotchi.utils import StatusFile, remove_whitelisted
|
from pwnagotchi.utils import StatusFile, remove_whitelisted
|
||||||
@ -22,10 +23,10 @@ class WpaSec(plugins.Plugin):
|
|||||||
self.ready = False
|
self.ready = False
|
||||||
self.lock = Lock()
|
self.lock = Lock()
|
||||||
try:
|
try:
|
||||||
self.report = StatusFile('/root/.wpa_sec_uploads', data_format='json')
|
self.report = StatusFile('/home/pi/.wpa_sec_uploads', data_format='json')
|
||||||
except JSONDecodeError:
|
except JSONDecodeError:
|
||||||
os.remove("/root/.wpa_sec_uploads")
|
os.remove("/home/pi/.wpa_sec_uploads")
|
||||||
self.report = StatusFile('/root/.wpa_sec_uploads', data_format='json')
|
self.report = StatusFile('/home/pi/.wpa_sec_uploads', data_format='json')
|
||||||
self.options = dict()
|
self.options = dict()
|
||||||
self.skip = list()
|
self.skip = list()
|
||||||
|
|
||||||
@ -42,14 +43,20 @@ class WpaSec(plugins.Plugin):
|
|||||||
cookies=cookie,
|
cookies=cookie,
|
||||||
files=payload,
|
files=payload,
|
||||||
timeout=timeout)
|
timeout=timeout)
|
||||||
|
if result.status_code == 200:
|
||||||
if 'already submitted' in result.text:
|
if 'already submitted' in result.text:
|
||||||
logging.debug("%s was already submitted.", path)
|
logging.debug("%s was already submitted.", path)
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
elif result.status_code != 200:
|
||||||
|
logging.error("WPA_SEC: Error code: %s", result.text)
|
||||||
|
return False
|
||||||
except requests.exceptions.RequestException as req_e:
|
except requests.exceptions.RequestException as req_e:
|
||||||
raise req_e
|
raise req_e
|
||||||
|
|
||||||
def _download_from_wpasec(self, output, timeout=30):
|
def _download_from_wpasec(self, output, timeout=30):
|
||||||
"""
|
"""
|
||||||
Downloads the results from wpasec and safes them to output
|
Downloads the results from wpasec and saves them to output
|
||||||
|
|
||||||
Output-Format: bssid, station_mac, ssid, password
|
Output-Format: bssid, station_mac, ssid, password
|
||||||
"""
|
"""
|
||||||
@ -110,9 +117,8 @@ class WpaSec(plugins.Plugin):
|
|||||||
logging.info("WPA_SEC: Internet connectivity detected. Uploading new handshakes to wpa-sec.stanev.org")
|
logging.info("WPA_SEC: Internet connectivity detected. Uploading new handshakes to wpa-sec.stanev.org")
|
||||||
for idx, handshake in enumerate(handshake_new):
|
for idx, handshake in enumerate(handshake_new):
|
||||||
display.on_uploading(f"wpa-sec.stanev.org ({idx + 1}/{len(handshake_new)})")
|
display.on_uploading(f"wpa-sec.stanev.org ({idx + 1}/{len(handshake_new)})")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self._upload_to_wpasec(handshake)
|
if self._upload_to_wpasec(handshake):
|
||||||
reported.append(handshake)
|
reported.append(handshake)
|
||||||
self.report.update(data={'reported': reported})
|
self.report.update(data={'reported': reported})
|
||||||
logging.debug("WPA_SEC: Successfully uploaded %s", handshake)
|
logging.debug("WPA_SEC: Successfully uploaded %s", handshake)
|
||||||
@ -123,7 +129,6 @@ class WpaSec(plugins.Plugin):
|
|||||||
except OSError as os_e:
|
except OSError as os_e:
|
||||||
logging.debug("WPA_SEC: %s", os_e)
|
logging.debug("WPA_SEC: %s", os_e)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
display.on_normal()
|
display.on_normal()
|
||||||
|
|
||||||
if 'download_results' in self.options and self.options['download_results']:
|
if 'download_results' in self.options and self.options['download_results']:
|
||||||
@ -156,6 +161,22 @@ class WpaSec(plugins.Plugin):
|
|||||||
|
|
||||||
def on_ui_update(self, ui):
|
def on_ui_update(self, ui):
|
||||||
if 'show_pwd' in self.options and self.options['show_pwd'] and 'download_results' in self.options and self.options['download_results']:
|
if 'show_pwd' in self.options and self.options['show_pwd'] and 'download_results' in self.options and self.options['download_results']:
|
||||||
last_line = os.popen('awk -F: \'!seen[$3]++ {print $3 " - " $4}\' /root/handshakes/wpa-sec.cracked.potfile | tail -n 1')
|
file_path = '/home/pi/handshakes/wpa-sec.cracked.potfile'
|
||||||
last_line = last_line.read().rstrip()
|
try:
|
||||||
ui.set('pass', last_line)
|
with open(file_path, 'r') as file:
|
||||||
|
# Read all lines and extract the required fields
|
||||||
|
lines = file.readlines()
|
||||||
|
if lines: # Check if file is not empty
|
||||||
|
last_line = lines[-1]
|
||||||
|
parts = last_line.split(':') # Split line into fields using ':' as a delimiter
|
||||||
|
if len(parts) >= 4:
|
||||||
|
result = f"{parts[2]} - {parts[3].strip()}"
|
||||||
|
else:
|
||||||
|
result = "Malformed line format"
|
||||||
|
else:
|
||||||
|
result = "File is empty"
|
||||||
|
except FileNotFoundError:
|
||||||
|
result = "File not found"
|
||||||
|
except OSError as e:
|
||||||
|
result = f"Error reading file: {e}"
|
||||||
|
ui.set('pass', result)
|
Reference in New Issue
Block a user