Skip to content

Commit ac7446b

Browse files
committed
Add category to modules
1 parent 9bde648 commit ac7446b

3 files changed

Lines changed: 27 additions & 7 deletions

File tree

nxc/loaders/moduleloader.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ def module_is_sane(self, module, module_path):
3030
elif not hasattr(module, "description"):
3131
self.logger.fail(f"{module_path} missing the description variable")
3232
module_error = True
33+
elif not hasattr(module, "category"):
34+
self.logger.fail(f"{module_path} missing the category variable")
35+
module_error = True
3336
elif not hasattr(module, "supported_protocols"):
3437
self.logger.fail(f"{module_path} missing the supported_protocols variable")
3538
module_error = True
@@ -92,6 +95,7 @@ def get_module_info(self, module_path):
9295
"description": module_spec.description,
9396
"options": module_spec.options.__doc__,
9497
"supported_protocols": module_spec.supported_protocols,
98+
"category": module_spec.category,
9599
"requires_admin": bool(hasattr(module_spec, "on_admin_login") and callable(module_spec.on_admin_login)),
96100
}
97101
}

nxc/modules/adcs.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
from impacket.ldap import ldap, ldapasn1
33
from impacket.ldap.ldap import LDAPSearchError
44

5+
from nxc.helpers.misc import CATEGORY
6+
57

68
class NXCModule:
79
"""

nxc/netexec.py

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
# PYTHON_ARGCOMPLETE_OK
22
import sys
3+
4+
from termcolor import colored
35
from nxc.helpers.logger import highlight
4-
from nxc.helpers.misc import identify_target_file
6+
from nxc.helpers.misc import identify_target_file, CATEGORY
57
from nxc.parsers.ip import parse_targets
68
from nxc.parsers.nmap import parse_nmap_xml
79
from nxc.parsers.nessus import parse_nessus_file
@@ -162,14 +164,26 @@ def main():
162164
modules = loader.list_modules()
163165

164166
if args.list_modules:
167+
low_privilege_modules = {m: props for m, props in modules.items() if args.protocol in props["supported_protocols"] and not props["requires_admin"]}
168+
high_privilege_modules = {m: props for m, props in modules.items() if args.protocol in props["supported_protocols"] and props["requires_admin"]}
169+
170+
# List low privilege modules
165171
nxc_logger.highlight("LOW PRIVILEGE MODULES")
166-
for name, props in sorted(modules.items()):
167-
if args.protocol in props["supported_protocols"] and not props["requires_admin"]:
168-
nxc_logger.display(f"{name:<25} {props['description']}")
172+
for category, color in {CATEGORY.ENUMERATION: "green", CATEGORY.CREDENTIAL_DUMPING: "cyan", CATEGORY.PRIVILEGE_ESCALATION: "magenta"}.items():
173+
if len([module for module in low_privilege_modules.values() if module["category"] == category]) > 0:
174+
nxc_logger.highlight(colored(f"{category.name}", color, attrs=["bold"]))
175+
for name, props in sorted(low_privilege_modules.items()):
176+
if props["category"] == category:
177+
nxc_logger.display(f"{name:<25} {props['description']}")
178+
179+
# List high privilege modules
169180
nxc_logger.highlight("\nHIGH PRIVILEGE MODULES (requires admin privs)")
170-
for name, props in sorted(modules.items()):
171-
if args.protocol in props["supported_protocols"] and props["requires_admin"]:
172-
nxc_logger.display(f"{name:<25} {props['description']}")
181+
for category, color in {CATEGORY.ENUMERATION: "green", CATEGORY.CREDENTIAL_DUMPING: "cyan", CATEGORY.PRIVILEGE_ESCALATION: "magenta"}.items():
182+
if len([module for module in high_privilege_modules.values() if module["category"] == category]) > 0:
183+
nxc_logger.highlight(colored(f"{category.name}", color, attrs=["bold"]))
184+
for name, props in sorted(high_privilege_modules.items()):
185+
if props["category"] == category:
186+
nxc_logger.display(f"{name:<25} {props['description']}")
173187
exit(0)
174188
elif args.module and args.show_module_options:
175189
for module in args.module:

0 commit comments

Comments
 (0)