Merge pull request #471 from neutralinsomniac/ohc_whitelist
Add whitelist support to onlinehashcrack plugin
This commit is contained in:
commit
04e551600d
@ -1,5 +1,6 @@
|
|||||||
import os
|
import os
|
||||||
import logging
|
import logging
|
||||||
|
import re
|
||||||
import requests
|
import requests
|
||||||
from pwnagotchi.utils import StatusFile
|
from pwnagotchi.utils import StatusFile
|
||||||
import pwnagotchi.plugins as plugins
|
import pwnagotchi.plugins as plugins
|
||||||
@ -24,8 +25,26 @@ class OnlineHashCrack(plugins.Plugin):
|
|||||||
logging.error("OHC: Email isn't set. Can't upload to onlinehashcrack.com")
|
logging.error("OHC: Email isn't set. Can't upload to onlinehashcrack.com")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if 'whitelist' not in self.options:
|
||||||
|
self.options['whitelist'] = []
|
||||||
|
|
||||||
|
# remove special characters from whitelist APs to match on-disk format
|
||||||
|
self.options['whitelist'] = set(map(lambda x: re.sub(r'[^a-zA-Z0-9]', '', x), self.options['whitelist']))
|
||||||
|
|
||||||
self.ready = True
|
self.ready = True
|
||||||
|
|
||||||
|
def _filter_handshake_file(self, handshake_filename):
|
||||||
|
try:
|
||||||
|
basename = os.path.basename(handshake_filename)
|
||||||
|
ssid, bssid = basename.split('_')
|
||||||
|
# remove the ".pcap" from the bssid (which is really just the end of the filename)
|
||||||
|
bssid = bssid[:-5]
|
||||||
|
except:
|
||||||
|
# something failed in our parsing of the filename. let the file through
|
||||||
|
return True
|
||||||
|
|
||||||
|
return ssid not in self.options['whitelist'] and bssid not in self.options['whitelist']
|
||||||
|
|
||||||
def _upload_to_ohc(self, path, timeout=30):
|
def _upload_to_ohc(self, path, timeout=30):
|
||||||
"""
|
"""
|
||||||
Uploads the file to onlinehashcrack.com
|
Uploads the file to onlinehashcrack.com
|
||||||
@ -58,6 +77,10 @@ class OnlineHashCrack(plugins.Plugin):
|
|||||||
handshake_filenames = os.listdir(handshake_dir)
|
handshake_filenames = os.listdir(handshake_dir)
|
||||||
handshake_paths = [os.path.join(handshake_dir, filename) for filename in handshake_filenames if
|
handshake_paths = [os.path.join(handshake_dir, filename) for filename in handshake_filenames if
|
||||||
filename.endswith('.pcap')]
|
filename.endswith('.pcap')]
|
||||||
|
|
||||||
|
# pull out whitelisted APs
|
||||||
|
handshake_paths = filter(lambda path: self._filter_handshake_file(path), handshake_paths)
|
||||||
|
|
||||||
handshake_new = set(handshake_paths) - set(reported) - set(self.skip)
|
handshake_new = set(handshake_paths) - set(reported) - set(self.skip)
|
||||||
|
|
||||||
if handshake_new:
|
if handshake_new:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user