Bugfix : exec-method specified in module file is not used #438
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello,
I noticed a bug when using
connection.execute(command, True, methods=[XXX])
in module files.The specified methods get ignored and are overwritten by the default argument (from proto_args.py).
My specific case is :
When using an SMB module specifying the exec method (impersonate and pi for example), nxc doesn't use smbexec as specified in the code but wmiexec (because it's the default value of
--exec-method
).This is because of this code :
https://github.com/Pennyw0rth/NetExec/blob/c1780a1a26eb000105f9d2818f821262b5955e84/nxc/protocols/smb.py#L622C1-L623C46
self.args.exec_method
is indeed never None because set to the default value wmiexec.I wrote a fix for SMB using a new action registering if arguments are explicitly set or not.
This may not be the best way to fix it.