From e4d9715d995c375cdc107d8bc5dbeb381742cc77 Mon Sep 17 00:00:00 2001 From: Marshall Hallenbeck Date: Tue, 29 Jul 2025 11:40:30 -0400 Subject: [PATCH 01/29] feat(kerberoasting): allow for specifying specific users to kerberoast --- nxc/protocols/ldap.py | 20 ++++++++++++++++++-- nxc/protocols/ldap/proto_args.py | 1 + 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/nxc/protocols/ldap.py b/nxc/protocols/ldap.py index 57eb92fa52..f4e3cc0ca6 100644 --- a/nxc/protocols/ldap.py +++ b/nxc/protocols/ldap.py @@ -1031,8 +1031,24 @@ def kerberoasting(self): f.write(line + "\n") return - # Building the search filter - searchFilter = "(&(servicePrincipalName=*)(!(objectCategory=computer)))" + if self.args.kerberoast_users: + target_usernames = [] + for item in self.args.kerberoast_users: + if os.path.isfile(item): + with open(item, encoding="utf-8") as f: + target_usernames.extend(line.strip() for line in f if line.strip()) + else: + target_usernames.append(item.strip()) + + self.logger.info(f"Targeting specific users for kerberoasting: {', '.join(target_usernames)}") + + # build search filter for specific users + user_filter = "".join([f"(sAMAccountName={username})" for username in target_usernames]) + searchFilter = f"(&(servicePrincipalName=*)(!(objectCategory=computer))(|{user_filter}))" + else: + # default to all + searchFilter = "(&(servicePrincipalName=*)(!(objectCategory=computer)))" + attributes = [ "sAMAccountName", "userAccountControl", diff --git a/nxc/protocols/ldap/proto_args.py b/nxc/protocols/ldap/proto_args.py index db7c5923a3..c311d46d8c 100644 --- a/nxc/protocols/ldap/proto_args.py +++ b/nxc/protocols/ldap/proto_args.py @@ -13,6 +13,7 @@ def proto_args(parser, parents): egroup = ldap_parser.add_argument_group("Retrieve hash on the remote DC", "Options to get hashes from Kerberos") egroup.add_argument("--asreproast", help="Output AS_REP response to crack with hashcat to file") egroup.add_argument("--kerberoasting", help="Output TGS ticket to crack with hashcat to file") + egroup.add_argument("--kerberoast-users", nargs="+", dest="kerberoast_users", help="Target specific users for kerberoasting (usernames or file containing usernames)") egroup.add_argument("--no-preauth-targets", nargs=1, dest="no_preauth_targets", help="Targeted kerberoastable users") vgroup = ldap_parser.add_argument_group("Retrieve useful information on the domain") From 71d8aa0142f9bafad7f3f3106e842ef65d3eb92f Mon Sep 17 00:00:00 2001 From: Marshall Hallenbeck Date: Sat, 2 Aug 2025 09:49:35 -0400 Subject: [PATCH 02/29] refactor(args): move get_conditional_access to central file --- nxc/helpers/args.py | 15 +++++++++++++++ nxc/protocols/smb/proto_args.py | 17 +---------------- nxc/protocols/ssh/proto_args.py | 19 ++----------------- 3 files changed, 18 insertions(+), 33 deletions(-) diff --git a/nxc/helpers/args.py b/nxc/helpers/args.py index 956ae37ed5..506f8a31dd 100644 --- a/nxc/helpers/args.py +++ b/nxc/helpers/args.py @@ -24,3 +24,18 @@ def __call__(self, parser, namespace, values, option_string=None): # Set an attribute to track whether the value was explicitly set setattr(namespace, self.dest, values) setattr(namespace, f"{self.dest}_explicitly_set", True) + + +def get_conditional_action(baseAction): + class ConditionalAction(baseAction): + def __init__(self, option_strings, dest, **kwargs): + x = kwargs.pop("make_required", []) + super().__init__(option_strings, dest, **kwargs) + self.make_required = x + + def __call__(self, parser, namespace, values, option_string=None): + for x in self.make_required: + x.required = True + super().__call__(parser, namespace, values, option_string) + + return ConditionalAction diff --git a/nxc/protocols/smb/proto_args.py b/nxc/protocols/smb/proto_args.py index 43a6feaa54..d74210e037 100644 --- a/nxc/protocols/smb/proto_args.py +++ b/nxc/protocols/smb/proto_args.py @@ -1,5 +1,5 @@ from argparse import _StoreTrueAction -from nxc.helpers.args import DisplayDefaultsNotNone, DefaultTrackingAction +from nxc.helpers.args import DisplayDefaultsNotNone, DefaultTrackingAction, get_conditional_action def proto_args(parser, parents): @@ -97,18 +97,3 @@ def proto_args(parser, parents): posh_group.add_argument("--no-encode", action="store_true", default=False, help="Do not encode the PowerShell command ran on target") return parser - - -def get_conditional_action(baseAction): - class ConditionalAction(baseAction): - def __init__(self, option_strings, dest, **kwargs): - x = kwargs.pop("make_required", []) - super().__init__(option_strings, dest, **kwargs) - self.make_required = x - - def __call__(self, parser, namespace, values, option_string=None): - for x in self.make_required: - x.required = True - super().__call__(parser, namespace, values, option_string) - - return ConditionalAction diff --git a/nxc/protocols/ssh/proto_args.py b/nxc/protocols/ssh/proto_args.py index add5454cef..af311f66dc 100644 --- a/nxc/protocols/ssh/proto_args.py +++ b/nxc/protocols/ssh/proto_args.py @@ -1,5 +1,5 @@ from argparse import _StoreAction -from nxc.helpers.args import DisplayDefaultsNotNone +from nxc.helpers.args import DisplayDefaultsNotNone, get_conditional_action def proto_args(parser, parents): @@ -21,19 +21,4 @@ def proto_args(parser, parents): cgroup.add_argument("--no-output", action="store_true", help="do not retrieve command output") cgroup.add_argument("-x", metavar="COMMAND", dest="execute", help="execute the specified command") - return parser - - -def get_conditional_action(baseAction): - class ConditionalAction(baseAction): - def __init__(self, option_strings, dest, **kwargs): - x = kwargs.pop("make_required", []) - super().__init__(option_strings, dest, **kwargs) - self.make_required = x - - def __call__(self, parser, namespace, values, option_string=None): - for x in self.make_required: - x.required = True - super().__call__(parser, namespace, values, option_string) - - return ConditionalAction \ No newline at end of file + return parser \ No newline at end of file From fcba94207efc7d98c4819b12c7f3ebea5a6fb9b5 Mon Sep 17 00:00:00 2001 From: Marshall Hallenbeck Date: Sat, 2 Aug 2025 09:50:15 -0400 Subject: [PATCH 03/29] fix(kerberoast): require kerberoasting arg when using kerberoast-users --- nxc/protocols/ldap/proto_args.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/nxc/protocols/ldap/proto_args.py b/nxc/protocols/ldap/proto_args.py index c311d46d8c..7b8a64dafd 100644 --- a/nxc/protocols/ldap/proto_args.py +++ b/nxc/protocols/ldap/proto_args.py @@ -1,4 +1,5 @@ -from nxc.helpers.args import DefaultTrackingAction, DisplayDefaultsNotNone +from nxc.helpers.args import DefaultTrackingAction, DisplayDefaultsNotNone, get_conditional_action +from argparse import _StoreAction def proto_args(parser, parents): @@ -12,9 +13,12 @@ def proto_args(parser, parents): egroup = ldap_parser.add_argument_group("Retrieve hash on the remote DC", "Options to get hashes from Kerberos") egroup.add_argument("--asreproast", help="Output AS_REP response to crack with hashcat to file") - egroup.add_argument("--kerberoasting", help="Output TGS ticket to crack with hashcat to file") - egroup.add_argument("--kerberoast-users", nargs="+", dest="kerberoast_users", help="Target specific users for kerberoasting (usernames or file containing usernames)") + kerberoasting_arg = egroup.add_argument("--kerberoasting", help="Output TGS ticket to crack with hashcat to file") + kerberoast_users_arg = egroup.add_argument("--kerberoast-users", nargs="+", dest="kerberoast_users", action=get_conditional_action(_StoreAction), make_required=[], help="Target specific users for kerberoasting (usernames or file containing usernames)") egroup.add_argument("--no-preauth-targets", nargs=1, dest="no_preauth_targets", help="Targeted kerberoastable users") + + # Make kerberoast-users require kerberoasting + kerberoast_users_arg.make_required = [kerberoasting_arg] vgroup = ldap_parser.add_argument_group("Retrieve useful information on the domain") vgroup.add_argument("--base-dn", metavar="BASE_DN", dest="base_dn", type=str, default=None, help="base DN for search queries") From 35bc7d9a0dccf1853a13faaef378af4891aaaf3c Mon Sep 17 00:00:00 2001 From: Marshall Hallenbeck Date: Sat, 2 Aug 2025 10:35:29 -0400 Subject: [PATCH 04/29] feat(kerberoast): add in kerberoast as alias to kerberoasting --- nxc/protocols/ldap/proto_args.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nxc/protocols/ldap/proto_args.py b/nxc/protocols/ldap/proto_args.py index 7b8a64dafd..7def836683 100644 --- a/nxc/protocols/ldap/proto_args.py +++ b/nxc/protocols/ldap/proto_args.py @@ -13,7 +13,7 @@ def proto_args(parser, parents): egroup = ldap_parser.add_argument_group("Retrieve hash on the remote DC", "Options to get hashes from Kerberos") egroup.add_argument("--asreproast", help="Output AS_REP response to crack with hashcat to file") - kerberoasting_arg = egroup.add_argument("--kerberoasting", help="Output TGS ticket to crack with hashcat to file") + kerberoasting_arg = egroup.add_argument("--kerberoasting", "--kerberoast", help="Output TGS ticket to crack with hashcat to file") kerberoast_users_arg = egroup.add_argument("--kerberoast-users", nargs="+", dest="kerberoast_users", action=get_conditional_action(_StoreAction), make_required=[], help="Target specific users for kerberoasting (usernames or file containing usernames)") egroup.add_argument("--no-preauth-targets", nargs=1, dest="no_preauth_targets", help="Targeted kerberoastable users") From e5af6420f87f36b10bf4a4f70bfb55d85bfa0c96 Mon Sep 17 00:00:00 2001 From: Marshall Hallenbeck Date: Wed, 13 Aug 2025 14:33:58 -0400 Subject: [PATCH 05/29] chore(ruff): fix stupid empty line --- nxc/protocols/ldap/proto_args.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nxc/protocols/ldap/proto_args.py b/nxc/protocols/ldap/proto_args.py index 7def836683..9b97a9cdc1 100644 --- a/nxc/protocols/ldap/proto_args.py +++ b/nxc/protocols/ldap/proto_args.py @@ -16,7 +16,7 @@ def proto_args(parser, parents): kerberoasting_arg = egroup.add_argument("--kerberoasting", "--kerberoast", help="Output TGS ticket to crack with hashcat to file") kerberoast_users_arg = egroup.add_argument("--kerberoast-users", nargs="+", dest="kerberoast_users", action=get_conditional_action(_StoreAction), make_required=[], help="Target specific users for kerberoasting (usernames or file containing usernames)") egroup.add_argument("--no-preauth-targets", nargs=1, dest="no_preauth_targets", help="Targeted kerberoastable users") - + # Make kerberoast-users require kerberoasting kerberoast_users_arg.make_required = [kerberoasting_arg] From 722fa0c8735e48a00d27b67c290349c87f54d03a Mon Sep 17 00:00:00 2001 From: Marshall Hallenbeck Date: Sun, 17 Aug 2025 11:32:16 -0400 Subject: [PATCH 06/29] fix: fail cleanly if file cannot be opened Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Marshall Hallenbeck --- nxc/protocols/ldap.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/nxc/protocols/ldap.py b/nxc/protocols/ldap.py index 2dafd580e8..09f2efad21 100644 --- a/nxc/protocols/ldap.py +++ b/nxc/protocols/ldap.py @@ -1036,7 +1036,11 @@ def kerberoasting(self): for item in self.args.kerberoast_users: if os.path.isfile(item): with open(item, encoding="utf-8") as f: - target_usernames.extend(line.strip() for line in f if line.strip()) + try: + with open(item, encoding="utf-8") as f: + target_usernames.extend(line.strip() for line in f if line.strip()) + except Exception as e: + self.logger.fail(f"Failed to read file '{item}': {e}") else: target_usernames.append(item.strip()) From 7b729af4ab68d9d3ab832b6fc32b6c619dca29f3 Mon Sep 17 00:00:00 2001 From: Marshall Hallenbeck Date: Tue, 29 Jul 2025 11:40:30 -0400 Subject: [PATCH 07/29] feat(kerberoasting): allow for specifying specific users to kerberoast --- nxc/protocols/ldap.py | 20 ++++++++++++++++++-- nxc/protocols/ldap/proto_args.py | 1 + 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/nxc/protocols/ldap.py b/nxc/protocols/ldap.py index f5762b18af..2dafd580e8 100644 --- a/nxc/protocols/ldap.py +++ b/nxc/protocols/ldap.py @@ -1031,8 +1031,24 @@ def kerberoasting(self): f.write(line + "\n") return - # Building the search filter - searchFilter = "(&(servicePrincipalName=*)(!(objectCategory=computer)))" + if self.args.kerberoast_users: + target_usernames = [] + for item in self.args.kerberoast_users: + if os.path.isfile(item): + with open(item, encoding="utf-8") as f: + target_usernames.extend(line.strip() for line in f if line.strip()) + else: + target_usernames.append(item.strip()) + + self.logger.info(f"Targeting specific users for kerberoasting: {', '.join(target_usernames)}") + + # build search filter for specific users + user_filter = "".join([f"(sAMAccountName={username})" for username in target_usernames]) + searchFilter = f"(&(servicePrincipalName=*)(!(objectCategory=computer))(|{user_filter}))" + else: + # default to all + searchFilter = "(&(servicePrincipalName=*)(!(objectCategory=computer)))" + attributes = [ "sAMAccountName", "userAccountControl", diff --git a/nxc/protocols/ldap/proto_args.py b/nxc/protocols/ldap/proto_args.py index db7c5923a3..c311d46d8c 100644 --- a/nxc/protocols/ldap/proto_args.py +++ b/nxc/protocols/ldap/proto_args.py @@ -13,6 +13,7 @@ def proto_args(parser, parents): egroup = ldap_parser.add_argument_group("Retrieve hash on the remote DC", "Options to get hashes from Kerberos") egroup.add_argument("--asreproast", help="Output AS_REP response to crack with hashcat to file") egroup.add_argument("--kerberoasting", help="Output TGS ticket to crack with hashcat to file") + egroup.add_argument("--kerberoast-users", nargs="+", dest="kerberoast_users", help="Target specific users for kerberoasting (usernames or file containing usernames)") egroup.add_argument("--no-preauth-targets", nargs=1, dest="no_preauth_targets", help="Targeted kerberoastable users") vgroup = ldap_parser.add_argument_group("Retrieve useful information on the domain") From 1ccd674e0f5f5f6387aedf2000a5523130271a0f Mon Sep 17 00:00:00 2001 From: Marshall Hallenbeck Date: Sat, 2 Aug 2025 09:49:35 -0400 Subject: [PATCH 08/29] refactor(args): move get_conditional_access to central file --- nxc/helpers/args.py | 15 +++++++++++++++ nxc/protocols/smb/proto_args.py | 17 +---------------- nxc/protocols/ssh/proto_args.py | 2 +- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/nxc/helpers/args.py b/nxc/helpers/args.py index 956ae37ed5..506f8a31dd 100644 --- a/nxc/helpers/args.py +++ b/nxc/helpers/args.py @@ -24,3 +24,18 @@ def __call__(self, parser, namespace, values, option_string=None): # Set an attribute to track whether the value was explicitly set setattr(namespace, self.dest, values) setattr(namespace, f"{self.dest}_explicitly_set", True) + + +def get_conditional_action(baseAction): + class ConditionalAction(baseAction): + def __init__(self, option_strings, dest, **kwargs): + x = kwargs.pop("make_required", []) + super().__init__(option_strings, dest, **kwargs) + self.make_required = x + + def __call__(self, parser, namespace, values, option_string=None): + for x in self.make_required: + x.required = True + super().__call__(parser, namespace, values, option_string) + + return ConditionalAction diff --git a/nxc/protocols/smb/proto_args.py b/nxc/protocols/smb/proto_args.py index f270086e17..d5c3cec3ac 100644 --- a/nxc/protocols/smb/proto_args.py +++ b/nxc/protocols/smb/proto_args.py @@ -1,5 +1,5 @@ from argparse import _StoreTrueAction -from nxc.helpers.args import DisplayDefaultsNotNone, DefaultTrackingAction +from nxc.helpers.args import DisplayDefaultsNotNone, DefaultTrackingAction, get_conditional_action def proto_args(parser, parents): @@ -98,18 +98,3 @@ def proto_args(parser, parents): posh_group.add_argument("--no-encode", action="store_true", default=False, help="Do not encode the PowerShell command ran on target") return parser - - -def get_conditional_action(baseAction): - class ConditionalAction(baseAction): - def __init__(self, option_strings, dest, **kwargs): - x = kwargs.pop("make_required", []) - super().__init__(option_strings, dest, **kwargs) - self.make_required = x - - def __call__(self, parser, namespace, values, option_string=None): - for x in self.make_required: - x.required = True - super().__call__(parser, namespace, values, option_string) - - return ConditionalAction diff --git a/nxc/protocols/ssh/proto_args.py b/nxc/protocols/ssh/proto_args.py index 10e618d39f..87c67fc73b 100644 --- a/nxc/protocols/ssh/proto_args.py +++ b/nxc/protocols/ssh/proto_args.py @@ -1,5 +1,5 @@ from argparse import _StoreAction -from nxc.helpers.args import DisplayDefaultsNotNone +from nxc.helpers.args import DisplayDefaultsNotNone, get_conditional_action def proto_args(parser, parents): From 1906919c810f171c0b3a3a66f70b47a84d0fd07f Mon Sep 17 00:00:00 2001 From: Marshall Hallenbeck Date: Sat, 2 Aug 2025 09:50:15 -0400 Subject: [PATCH 09/29] fix(kerberoast): require kerberoasting arg when using kerberoast-users --- nxc/protocols/ldap/proto_args.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/nxc/protocols/ldap/proto_args.py b/nxc/protocols/ldap/proto_args.py index c311d46d8c..7b8a64dafd 100644 --- a/nxc/protocols/ldap/proto_args.py +++ b/nxc/protocols/ldap/proto_args.py @@ -1,4 +1,5 @@ -from nxc.helpers.args import DefaultTrackingAction, DisplayDefaultsNotNone +from nxc.helpers.args import DefaultTrackingAction, DisplayDefaultsNotNone, get_conditional_action +from argparse import _StoreAction def proto_args(parser, parents): @@ -12,9 +13,12 @@ def proto_args(parser, parents): egroup = ldap_parser.add_argument_group("Retrieve hash on the remote DC", "Options to get hashes from Kerberos") egroup.add_argument("--asreproast", help="Output AS_REP response to crack with hashcat to file") - egroup.add_argument("--kerberoasting", help="Output TGS ticket to crack with hashcat to file") - egroup.add_argument("--kerberoast-users", nargs="+", dest="kerberoast_users", help="Target specific users for kerberoasting (usernames or file containing usernames)") + kerberoasting_arg = egroup.add_argument("--kerberoasting", help="Output TGS ticket to crack with hashcat to file") + kerberoast_users_arg = egroup.add_argument("--kerberoast-users", nargs="+", dest="kerberoast_users", action=get_conditional_action(_StoreAction), make_required=[], help="Target specific users for kerberoasting (usernames or file containing usernames)") egroup.add_argument("--no-preauth-targets", nargs=1, dest="no_preauth_targets", help="Targeted kerberoastable users") + + # Make kerberoast-users require kerberoasting + kerberoast_users_arg.make_required = [kerberoasting_arg] vgroup = ldap_parser.add_argument_group("Retrieve useful information on the domain") vgroup.add_argument("--base-dn", metavar="BASE_DN", dest="base_dn", type=str, default=None, help="base DN for search queries") From 76ce823ac1f2197b53c00bbd17df5a8097c4eb01 Mon Sep 17 00:00:00 2001 From: Marshall Hallenbeck Date: Sat, 2 Aug 2025 10:35:29 -0400 Subject: [PATCH 10/29] feat(kerberoast): add in kerberoast as alias to kerberoasting --- nxc/protocols/ldap/proto_args.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nxc/protocols/ldap/proto_args.py b/nxc/protocols/ldap/proto_args.py index 7b8a64dafd..7def836683 100644 --- a/nxc/protocols/ldap/proto_args.py +++ b/nxc/protocols/ldap/proto_args.py @@ -13,7 +13,7 @@ def proto_args(parser, parents): egroup = ldap_parser.add_argument_group("Retrieve hash on the remote DC", "Options to get hashes from Kerberos") egroup.add_argument("--asreproast", help="Output AS_REP response to crack with hashcat to file") - kerberoasting_arg = egroup.add_argument("--kerberoasting", help="Output TGS ticket to crack with hashcat to file") + kerberoasting_arg = egroup.add_argument("--kerberoasting", "--kerberoast", help="Output TGS ticket to crack with hashcat to file") kerberoast_users_arg = egroup.add_argument("--kerberoast-users", nargs="+", dest="kerberoast_users", action=get_conditional_action(_StoreAction), make_required=[], help="Target specific users for kerberoasting (usernames or file containing usernames)") egroup.add_argument("--no-preauth-targets", nargs=1, dest="no_preauth_targets", help="Targeted kerberoastable users") From c522c271d0d4d8390bd8fe2ccf47e4bf37d85f20 Mon Sep 17 00:00:00 2001 From: Marshall Hallenbeck Date: Wed, 13 Aug 2025 14:33:58 -0400 Subject: [PATCH 11/29] chore(ruff): fix stupid empty line --- nxc/protocols/ldap/proto_args.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nxc/protocols/ldap/proto_args.py b/nxc/protocols/ldap/proto_args.py index 7def836683..9b97a9cdc1 100644 --- a/nxc/protocols/ldap/proto_args.py +++ b/nxc/protocols/ldap/proto_args.py @@ -16,7 +16,7 @@ def proto_args(parser, parents): kerberoasting_arg = egroup.add_argument("--kerberoasting", "--kerberoast", help="Output TGS ticket to crack with hashcat to file") kerberoast_users_arg = egroup.add_argument("--kerberoast-users", nargs="+", dest="kerberoast_users", action=get_conditional_action(_StoreAction), make_required=[], help="Target specific users for kerberoasting (usernames or file containing usernames)") egroup.add_argument("--no-preauth-targets", nargs=1, dest="no_preauth_targets", help="Targeted kerberoastable users") - + # Make kerberoast-users require kerberoasting kerberoast_users_arg.make_required = [kerberoasting_arg] From 57edc294ad17ce5e6442532d741a0cd2904e5865 Mon Sep 17 00:00:00 2001 From: Z4kSec Date: Sat, 16 Aug 2025 13:02:13 +0000 Subject: [PATCH 12/29] Update Masky module to 0.2.1 --- nxc/modules/masky.py | 6 +++--- pyproject.toml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/nxc/modules/masky.py b/nxc/modules/masky.py index 1acb509aef..711ab1ea66 100644 --- a/nxc/modules/masky.py +++ b/nxc/modules/masky.py @@ -79,8 +79,8 @@ def process_results(self, connection, context, rslts, tracker): pwned_users = 0 for user in rslts.users: - if user.nthash: - context.log.highlight(f"{user.domain}\\{user.name} {user.nthash}") + if user.nt_hash: + context.log.highlight(f"{user.domain}\\{user.name} {user.nt_hash}") self.process_credentials(connection, context, user) pwned_users += 1 @@ -96,7 +96,7 @@ def process_credentials(self, connection, context, user): "hash", user.domain, user.name, - user.nthash, + user.nt_hash, pillaged_from=host, ) add_user_bh(user.name, user.domain, context.log, connection.config) diff --git a/pyproject.toml b/pyproject.toml index cdbad43394..2d62a65971 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -26,7 +26,7 @@ dependencies = [ "dsinternals>=1.2.4", "jwt>=1.3.1", "lsassy>=3.1.11", - "masky>=0.2.0", + "masky>=0.2.1", "minikerberos>=0.4.1", "neo4j>=5.0.0", "paramiko>=3.3.1", From a1a3a5d760b84393c57ebd2149a66308d14d237d Mon Sep 17 00:00:00 2001 From: Alexander Neff Date: Sat, 16 Aug 2025 16:14:32 -0400 Subject: [PATCH 13/29] Update masky --- poetry.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/poetry.lock b/poetry.lock index 59646b80e2..44d38753e8 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1252,14 +1252,14 @@ files = [ [[package]] name = "masky" -version = "0.2.0" +version = "0.2.1" description = "Python library with CLI allowing to remotely dump domain user credentials via an ADCS" optional = false python-versions = ">=3.6" groups = ["main"] files = [ - {file = "masky-0.2.0-py3-none-any.whl", hash = "sha256:04f29988e659bd265bf393c833ee473cfd16bf8a32ffdeaacfbefe8f466f53ab"}, - {file = "masky-0.2.0.tar.gz", hash = "sha256:fc0a99086da54e1cf91bb5e9c809aa311ea1519f10a3b6faf6d8e0a47c471ec9"}, + {file = "masky-0.2.1-py3-none-any.whl", hash = "sha256:bcf545f5e2b762fc49df2f29aa934498bb5dd37ba0a28e0c1683acee2e5ef14b"}, + {file = "masky-0.2.1.tar.gz", hash = "sha256:973615bebbd9455a1c2a81a6cec626a2032ec2209f242e3e69a6226e4b60b6fc"}, ] [package.dependencies] From ea6fab4a2b30195250326b93ee1f7230e226b87c Mon Sep 17 00:00:00 2001 From: Alexander Neff Date: Sat, 16 Aug 2025 16:16:51 -0400 Subject: [PATCH 14/29] Fix lock file --- poetry.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/poetry.lock b/poetry.lock index 44d38753e8..5980d2b7a1 100644 --- a/poetry.lock +++ b/poetry.lock @@ -2463,4 +2463,4 @@ files = [ [metadata] lock-version = "2.1" python-versions = ">=3.10,<4.0" -content-hash = "e02f61c9bb3bccd22fc51f90a9e09552afe50cb309155959dbb3ff06fea4d736" +content-hash = "e99f88534ebb145b7fadef433b4eb72132b4cb6ef012bc4132c69b75df348055" From 5366a1bc615addb893bb0333fd461bef729f7162 Mon Sep 17 00:00:00 2001 From: E1A Date: Sat, 2 Aug 2025 17:51:23 +0200 Subject: [PATCH 15/29] Added the lockscreendoors module --- nxc/modules/lockscreendoors.py | 90 ++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 nxc/modules/lockscreendoors.py diff --git a/nxc/modules/lockscreendoors.py b/nxc/modules/lockscreendoors.py new file mode 100644 index 0000000000..c5508a6b8d --- /dev/null +++ b/nxc/modules/lockscreendoors.py @@ -0,0 +1,90 @@ +import struct +from io import BytesIO +import pefile + +class NXCModule: + name = "lockscreendoors" + description = "Detect Windows lock screen backdoors by checking FileDescriptions of accessibility binaries." + supported_protocols = ["smb"] + + def __init__(self): + # list of exe names with expected descriptions + self.expected_descriptions = { + "utilman.exe": "Utility Manager", + "narrator.exe": "Screen Reader", + "sethc.exe": "Accessibility shortcut keys", + "osk.exe": "Accessibility On-Screen Keyboard", + "xwizard.exe": "Extensible Wizards Host Process", + "sndvol.exe": "Volume Mixer", + "ctfmon.exe": "CTF Loader", + "displayswitch.exe": "Display Switch", + "magnify.exe": "Microsoft Screen Magnifier", + "atbroker.exe": "Windows Assistive Technology Manager", + "EaseOfAccessDialog.exe": "Ease of Access Dialog Host" + } + + # if description matches one of these it's almost certainly backdoored + self.backdoor_descriptions = [ + "Windows Command Processor", + "Windows PowerShell" + ] + + def options(self, context, module_options): + pass + + def get_description(self, binary_data): + # extract the file description from version info + try: + pe = pefile.PE(data=binary_data, fast_load=True) + pe.parse_data_directories( + directories=[pefile.DIRECTORY_ENTRY['IMAGE_DIRECTORY_ENTRY_RESOURCE']] + ) + for fileinfo in pe.FileInfo: + for entry in fileinfo: + if entry.Key.decode() == 'StringFileInfo': + for st in entry.StringTable: + desc = st.entries.get(b"FileDescription") + if desc: + return desc.decode(errors="ignore") + except Exception: + return None + return None + + def on_admin_login(self, context, connection): + target_path = "Windows/System32" + tampered = False + readable_file_found = False + + for exe, expected_desc in self.expected_descriptions.items(): + try: + # grab the binary from the share + buf = BytesIO() + connection.conn.getFile("C$", f"{target_path}/{exe}", buf.write) + binary = buf.getvalue() + readable_file_found = True + + # extract and normalize the file description + file_desc = self.get_description(binary) + if not file_desc: + context.log.fail(f"{exe}: could not extract FileDescription") + continue + + file_desc = file_desc.strip() + + # check if the description is what we expect + if file_desc != expected_desc: + tampered = True + if file_desc in self.backdoor_descriptions: + context.log.fail(f"BACKDOOR DETECTED: {exe} has FileDescription '{file_desc}'") + else: + context.log.fail(f"SUSPICIOUS: {exe} has unexpected FileDescription '{file_desc}' (expected '{expected_desc}')") + + except Exception: + # silently skip if we can't access the file + continue + + if not readable_file_found: + return + + if not tampered: + context.log.display("All lock screen executable descriptions are consistent with the expected values") \ No newline at end of file From 28f5bd1b7947a2566369bcf8c4619be523edce28 Mon Sep 17 00:00:00 2001 From: E1A Date: Sat, 2 Aug 2025 17:53:52 +0200 Subject: [PATCH 16/29] added credits --- nxc/modules/lockscreendoors.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/nxc/modules/lockscreendoors.py b/nxc/modules/lockscreendoors.py index c5508a6b8d..e5cfc92107 100644 --- a/nxc/modules/lockscreendoors.py +++ b/nxc/modules/lockscreendoors.py @@ -3,6 +3,10 @@ import pefile class NXCModule: + """ + Module by @E1A + """ + name = "lockscreendoors" description = "Detect Windows lock screen backdoors by checking FileDescriptions of accessibility binaries." supported_protocols = ["smb"] From 23046792db5241ae035e4853359e7c29d33291b5 Mon Sep 17 00:00:00 2001 From: E1A Date: Sat, 2 Aug 2025 18:07:53 +0200 Subject: [PATCH 17/29] ruff changes --- nxc/modules/lockscreendoors.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/nxc/modules/lockscreendoors.py b/nxc/modules/lockscreendoors.py index e5cfc92107..b591b8326a 100644 --- a/nxc/modules/lockscreendoors.py +++ b/nxc/modules/lockscreendoors.py @@ -1,11 +1,9 @@ -import struct from io import BytesIO import pefile + class NXCModule: - """ - Module by @E1A - """ + """Module by @E1A""" name = "lockscreendoors" description = "Detect Windows lock screen backdoors by checking FileDescriptions of accessibility binaries." @@ -41,11 +39,11 @@ def get_description(self, binary_data): try: pe = pefile.PE(data=binary_data, fast_load=True) pe.parse_data_directories( - directories=[pefile.DIRECTORY_ENTRY['IMAGE_DIRECTORY_ENTRY_RESOURCE']] + directories=[pefile.DIRECTORY_ENTRY["IMAGE_DIRECTORY_ENTRY_RESOURCE"]] ) for fileinfo in pe.FileInfo: for entry in fileinfo: - if entry.Key.decode() == 'StringFileInfo': + if entry.Key.decode() == "StringFileInfo": for st in entry.StringTable: desc = st.entries.get(b"FileDescription") if desc: @@ -91,4 +89,4 @@ def on_admin_login(self, context, connection): return if not tampered: - context.log.display("All lock screen executable descriptions are consistent with the expected values") \ No newline at end of file + context.log.display("All lock screen executable descriptions are consistent with the expected values") From 352fef499363fa1f0da02c171eaf9442b6111c89 Mon Sep 17 00:00:00 2001 From: E1A Date: Sat, 2 Aug 2025 18:30:56 +0200 Subject: [PATCH 18/29] Added lockscreendoors --- tests/e2e_commands.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/e2e_commands.txt b/tests/e2e_commands.txt index ca61185359..12ad46d385 100644 --- a/tests/e2e_commands.txt +++ b/tests/e2e_commands.txt @@ -291,3 +291,4 @@ netexec nfs TARGET_HOST -u "" -p "" --shares netexec nfs TARGET_HOST -u "" -p "" --enum-shares netexec nfs TARGET_HOST -u "" -p "" --get-file /NFStest/test/test.txt ../test.txt netexec nfs TARGET_HOST -u "" -p "" --put-file ../test.txt /NFStest/test +netexec smb TARGET_HOST -u LOGIN_USERNAME -p LOGIN_PASSWORD -M lockscreendoors \ No newline at end of file From 18794f996e6670f9a7761b1f4cb7028aeeaaa032 Mon Sep 17 00:00:00 2001 From: E1A Date: Mon, 4 Aug 2025 09:57:04 +0200 Subject: [PATCH 19/29] Fixed issues for PR --- nxc/modules/lockscreendoors.py | 24 ++++++++++-------------- pyproject.toml | 1 + tests/e2e_commands.txt | 4 ++-- 3 files changed, 13 insertions(+), 16 deletions(-) diff --git a/nxc/modules/lockscreendoors.py b/nxc/modules/lockscreendoors.py index b591b8326a..12754fdc47 100644 --- a/nxc/modules/lockscreendoors.py +++ b/nxc/modules/lockscreendoors.py @@ -10,7 +10,7 @@ class NXCModule: supported_protocols = ["smb"] def __init__(self): - # list of exe names with expected descriptions + # List of exe names with expected descriptions self.expected_descriptions = { "utilman.exe": "Utility Manager", "narrator.exe": "Screen Reader", @@ -25,7 +25,7 @@ def __init__(self): "EaseOfAccessDialog.exe": "Ease of Access Dialog Host" } - # if description matches one of these it's almost certainly backdoored + # If description matches one of these it's almost certainly backdoored self.backdoor_descriptions = [ "Windows Command Processor", "Windows PowerShell" @@ -35,19 +35,17 @@ def options(self, context, module_options): pass def get_description(self, binary_data): - # extract the file description from version info + # Extract the file description from version info try: pe = pefile.PE(data=binary_data, fast_load=True) - pe.parse_data_directories( - directories=[pefile.DIRECTORY_ENTRY["IMAGE_DIRECTORY_ENTRY_RESOURCE"]] - ) + pe.parse_data_directories(directories=[pefile.DIRECTORY_ENTRY["IMAGE_DIRECTORY_ENTRY_RESOURCE"]]) for fileinfo in pe.FileInfo: for entry in fileinfo: if entry.Key.decode() == "StringFileInfo": for st in entry.StringTable: desc = st.entries.get(b"FileDescription") if desc: - return desc.decode(errors="ignore") + return desc.decode(errors="ignore").strip() except Exception: return None return None @@ -59,21 +57,19 @@ def on_admin_login(self, context, connection): for exe, expected_desc in self.expected_descriptions.items(): try: - # grab the binary from the share + # Grab the binary from the share buf = BytesIO() connection.conn.getFile("C$", f"{target_path}/{exe}", buf.write) binary = buf.getvalue() readable_file_found = True - # extract and normalize the file description + # Extract and normalize the file description file_desc = self.get_description(binary) if not file_desc: context.log.fail(f"{exe}: could not extract FileDescription") continue - file_desc = file_desc.strip() - - # check if the description is what we expect + # Check if the description is as expected if file_desc != expected_desc: tampered = True if file_desc in self.backdoor_descriptions: @@ -82,11 +78,11 @@ def on_admin_login(self, context, connection): context.log.fail(f"SUSPICIOUS: {exe} has unexpected FileDescription '{file_desc}' (expected '{expected_desc}')") except Exception: - # silently skip if we can't access the file + # Silently skip if we can't access the file continue if not readable_file_found: return if not tampered: - context.log.display("All lock screen executable descriptions are consistent with the expected values") + context.log.display("All lock screen executable descriptions are consistent with the expected values") \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 2d62a65971..c7c70c1cea 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -46,6 +46,7 @@ dependencies = [ "impacket @ git+https://github.com/Pennyw0rth/impacket.git", "oscrypto @ git+https://github.com/wbond/oscrypto", "pynfsclient @ git+https://github.com/Pennyw0rth/NfsClient", + "pefile (>=2024.8.26,<2025.0.0)", ] [project.urls] diff --git a/tests/e2e_commands.txt b/tests/e2e_commands.txt index 12ad46d385..2085dddc79 100644 --- a/tests/e2e_commands.txt +++ b/tests/e2e_commands.txt @@ -161,6 +161,7 @@ netexec smb TARGET_HOST -u LOGIN_USERNAME -p LOGIN_PASSWORD KERBEROS -M winscp netexec smb TARGET_HOST -u LOGIN_USERNAME -p LOGIN_PASSWORD KERBEROS -M zerologon #netexec smb TARGET_HOST -u LOGIN_USERNAME -p LOGIN_PASSWORD KERBEROS -M change-password -o NEWPASS=Password123 #netexec smb TARGET_HOST -u LOGIN_USERNAME -p LOGIN_PASSWORD KERBEROS -M change-password -o NEWNTHASH=58A478135A93AC3BF058A5EA0E8FDB71 +netexec smb TARGET_HOST -u LOGIN_USERNAME -p LOGIN_PASSWORD KERBEROS -M lockscreendoors # test for multiple modules at once netexec smb TARGET_HOST -u LOGIN_USERNAME -p LOGIN_PASSWORD KERBEROS -M spooler -M petitpotam -M zerologon -M nopac -M enum_av -M enum_dns -M gpp_autologin -M gpp_password -M lsassy -M impersonate -M install_elevated -M ioxidresolver -M ms17-010 -M ntlmv1 -M runasppl -M uac -M webdav -M wifi -M coerce_plus ##### SMB Anonymous Auth @@ -290,5 +291,4 @@ netexec ftp TARGET_HOST -u TEST_USER_FILE -p TEST_PASSWORD_FILE netexec nfs TARGET_HOST -u "" -p "" --shares netexec nfs TARGET_HOST -u "" -p "" --enum-shares netexec nfs TARGET_HOST -u "" -p "" --get-file /NFStest/test/test.txt ../test.txt -netexec nfs TARGET_HOST -u "" -p "" --put-file ../test.txt /NFStest/test -netexec smb TARGET_HOST -u LOGIN_USERNAME -p LOGIN_PASSWORD -M lockscreendoors \ No newline at end of file +netexec nfs TARGET_HOST -u "" -p "" --put-file ../test.txt /NFStest/test \ No newline at end of file From 458b1137e381721865619cf866464f130bbb992a Mon Sep 17 00:00:00 2001 From: E1A Date: Mon, 4 Aug 2025 16:23:02 +0200 Subject: [PATCH 20/29] Added and removed lock screen executables Changed context.log.fail to context.log.highlight when if tampered = true --- nxc/modules/lockscreendoors.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/nxc/modules/lockscreendoors.py b/nxc/modules/lockscreendoors.py index 12754fdc47..f9e4d27757 100644 --- a/nxc/modules/lockscreendoors.py +++ b/nxc/modules/lockscreendoors.py @@ -3,7 +3,10 @@ class NXCModule: - """Module by @E1A""" + """ + Module for detecting Windows lock screen backdoors + Module by @E1A + """ name = "lockscreendoors" description = "Detect Windows lock screen backdoors by checking FileDescriptions of accessibility binaries." @@ -16,13 +19,11 @@ def __init__(self): "narrator.exe": "Screen Reader", "sethc.exe": "Accessibility shortcut keys", "osk.exe": "Accessibility On-Screen Keyboard", - "xwizard.exe": "Extensible Wizards Host Process", - "sndvol.exe": "Volume Mixer", - "ctfmon.exe": "CTF Loader", - "displayswitch.exe": "Display Switch", "magnify.exe": "Microsoft Screen Magnifier", + "EaseOfAccessDialog.exe": "Ease of Access Dialog Host", + "voiceaccess.exe": "Voice access", # Only on Windows 11 / Server 2025+ + "displayswitch.exe": "Display Switch", "atbroker.exe": "Windows Assistive Technology Manager", - "EaseOfAccessDialog.exe": "Ease of Access Dialog Host" } # If description matches one of these it's almost certainly backdoored @@ -73,12 +74,12 @@ def on_admin_login(self, context, connection): if file_desc != expected_desc: tampered = True if file_desc in self.backdoor_descriptions: - context.log.fail(f"BACKDOOR DETECTED: {exe} has FileDescription '{file_desc}'") + context.log.highlight(f"BACKDOOR DETECTED: {exe} has FileDescription '{file_desc}'") else: - context.log.fail(f"SUSPICIOUS: {exe} has unexpected FileDescription '{file_desc}' (expected '{expected_desc}')") + context.log.highlight(f"SUSPICIOUS: {exe} has unexpected FileDescription '{file_desc}' (expected '{expected_desc}')") except Exception: - # Silently skip if we can't access the file + # Silently skip if the file is not readable or doesn't exist continue if not readable_file_found: From 42379396f578682aa3d5b029b58f3367c93045dc Mon Sep 17 00:00:00 2001 From: E1A Date: Wed, 6 Aug 2025 09:40:43 +0200 Subject: [PATCH 21/29] Fixed support for Win server 2008 and multiple descriptions --- nxc/modules/lockscreendoors.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/nxc/modules/lockscreendoors.py b/nxc/modules/lockscreendoors.py index f9e4d27757..891fa0ef3a 100644 --- a/nxc/modules/lockscreendoors.py +++ b/nxc/modules/lockscreendoors.py @@ -15,15 +15,15 @@ class NXCModule: def __init__(self): # List of exe names with expected descriptions self.expected_descriptions = { - "utilman.exe": "Utility Manager", - "narrator.exe": "Screen Reader", - "sethc.exe": "Accessibility shortcut keys", - "osk.exe": "Accessibility On-Screen Keyboard", - "magnify.exe": "Microsoft Screen Magnifier", - "EaseOfAccessDialog.exe": "Ease of Access Dialog Host", - "voiceaccess.exe": "Voice access", # Only on Windows 11 / Server 2025+ - "displayswitch.exe": "Display Switch", - "atbroker.exe": "Windows Assistive Technology Manager", + "utilman.exe": ["Utility Manager"], + "narrator.exe": ["Screen Reader", "Narrator"], + "sethc.exe": ["Accessibility shortcut keys"], + "osk.exe": ["Accessibility On-Screen Keyboard"], + "magnify.exe": ["Microsoft Screen Magnifier"], + "EaseOfAccessDialog.exe": ["Ease of Access Dialog Host"], + "voiceaccess.exe": ["Voice access"], # Only on Windows 11 / Server 2025+ + "displayswitch.exe": ["Display Switch"], + "atbroker.exe": ["Windows Assistive Technology Manager", "Transitions Accessible technologies between desktops"], } # If description matches one of these it's almost certainly backdoored @@ -56,7 +56,7 @@ def on_admin_login(self, context, connection): tampered = False readable_file_found = False - for exe, expected_desc in self.expected_descriptions.items(): + for exe, expected_descs in self.expected_descriptions.items(): try: # Grab the binary from the share buf = BytesIO() @@ -71,12 +71,12 @@ def on_admin_login(self, context, connection): continue # Check if the description is as expected - if file_desc != expected_desc: + if file_desc not in expected_descs: tampered = True if file_desc in self.backdoor_descriptions: context.log.highlight(f"BACKDOOR DETECTED: {exe} has FileDescription '{file_desc}'") else: - context.log.highlight(f"SUSPICIOUS: {exe} has unexpected FileDescription '{file_desc}' (expected '{expected_desc}')") + context.log.highlight(f"SUSPICIOUS: {exe} has unexpected FileDescription '{file_desc}' (expected '{expected_descs}')") except Exception: # Silently skip if the file is not readable or doesn't exist From 055934e4cc4b8aae9b07a43bf994d5f58bc6113b Mon Sep 17 00:00:00 2001 From: E1A Date: Wed, 6 Aug 2025 09:52:40 +0200 Subject: [PATCH 22/29] format expected descriptions as plain string in output --- nxc/modules/lockscreendoors.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/nxc/modules/lockscreendoors.py b/nxc/modules/lockscreendoors.py index 891fa0ef3a..e5debb85c6 100644 --- a/nxc/modules/lockscreendoors.py +++ b/nxc/modules/lockscreendoors.py @@ -76,7 +76,14 @@ def on_admin_login(self, context, connection): if file_desc in self.backdoor_descriptions: context.log.highlight(f"BACKDOOR DETECTED: {exe} has FileDescription '{file_desc}'") else: - context.log.highlight(f"SUSPICIOUS: {exe} has unexpected FileDescription '{file_desc}' (expected '{expected_descs}')") + if len(expected_descs) == 1: + expected_str = f"'{expected_descs[0]}'" + else: + expected_str = ", ".join(f"'{d}'" for d in expected_descs) + expected_str = f"one of: {expected_str}" + context.log.highlight( + f"SUSPICIOUS: {exe} has unexpected FileDescription '{file_desc}' (expected {expected_str})" + ) except Exception: # Silently skip if the file is not readable or doesn't exist From 005af59431374ad643748bf3348ab10f58b37265 Mon Sep 17 00:00:00 2001 From: Alexander Neff Date: Sat, 16 Aug 2025 09:22:20 -0400 Subject: [PATCH 23/29] Formatting --- tests/e2e_commands.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/e2e_commands.txt b/tests/e2e_commands.txt index 2085dddc79..1a45c3bbac 100644 --- a/tests/e2e_commands.txt +++ b/tests/e2e_commands.txt @@ -291,4 +291,4 @@ netexec ftp TARGET_HOST -u TEST_USER_FILE -p TEST_PASSWORD_FILE netexec nfs TARGET_HOST -u "" -p "" --shares netexec nfs TARGET_HOST -u "" -p "" --enum-shares netexec nfs TARGET_HOST -u "" -p "" --get-file /NFStest/test/test.txt ../test.txt -netexec nfs TARGET_HOST -u "" -p "" --put-file ../test.txt /NFStest/test \ No newline at end of file +netexec nfs TARGET_HOST -u "" -p "" --put-file ../test.txt /NFStest/test From 81997e6b019162b12e4e7c5c16803c45abb0c6e3 Mon Sep 17 00:00:00 2001 From: Alexander Neff Date: Sat, 16 Aug 2025 09:25:10 -0400 Subject: [PATCH 24/29] Formatting --- nxc/modules/lockscreendoors.py | 2 +- pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/nxc/modules/lockscreendoors.py b/nxc/modules/lockscreendoors.py index e5debb85c6..6b54a5e204 100644 --- a/nxc/modules/lockscreendoors.py +++ b/nxc/modules/lockscreendoors.py @@ -93,4 +93,4 @@ def on_admin_login(self, context, connection): return if not tampered: - context.log.display("All lock screen executable descriptions are consistent with the expected values") \ No newline at end of file + context.log.display("All lock screen executable descriptions are consistent with the expected values") diff --git a/pyproject.toml b/pyproject.toml index c7c70c1cea..fa70c0761f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -30,6 +30,7 @@ dependencies = [ "minikerberos>=0.4.1", "neo4j>=5.0.0", "paramiko>=3.3.1", + "pefile (>=2024.8.26,<2025.0.0)", "pyasn1-modules>=0.3.0", "pylnk3>=0.4.3", "pypsrp>=0.8.1", @@ -46,7 +47,6 @@ dependencies = [ "impacket @ git+https://github.com/Pennyw0rth/impacket.git", "oscrypto @ git+https://github.com/wbond/oscrypto", "pynfsclient @ git+https://github.com/Pennyw0rth/NfsClient", - "pefile (>=2024.8.26,<2025.0.0)", ] [project.urls] From e60aa93ad0ead06c48bef1847342a4e2f809b647 Mon Sep 17 00:00:00 2001 From: Alexander Neff Date: Sat, 16 Aug 2025 09:32:51 -0400 Subject: [PATCH 25/29] Add debug log on parsing errors --- nxc/modules/lockscreendoors.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/nxc/modules/lockscreendoors.py b/nxc/modules/lockscreendoors.py index 6b54a5e204..a0d7ba1f6d 100644 --- a/nxc/modules/lockscreendoors.py +++ b/nxc/modules/lockscreendoors.py @@ -46,9 +46,9 @@ def get_description(self, binary_data): for st in entry.StringTable: desc = st.entries.get(b"FileDescription") if desc: - return desc.decode(errors="ignore").strip() - except Exception: - return None + return desc.decode().strip() + except Exception as e: + self.context.log.debug(f"Failed to extract PE info: {e}") return None def on_admin_login(self, context, connection): From 1f313caf4dda6509991bc8144da97712c42452b3 Mon Sep 17 00:00:00 2001 From: Alexander Neff Date: Sat, 16 Aug 2025 09:33:13 -0400 Subject: [PATCH 26/29] Formatting and remove unnecessary check --- nxc/modules/lockscreendoors.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/nxc/modules/lockscreendoors.py b/nxc/modules/lockscreendoors.py index a0d7ba1f6d..ad34e61b07 100644 --- a/nxc/modules/lockscreendoors.py +++ b/nxc/modules/lockscreendoors.py @@ -52,17 +52,15 @@ def get_description(self, binary_data): return None def on_admin_login(self, context, connection): - target_path = "Windows/System32" + target_path = "\\Windows\\System32" tampered = False - readable_file_found = False for exe, expected_descs in self.expected_descriptions.items(): try: # Grab the binary from the share buf = BytesIO() - connection.conn.getFile("C$", f"{target_path}/{exe}", buf.write) + connection.conn.getFile("C$", f"{target_path}\\{exe}", buf.write) binary = buf.getvalue() - readable_file_found = True # Extract and normalize the file description file_desc = self.get_description(binary) @@ -89,8 +87,5 @@ def on_admin_login(self, context, connection): # Silently skip if the file is not readable or doesn't exist continue - if not readable_file_found: - return - if not tampered: context.log.display("All lock screen executable descriptions are consistent with the expected values") From 77d00bb36e5658d1dba545078d50e835e0dcddc7 Mon Sep 17 00:00:00 2001 From: Alexander Neff Date: Sat, 16 Aug 2025 09:44:26 -0400 Subject: [PATCH 27/29] Don't skip silently, bug provide a debug log --- nxc/modules/lockscreendoors.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/nxc/modules/lockscreendoors.py b/nxc/modules/lockscreendoors.py index ad34e61b07..4a5450ea93 100644 --- a/nxc/modules/lockscreendoors.py +++ b/nxc/modules/lockscreendoors.py @@ -79,13 +79,9 @@ def on_admin_login(self, context, connection): else: expected_str = ", ".join(f"'{d}'" for d in expected_descs) expected_str = f"one of: {expected_str}" - context.log.highlight( - f"SUSPICIOUS: {exe} has unexpected FileDescription '{file_desc}' (expected {expected_str})" - ) - - except Exception: - # Silently skip if the file is not readable or doesn't exist - continue + context.log.highlight(f"SUSPICIOUS: {exe} has unexpected FileDescription '{file_desc}' (expected {expected_str})") + except Exception as e: + context.log.debug(f"Failed to process {exe}: {e}") if not tampered: context.log.display("All lock screen executable descriptions are consistent with the expected values") From e7d9a4a4b80a22f30ab7157e32feff4fccd9c7b0 Mon Sep 17 00:00:00 2001 From: Alexander Neff Date: Sat, 16 Aug 2025 09:47:03 -0400 Subject: [PATCH 28/29] Add 'No options available' to the module and the example module --- nxc/modules/example_module.py | 1 + nxc/modules/lockscreendoors.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/nxc/modules/example_module.py b/nxc/modules/example_module.py index 7cf731376c..b467c26d51 100644 --- a/nxc/modules/example_module.py +++ b/nxc/modules/example_module.py @@ -18,6 +18,7 @@ def options(self, context, module_options): """Required. Module options get parsed here. Additionally, put the modules usage here as well """ + # Put "No options available" in the docstring if there are no options for the module def on_login(self, context, connection): """Concurrent. diff --git a/nxc/modules/lockscreendoors.py b/nxc/modules/lockscreendoors.py index 4a5450ea93..f4005b3cf4 100644 --- a/nxc/modules/lockscreendoors.py +++ b/nxc/modules/lockscreendoors.py @@ -33,7 +33,7 @@ def __init__(self): ] def options(self, context, module_options): - pass + """No options available""" def get_description(self, binary_data): # Extract the file description from version info From a982386190fb9cfa1c73479ca17db74097216c91 Mon Sep 17 00:00:00 2001 From: Marshall Hallenbeck Date: Sun, 17 Aug 2025 11:32:16 -0400 Subject: [PATCH 29/29] fix: fail cleanly if file cannot be opened Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Marshall Hallenbeck --- nxc/protocols/ldap.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/nxc/protocols/ldap.py b/nxc/protocols/ldap.py index 2dafd580e8..09f2efad21 100644 --- a/nxc/protocols/ldap.py +++ b/nxc/protocols/ldap.py @@ -1036,7 +1036,11 @@ def kerberoasting(self): for item in self.args.kerberoast_users: if os.path.isfile(item): with open(item, encoding="utf-8") as f: - target_usernames.extend(line.strip() for line in f if line.strip()) + try: + with open(item, encoding="utf-8") as f: + target_usernames.extend(line.strip() for line in f if line.strip()) + except Exception as e: + self.logger.fail(f"Failed to read file '{item}': {e}") else: target_usernames.append(item.strip())