Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to get completion to work for NetExec #468

Closed
Adamkadaban opened this issue Dec 16, 2023 · 2 comments
Closed

Unable to get completion to work for NetExec #468

Adamkadaban opened this issue Dec 16, 2023 · 2 comments

Comments

@Adamkadaban
Copy link

I haven't been able to get this working for https://github.com/Pennyw0rth/NetExec

This is what the default output is of running without arguments:
image

Syntax is nxc <protocol> <subargs>

Diff File:

diff --git a/nxc/cli.py b/nxc/cli.py
index 29fd91f8..c815017e 100755
--- a/nxc/cli.py
+++ b/nxc/cli.py
@@ -1,4 +1,5 @@
 import argparse
+import argcomplete
 import sys
 from argparse import RawTextHelpFormatter
 from nxc.loaders.protocolloader import ProtocolLoader
@@ -85,6 +86,7 @@ def gen_cli_args():
         parser.print_help()
         sys.exit(1)
 
+    argcomplete.autocomplete(parser)
     args = parser.parse_args()
 
     if args.version:
diff --git a/pyproject.toml b/pyproject.toml
index ef0f03bd..4ff77a1b 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -65,6 +65,7 @@ resource = "^0.2.1"
 oscrypto = { git = "https://github.com/Pennyw0rth/oscrypto" } # Pypi version currently broken, see: https://github.com/wbond/oscrypto/issues/78 (as of 9/23)
 pyreadline = "^2.1" # for the build - impacket imports its hidden from the builder so an error occurs
 ruff = "=0.0.292"
+argcomplete = "3.2.1"
 
 [tool.poetry.group.dev.dependencies]
 flake8 = "*"
@@ -123,4 +124,4 @@ target-version = "py37"
 [tool.ruff.flake8-quotes]
 docstring-quotes = "double"
 inline-quotes = "double"
-multiline-quotes = "double"
\ No newline at end of file
+multiline-quotes = "double"

I did eval "$(register-python-argcomplete nxc)" and eval "$(register-python-argcomplete netexec)" separately to see if it was an issue with naming.

When I export _ARC_DEBUG, it seems to run the program twice but doesn't parse any of the options.

I think this may be because of the subcategories for the tool (eg. nxc smb and nxc ssh). Is there a way to set up custom parsing for this?

Thanks

@evanunderscore
Copy link
Collaborator

At a glance I would guess this is your problem:

https://github.com/Pennyw0rth/NetExec/blob/ef4f2df92cc553274a09c38fead0030d5018481e/nxc/cli.py#L84-L86

We don't actually invoke your program with arguments, so you'll quit before generating completions. If moving argcomplete.autocomplete(parser) above this doesn't fix your problem, please show the output of attempted tab completion with _ARC_DEBUG=1.

@Adamkadaban
Copy link
Author

Oh wow, that was a simple solution.

Thanks for the help! @evanunderscore

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants