Skip to content

Commit 4b1b9b6

Browse files
committed
Add category filtering to module listing
1 parent 652fc12 commit 4b1b9b6

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

nxc/cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def gen_cli_args():
7676
mgroup = module_parser.add_argument_group("Modules", "Options for nxc modules")
7777
mgroup.add_argument("-M", "--module", choices=get_module_names(), action="append", metavar="MODULE", help="module to use")
7878
mgroup.add_argument("-o", metavar="MODULE_OPTION", nargs="+", default=[], dest="module_options", help="module options")
79-
mgroup.add_argument("-L", "--list-modules", action="store_true", help="list available modules")
79+
mgroup.add_argument("-L", "--list-modules", nargs="?", type=str, const="", help="list available modules")
8080
mgroup.add_argument("--options", dest="show_module_options", action="store_true", help="display module options")
8181

8282
subparsers = parser.add_subparsers(title="Available Protocols", dest="protocol")

nxc/netexec.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,17 +159,20 @@ def main():
159159
# with the new nxc/config.py this can be eventually removed, as it can be imported anywhere
160160
protocol_object.config = nxc_config
161161

162-
if args.module or args.list_modules:
162+
if args.module or args.list_modules is not None:
163163
loader = ModuleLoader(args, db, nxc_logger)
164164
modules = loader.list_modules()
165165

166-
if args.list_modules:
166+
if args.list_modules is not None:
167167
low_privilege_modules = {m: props for m, props in modules.items() if args.protocol in props["supported_protocols"] and not props["requires_admin"]}
168168
high_privilege_modules = {m: props for m, props in modules.items() if args.protocol in props["supported_protocols"] and props["requires_admin"]}
169169

170170
# List low privilege modules
171171
nxc_logger.highlight("LOW PRIVILEGE MODULES")
172172
for category, color in {CATEGORY.ENUMERATION: "green", CATEGORY.CREDENTIAL_DUMPING: "cyan", CATEGORY.PRIVILEGE_ESCALATION: "magenta"}.items():
173+
# Add category filter for module listing
174+
if args.list_modules and args.list_modules.lower() != category.name.lower():
175+
continue
173176
if len([module for module in low_privilege_modules.values() if module["category"] == category]) > 0:
174177
nxc_logger.highlight(colored(f"{category.name}", color, attrs=["bold"]))
175178
for name, props in sorted(low_privilege_modules.items()):
@@ -179,6 +182,9 @@ def main():
179182
# List high privilege modules
180183
nxc_logger.highlight("\nHIGH PRIVILEGE MODULES (requires admin privs)")
181184
for category, color in {CATEGORY.ENUMERATION: "green", CATEGORY.CREDENTIAL_DUMPING: "cyan", CATEGORY.PRIVILEGE_ESCALATION: "magenta"}.items():
185+
# Add category filter for module listing
186+
if args.list_modules and args.list_modules.lower() != category.name.lower():
187+
continue
182188
if len([module for module in high_privilege_modules.values() if module["category"] == category]) > 0:
183189
nxc_logger.highlight(colored(f"{category.name}", color, attrs=["bold"]))
184190
for name, props in sorted(high_privilege_modules.items()):

0 commit comments

Comments
 (0)