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

Add Secondary localgroup/session BOFs Supported by BOFHound #114

Conversation

Tw1sm
Copy link
Contributor

@Tw1sm Tw1sm commented Jan 29, 2024

External tool BOFHound (now here) has supported parsing ldapsearch results out of C2 logs to produce JSON for BloodHound. This PR adds several secondary versions of existing BOFs that allow parsing of session data and local group memberships from log files. This allows for BloodHound's HasSession, AdminTo and other edges that rely on local group data.

This PR includes secondary versions of the following BOFs (mostly modified for ease of output parsing, but there are some other modifications such as structures returned by API calls):

  • netsession2
  • netloggedon2
  • netLocalGroupListMember2

One "new" BOF to pull sessions from the registry:

  • regsession

I opted for separate secondary BOFs since the changes aren't really upgrades/bugfixes for the original BOFs, and in some cases might clutter the output with data some users don't care for. With that said, if you'd like these changes merged into the original BOFs, I can make the necessary edits. Conversely, if you don't want to accept this PR, I am happy to move these BOFs to their own dedicated repo.

Additional details here: https://posts.specterops.io/bofhound-session-integration-7b88b6f18423

Copy link
Collaborator

@freefirex freefirex left a comment

Choose a reason for hiding this comment

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

Thanks for the pull request!

I found a few items I would like addressed in get-netsession2. Everything else looks good to me 👍

src/SA/get-netsession2/entry.c Outdated Show resolved Hide resolved
src/SA/get-netsession2/entry.c Outdated Show resolved Hide resolved
// DNS cleanup
END:
if(base)
{DNSAPI$DnsFree(base, freetype);}
Copy link
Collaborator

Choose a reason for hiding this comment

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

the value of base is passed by value. This free will never get hit and the value returned in the query_domain call will get leaked. The free for this value needs to be in query_domain

Copy link
Contributor Author

@Tw1sm Tw1sm Feb 1, 2024

Choose a reason for hiding this comment

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

I think I fixed this one, moving the call up to query_domain

src/SA/get-netsession2/entry.c Outdated Show resolved Hide resolved
SA/SA.cna Show resolved Hide resolved
@Tw1sm
Copy link
Contributor Author

Tw1sm commented Feb 1, 2024

@freefirex thank you for providing recommended fixes for the issues - huge help. I think I've made the changes as requested, but if any issues are still lingering, please let me know and I'll take another pass

@freefirex freefirex merged commit fe85ae7 into trustedsec:master Feb 2, 2024
@freefirex
Copy link
Collaborator

Merged, thanks again!

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

Successfully merging this pull request may close these issues.

2 participants