add password download

This commit is contained in:
dadav 2020-01-19 11:51:11 +01:00
parent 0764304be9
commit 37b25a142f
2 changed files with 36 additions and 0 deletions

View File

@ -36,6 +36,7 @@ main.plugins.webgpsmap.enabled = false
main.plugins.onlinehashcrack.enabled = false main.plugins.onlinehashcrack.enabled = false
main.plugins.onlinehashcrack.email = "" main.plugins.onlinehashcrack.email = ""
main.plugins.onlinehashcrack.dashboard = ""
main.plugins.wpa-sec.enabled = false main.plugins.wpa-sec.enabled = false
main.plugins.wpa-sec.api_key = "" main.plugins.wpa-sec.api_key = ""

View File

@ -2,6 +2,7 @@ import os
import logging import logging
import re import re
import requests import requests
from datetime import datetime
from threading import Lock from threading import Lock
from pwnagotchi.utils import StatusFile from pwnagotchi.utils import StatusFile
import pwnagotchi.plugins as plugins import pwnagotchi.plugins as plugins
@ -71,6 +72,24 @@ class OnlineHashCrack(plugins.Plugin):
logging.error(f"OHC: Got an exception while uploading {path} -> {e}") logging.error(f"OHC: Got an exception while uploading {path} -> {e}")
raise e raise e
def _download_cracked(self, save_file, timeout=120):
"""
Downloads the cracked passwords and saves them
returns the number of downloaded passwords
"""
try:
s = requests.Session()
dashboard = s.get(self.options['dashboard'], timeout=timeout)
result = s.get('https://www.onlinehashcrack.com/wpa-exportcsv', timeout=timeout)
result.raise_for_status()
with open(save_file, 'wt') as output_file:
output_file.write(result.content)
except requests.exceptions.RequestException as req_e:
raise req_e
except OSError as os_e:
raise os_e
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
@ -112,3 +131,19 @@ class OnlineHashCrack(plugins.Plugin):
self.skip.append(handshake) self.skip.append(handshake)
logging.error("OHC: %s", os_e) logging.error("OHC: %s", os_e)
continue continue
if 'dashboard' in self.options and self.options['dashboard']:
cracked_file = os.path.join(handshake_dir, 'onlinehashcrack.cracked')
if os.path.exists(cracked_file):
last_check = datetime.fromtimestamp(os.path.getmtime(cracked_file))
if last_check is not None and ((datetime.now() - last_check).seconds / (60 * 60)) < 1:
return
try:
self._download_cracked(cracked_file)
logging.info("OHC: Downloaded cracked passwords.")
except requests.exceptions.RequestException as req_e:
logging.debug("OHC: %s", req_e)
except OSError as os_e:
logging.debug("OHC: %s", os_e)