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

fix mssql_priv #277

Merged
merged 4 commits into from
Apr 27, 2024
Merged

Conversation

sepauli
Copy link
Contributor

@sepauli sepauli commented Apr 26, 2024

Fixing the Issue #273

The privileged user for the impersonation cannot be found, because there is an issue in the "is_admin_user" function.
Due to the try except statement the admin privileges are always wrong, because the if statement cannot be executed

TypeError: int() argument must be a string, a bytes-like object or a real number, not 'list'

I could sucessfully test my changes on the HTB Academy module “Using CrackMapExec” in the task “MSSQL Enumeration and Attacks”

└─$ docker run --privileged --network host netexec-fixed mssql 10.129.204.177 -u robert -p Inlanefreight01! -M mssql_priv -o ACTION=privesc
...
MSSQL       10.129.204.177  1433   DC01             [*] Windows 10 / Server 2019 Build 17763 (name:DC01) (domain:inlanefreight.htb)
MSSQL       10.129.204.177  1433   DC01             [+] inlanefreight.htb\robert:Inlanefreight01!
MSSQL_PRIV                                          [+] INLANEFREIGHT\robert can impersonate: julio (sysadmin)
MSSQL_PRIV                                          [+] INLANEFREIGHT\robert is now a sysadmin! (Pwn3d!)
└─$ docker run --privileged --network host netexec-fixed mssql 10.129.204.177 -u robert -p Inlanefreight01! -x whoami
...
MSSQL       10.129.204.177  1433   DC01             [*] Windows 10 / Server 2019 Build 17763 (name:DC01) (domain:inlanefreight.htb)
MSSQL       10.129.204.177  1433   DC01             [+] inlanefreight.htb\robert:Inlanefreight01! (Pwn3d!)
MSSQL       10.129.204.177  1433   DC01             [+] Executed command via mssqlexec
MSSQL       10.129.204.177  1433   DC01             inlanefreight\svc_mssql

@NeffIsBack
Copy link
Contributor

Very nice! Thanks for the fix

@NeffIsBack NeffIsBack added the bug-fix This Pull Request fixes a bug label Apr 26, 2024
@Marshall-Hallenbeck
Copy link
Collaborator

Sorry I can't test right now (can in 2 days), but I think if the function that saves to res fails it's None, that's why they int'd it before, so if we just reference it it'll KeyError or whatever. I'll have to test it but if someone else can that'd be cool.

@NeffIsBack
Copy link
Contributor

Lol also no one (including me) noticed that the logger in the module is completely broken

@NeffIsBack
Copy link
Contributor

@Marshall-Hallenbeck Looks like thats just an object with "1" or "0" depending on the user being sysadmin or not
image

@NeffIsBack
Copy link
Contributor

fyi, fixed the logger

Copy link
Contributor

@NeffIsBack NeffIsBack left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM
image

@NeffIsBack
Copy link
Contributor

Also fixed the context bug for some other modules like adcs:
image

@Marshall-Hallenbeck Marshall-Hallenbeck merged commit 60db634 into Pennyw0rth:main Apr 27, 2024
5 checks passed
@sepauli sepauli deleted the sepauli/fix-mssql_priv branch April 29, 2024 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug-fix This Pull Request fixes a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants