From b3bdb34e3f71b4b99fc666601a8d10d19f060235 Mon Sep 17 00:00:00 2001
From: Jacopo Tediosi <jacopotediosi@gmail.com>
Date: Mon, 17 Feb 2020 10:55:35 +0100
Subject: [PATCH 1/2] Onlinehashcrack should create .pcap.cracked files

---
 pwnagotchi/plugins/default/onlinehashcrack.py | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/pwnagotchi/plugins/default/onlinehashcrack.py b/pwnagotchi/plugins/default/onlinehashcrack.py
index 82a82bf..01c391a 100644
--- a/pwnagotchi/plugins/default/onlinehashcrack.py
+++ b/pwnagotchi/plugins/default/onlinehashcrack.py
@@ -1,4 +1,5 @@
 import os
+import csv
 import logging
 import re
 import requests
@@ -148,3 +149,11 @@ class OnlineHashCrack(plugins.Plugin):
                     except OSError as os_e:
                         logging.debug("OHC: %s", os_e)
 
+                    if 'single_files' in self.options and self.options['single_files']:
+                        with open(cracked_file, 'r') as cracked_list:
+                            for row in csv.DictReader(cracked_list):
+                                if row['password']:
+                                    filename = row['ESSID'].replace('-','').replace(' ','') + '_' + row['BSSID'].replace(':','')
+                                    if os.path.exists( os.path.join(handshake_dir, filename+'.pcap') ):
+                                        with open(os.path.join(handshake_dir, filename+'.pcap.cracked'), 'w') as f:
+                                            f.write(row['password'])

From 0e1a1f4c7923f7e4f8dd9c23ffdecaaaa5336630 Mon Sep 17 00:00:00 2001
From: Jacopo Tediosi <jacopotediosi@gmail.com>
Date: Mon, 17 Feb 2020 12:15:26 +0100
Subject: [PATCH 2/2] Changed filename generation to a regex

---
 pwnagotchi/plugins/default/onlinehashcrack.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pwnagotchi/plugins/default/onlinehashcrack.py b/pwnagotchi/plugins/default/onlinehashcrack.py
index 01c391a..683e27a 100644
--- a/pwnagotchi/plugins/default/onlinehashcrack.py
+++ b/pwnagotchi/plugins/default/onlinehashcrack.py
@@ -153,7 +153,7 @@ class OnlineHashCrack(plugins.Plugin):
                         with open(cracked_file, 'r') as cracked_list:
                             for row in csv.DictReader(cracked_list):
                                 if row['password']:
-                                    filename = row['ESSID'].replace('-','').replace(' ','') + '_' + row['BSSID'].replace(':','')
+                                    filename = re.sub(r'[^a-zA-Z0-9]', '', row['ESSID']) + '_' + row['BSSID'].replace(':','')
                                     if os.path.exists( os.path.join(handshake_dir, filename+'.pcap') ):
                                         with open(os.path.join(handshake_dir, filename+'.pcap.cracked'), 'w') as f:
                                             f.write(row['password'])