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

Added option to do Session Enumeration as local Admin User #40

Merged
merged 6 commits into from
Oct 30, 2023

Conversation

LuemmelSec
Copy link
Contributor

@LuemmelSec LuemmelSec commented Feb 18, 2023

This is the needed PR to SharpHound that allows to set an option to do session enumeration with a dedicated local (admin) user.
Credits to @eversinc33 how helped me a lot with this.

The situation with more recent pentests and red-team engagements is most likely that you see higher numbers of Windows Server 2016 + as well as Windows 10 1607 +. So the privileged session enumeration via NetWkstaUserEnum needs to be with a user that has local admin rights. Once gaining a foothold or in an assumed breach scenario we will most likely do not have these rights.
But, and that is very common, we do local priv esc on the client, fetch the local admin's credentials, and it happens to be some lame password that is reused accross a large scope of systems - worst case even servers. Same applies to once we get a server's local admin password, and this one is reused.

SharpHound was not able to do this, because it would run the session checks in the context of the user that runs the collector.
What we did was to add 3 new flags:

-DoLocalAdminSessionEnum
-LocalAdminUsername
-LocalAdminPassword

We added a new library (Impersonate.cs ) that allows us to impersonate another remote local user in the current user's context via the LOGON32_PROVIDER_WINNT50 option from the advapi32.dll.
That allows us to wrap the session enumeration stuff inside an impersonated user's context and overcome the limitations mentioned above.
Credits to @phillipharding for this library.

Everything else is done as the running user, so no impact on the rest of what SharpHound is doing.

I created a POC video demonsrating how it works:
https://www.youtube.com/watch?v=mMpNs3MXISM

BloodHound documentation was extended accordingly as well as the SharpHoundCommon project itself. Accordings PRs were opened.
BloodHoundAD/SharpHoundCommon#47
BloodHoundAD/BloodHound#646

@github-actions
Copy link

github-actions bot commented Feb 18, 2023

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

@eversinc33
Copy link
Contributor

I have read the CLA Document and I hereby sign the CLA

@eversinc33
Copy link
Contributor

recheck

@cmprmsd
Copy link

cmprmsd commented Jun 22, 2023

That is very cool and should be merged!

Another feature that would be awesome: Check the local groups especially members of "RDP Users" and "Administrators" or the common name in the localized version. Often you find domain groups in those local groups that Sharphound won't see.
I think that would fit in here as an additional feature.

@JonasBK JonasBK merged commit cba800e into BloodHoundAD:dev Oct 30, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Oct 30, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants