Merge pull request from dadav/feature/ohc_download

add password download from onlinehashcrack
This commit is contained in:
Simone Margaritelli 2020-01-19 14:46:24 +01:00 committed by GitHub
commit 7e80a7b9ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 36 additions and 0 deletions
pwnagotchi

@ -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 = ""

@ -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
@ -72,6 +73,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
@ -113,3 +132,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)