Add oleexec, clrexec, jobexec and assembly execution fileless for MSSQL#1268
Open
Dfte wants to merge 11 commits into
Open
Add oleexec, clrexec, jobexec and assembly execution fileless for MSSQL#1268Dfte wants to merge 11 commits into
Dfte wants to merge 11 commits into
Conversation
Dfte
requested review from
Marshall-Hallenbeck,
NeffIsBack,
mpgn and
zblurx
as code owners
June 4, 2026 14:42
Contributor
Author
Contributor
Author
|
Last commit patches the --lsa and --sam functions so that they work as intended with the modifications I applied. Both functions look like: @requires_admin
def put_file(self, download_path=None, remote_path=None):
if remote_path is None and download_path is None:
download_path = self.args.put_file[0]
remote_path = self.args.put_file[1]Which allows calling the function as a method filling remote and local path. Or via the command line from self.args. |
14 tasks
Contributor
Author
Dfte
marked this pull request as draft
June 8, 2026 09:29
Dfte
marked this pull request as ready for review
June 8, 2026 10:55
added 2 commits
July 9, 2026 17:13
…unning and with which service account
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.



Description
This PR adds two new exec methods for the MSSQL protocol:
As such, I have added the --exec-method {mssqlexec, oleexec, crlexec} mechanism as well.
Concerning the CRL exec method, it relies on an assembly which is a binary file that is sent as hexadecimal to the SQL server and used to run the command. This file is located in NXC_DATA/mssql_clr and the corresponding C# code is the following:
If using the --exec-method crlexec, it is possible to use a custom assembly specifying the --clr-assembly PATH_TO_ASSEMBLY. In that case the -x "COMMAND" is not used at all and the CLR assembly is executed.
Note that this PR is work in progress. Indeed, there are few issues:
I know it sucks but for the moment, and considering how -x and -X are designed, it's not really possible to do much better.
Type of change
Insert an "x" inside the brackets for relevant items (do not delete options)
Setup guide for the review
Nothing to setup, it works on default MSSQL server.
Screenshots (if appropriate):
Notice that -x doesn't have any COMMAND, that's because I had to modify proto_args.
Checklist:
Insert an "x" inside the brackets for completed and relevant items (do not delete options)
poetry run ruff check ., use--fixto automatically fix what it can)tests/e2e_commands.txtfile if necessary (new modules or features are required to be added to the e2e tests)IMPORTANT
I honestly believe we can simplify the way we execute commands. Knowing that most -X command exec rely on cmd /c powershell COMMAND, is absurd to me. Question is whether we are keen modifying that part (which is a huge change) or hack protocols so that we can use more advanced protocol capabilities like the CRL on MSSQL for example. Let me know what you guys think :)