From 09a82aa0b4b2b7046cbfc5e75a475f0e360ec40a Mon Sep 17 00:00:00 2001 From: jayofelony Date: Wed, 13 Mar 2024 07:59:37 +0100 Subject: [PATCH] revert pcapng Signed-off-by: jayofelony --- pwnagotchi/plugins/default/gps.py | 2 +- pwnagotchi/plugins/default/grid.py | 16 ++++++++-------- pwnagotchi/plugins/default/net-pos.py | 2 +- pwnagotchi/plugins/default/onlinehashcrack.py | 4 ++-- pwnagotchi/plugins/default/webgpsmap.py | 10 +++++----- pwnagotchi/plugins/default/wigle.py | 10 +++++----- pwnagotchi/plugins/default/wpa-sec.py | 2 +- pwnagotchi/utils.py | 10 +++++----- 8 files changed, 28 insertions(+), 28 deletions(-) diff --git a/pwnagotchi/plugins/default/gps.py b/pwnagotchi/plugins/default/gps.py index 7bf72f8e..2f955c6a 100644 --- a/pwnagotchi/plugins/default/gps.py +++ b/pwnagotchi/plugins/default/gps.py @@ -48,7 +48,7 @@ class GPS(plugins.Plugin): if self.running: info = agent.session() self.coordinates = info["gps"] - gps_filename = filename.replace(".pcapng", ".gps.json") + gps_filename = filename.replace(".pcap", ".gps.json") if self.coordinates and all([ # avoid 0.000... measurements diff --git a/pwnagotchi/plugins/default/grid.py b/pwnagotchi/plugins/default/grid.py index fbc3374e..a2a35357 100644 --- a/pwnagotchi/plugins/default/grid.py +++ b/pwnagotchi/plugins/default/grid.py @@ -6,20 +6,20 @@ import re import pwnagotchi.grid as grid import pwnagotchi.plugins as plugins -from pwnagotchi.utils import StatusFile, WifiInfo, extract_from_pcapng +from pwnagotchi.utils import StatusFile, WifiInfo, extract_from_pcap from threading import Lock def parse_pcap(filename): logging.info("grid: parsing %s ..." % filename) - net_id = os.path.basename(filename).replace('.pcapng', '') + net_id = os.path.basename(filename).replace('.pcap', '') if '_' in net_id: - # /root/handshakes/ESSID_BSSID.pcapng + # /root/handshakes/ESSID_BSSID.pcap essid, bssid = net_id.split('_') else: - # /root/handshakes/BSSID.pcapng + # /root/handshakes/BSSID.pcap essid, bssid = '', net_id mac_re = re.compile('[0-9a-fA-F]{12}') @@ -35,7 +35,7 @@ def parse_pcap(filename): } try: - info = extract_from_pcapng(filename, [WifiInfo.BSSID, WifiInfo.ESSID]) + info = extract_from_pcap(filename, [WifiInfo.BSSID, WifiInfo.ESSID]) except Exception as e: logging.error("grid: %s" % e) @@ -86,10 +86,10 @@ class Grid(plugins.Plugin): agent.view().on_unread_messages(self.unread_messages, self.total_messages) def check_handshakes(self, agent): - logging.debug("checking pcapng's") + logging.debug("checking pcap's") config = agent.config() - pcap_files = glob.glob(os.path.join(agent.config()['bettercap']['handshakes'], "*.pcapng")) + pcap_files = glob.glob(os.path.join(agent.config()['bettercap']['handshakes'], "*.pcap")) num_networks = len(pcap_files) reported = self.report.data_field_or('reported', default=[]) num_reported = len(reported) @@ -102,7 +102,7 @@ class Grid(plugins.Plugin): logging.debug(" exclude: %s" % config['main']['whitelist']) for pcap_file in pcap_files: - net_id = os.path.basename(pcap_file).replace('.pcapng', '') + net_id = os.path.basename(pcap_file).replace('.pcap', '') if net_id not in reported: if self.is_excluded(net_id, agent): logging.debug("skipping %s due to exclusion filter" % pcap_file) diff --git a/pwnagotchi/plugins/default/net-pos.py b/pwnagotchi/plugins/default/net-pos.py index ef5f0c59..3f226204 100644 --- a/pwnagotchi/plugins/default/net-pos.py +++ b/pwnagotchi/plugins/default/net-pos.py @@ -108,7 +108,7 @@ class NetPos(plugins.Plugin): return netpos["ts"] = int("%.0f" % time.time()) - netpos_filename = filename.replace('.pcapng', '.net-pos.json') + netpos_filename = filename.replace('.pcap', '.net-pos.json') logging.debug("NET-POS: Saving net-location to %s", netpos_filename) try: diff --git a/pwnagotchi/plugins/default/onlinehashcrack.py b/pwnagotchi/plugins/default/onlinehashcrack.py index 1eafb9fa..7a7e870c 100644 --- a/pwnagotchi/plugins/default/onlinehashcrack.py +++ b/pwnagotchi/plugins/default/onlinehashcrack.py @@ -142,6 +142,6 @@ class OnlineHashCrack(plugins.Plugin): for row in csv.DictReader(cracked_list): if row['password']: filename = re.sub(r'[^a-zA-Z0-9]', '', row['ESSID']) + '_' + row['BSSID'].replace(':','') - if os.path.exists( os.path.join(handshake_dir, filename+'.pcapng')): - with open(os.path.join(handshake_dir, filename+'.pcapng.cracked'), 'w') as f: + 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']) diff --git a/pwnagotchi/plugins/default/webgpsmap.py b/pwnagotchi/plugins/default/webgpsmap.py index b03fef50..dc0f4f85 100644 --- a/pwnagotchi/plugins/default/webgpsmap.py +++ b/pwnagotchi/plugins/default/webgpsmap.py @@ -13,8 +13,8 @@ from dateutil.parser import parse webgpsmap shows existing position data stored in your /handshakes/ directory the plugin does the following: - - search for *.pcapng files in your /handshakes/ dir - - for every found .pcapng file it looks for a .geo.json or .gps.json or file with + - search for *.pcap files in your /handshakes/ dir + - for every found .pcap file it looks for a .geo.json or .gps.json or file with latitude+longitude data inside and shows this position on the map - if also an .cracked file with a plaintext password inside exist, it reads the content and shows the position as green instead of red and the password inside the infopox of the position @@ -166,7 +166,7 @@ class Webgpsmap(plugins.Plugin): all_files = os.listdir(handshake_dir) # print(all_files) all_pcap_files = [os.path.join(handshake_dir, filename) for filename in all_files if - filename.endswith('.pcapng')] + filename.endswith('.pcap')] all_geo_or_gps_files = [] for filename_pcap in all_pcap_files: filename_base = filename_pcap[:-5] # remove ".pcap" @@ -224,7 +224,7 @@ class Webgpsmap(plugins.Plugin): } # get ap password if exist - check_for = os.path.basename(pos_file).split(".")[0] + ".pcapng.cracked" + check_for = os.path.basename(pos_file).split(".")[0] + ".pcap.cracked" if check_for in all_files: gps_data[ssid + "_" + mac]["pass"] = pos.password() @@ -329,7 +329,7 @@ class PositionFile: return_pass = None # 2do: make better filename split/remove extension because this one has problems with "." in path base_filename, ext1, ext2 = re.split('\.', self._file) - password_file_path = base_filename + ".pcapng.cracked" + password_file_path = base_filename + ".pcap.cracked" if os.path.isfile(password_file_path): try: password_file = open(password_file_path, 'r') diff --git a/pwnagotchi/plugins/default/wigle.py b/pwnagotchi/plugins/default/wigle.py index 11805c3b..353660ea 100644 --- a/pwnagotchi/plugins/default/wigle.py +++ b/pwnagotchi/plugins/default/wigle.py @@ -7,7 +7,7 @@ import pwnagotchi from io import StringIO from datetime import datetime -from pwnagotchi.utils import WifiInfo, FieldNotFoundError, extract_from_pcapng, StatusFile, remove_whitelisted +from pwnagotchi.utils import WifiInfo, FieldNotFoundError, extract_from_pcap, StatusFile, remove_whitelisted from threading import Lock from pwnagotchi import plugins from pwnagotchi._version import __version__ as __pwnagotchi_version__ @@ -153,11 +153,11 @@ class Wigle(plugins.Plugin): no_err_entries = list() for gps_file in new_gps_files: if gps_file.endswith('.gps.json'): - pcap_filename = gps_file.replace('.gps.json', '.pcapng') + pcap_filename = gps_file.replace('.gps.json', '.pcap') if gps_file.endswith('.geo.json'): - pcap_filename = gps_file.replace('.geo.json', '.pcapng') + pcap_filename = gps_file.replace('.geo.json', '.pcap') if not os.path.exists(pcap_filename): - logging.debug("WIGLE: Can't find pcapng for %s", gps_file) + logging.debug("WIGLE: Can't find pcap for %s", gps_file) self.skip.append(gps_file) continue try: @@ -175,7 +175,7 @@ class Wigle(plugins.Plugin): self.skip.append(gps_file) continue try: - pcap_data = extract_from_pcapng(pcap_filename, [WifiInfo.BSSID, + pcap_data = extract_from_pcap(pcap_filename, [WifiInfo.BSSID, WifiInfo.ESSID, WifiInfo.ENCRYPTION, WifiInfo.CHANNEL, diff --git a/pwnagotchi/plugins/default/wpa-sec.py b/pwnagotchi/plugins/default/wpa-sec.py index 42f1c29f..696b53b4 100644 --- a/pwnagotchi/plugins/default/wpa-sec.py +++ b/pwnagotchi/plugins/default/wpa-sec.py @@ -98,7 +98,7 @@ class WpaSec(plugins.Plugin): reported = self.report.data_field_or('reported', default=list()) handshake_dir = config['bettercap']['handshakes'] handshake_filenames = os.listdir(handshake_dir) - handshake_paths = [os.path.join(handshake_dir, filename) for filename in handshake_filenames if filename.endswith('.pcapng')] + handshake_paths = [os.path.join(handshake_dir, filename) for filename in handshake_filenames if filename.endswith('.pcap')] handshake_paths = remove_whitelisted(handshake_paths, config['main']['whitelist']) handshake_new = set(handshake_paths) - set(reported) - set(self.skip) diff --git a/pwnagotchi/utils.py b/pwnagotchi/utils.py index 72f2831c..a123b7d0 100644 --- a/pwnagotchi/utils.py +++ b/pwnagotchi/utils.py @@ -82,7 +82,7 @@ def remove_whitelisted(list_of_handshakes, list_of_whitelisted_strings, valid_on for handshake in list_of_handshakes: try: - normalized_handshake = normalize(os.path.basename(handshake).rstrip('.pcapng')) + normalized_handshake = normalize(os.path.basename(handshake).rstrip('.pcap')) for whitelist in list_of_whitelisted_strings: normalized_whitelist = normalize(whitelist) if normalized_whitelist in normalized_handshake: @@ -448,7 +448,7 @@ def secs_to_hhmmss(secs): def total_unique_handshakes(path): - expr = os.path.join(path, "*.pcapng") + expr = os.path.join(path, "*.pcap") return len(glob.glob(expr)) @@ -506,11 +506,11 @@ def md5(fname): return hash_md5.hexdigest() -def extract_from_pcapng(path, fields): +def extract_from_pcap(path, fields): """ - Search in pcapng-file for specified information + Search in pcap-file for specified information - path: Path to pcapng file + path: Path to pcap file fields: Array of fields that should be extracted If a field is not found, FieldNotFoundError is raised