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

Get-BloodHoundData loops forever when Group contains itself #24

Closed
ktwombley opened this issue Aug 10, 2016 · 5 comments
Closed

Get-BloodHoundData loops forever when Group contains itself #24

ktwombley opened this issue Aug 10, 2016 · 5 comments
Assignees

Comments

@ktwombley
Copy link
Contributor

I was diagnosing an issue where my bloodhound database never grew above a certain size so I changed output to CSV. In the CSV file it became clear that in my AD environment I ended up with a group which contained itself as a member, causing Get-BloodHoundData to churn forever when trying to process that group.

Here is the command I'm running:

$VerbosePreference = "Continue"; Get-BloodHoundData -verbose | Export-BloodHoundCSV -SkipGCDeconfliction -Verbose -CSVFolder .\csv

Checking group_memberships.csv file after some time reveals a pattern:

@HarmJ0y
Copy link
Contributor

HarmJ0y commented Aug 10, 2016

I'm not quite sure what's causing this, as we don't recurse on group memberships themselves. I created a group that's nested within itself and am not able to recreate the infinite loop.

Can you run Get-NetGroup | Get-NetGroupMember manually and see if it still loops?

@HarmJ0y HarmJ0y self-assigned this Aug 10, 2016
@ktwombley
Copy link
Contributor Author

Running that manually does not loop, and the results agree with get-adgroupmember as well;

PS C:\development\Bloodhound\PowerShell> (get-netgroup "BadGroup" | Get-NetGroupMember | measure-object).Count
516

PS C:\development\Bloodhound\PowerShell> (get-adgroupmember BadGroup | measure-object).Count
516

@HarmJ0y
Copy link
Contributor

HarmJ0y commented Aug 10, 2016

Hrmmmm unsure about this as we can't recreate, we'll try to dive a bit deeper.

@ktwombley
Copy link
Contributor Author

ktwombley commented Aug 10, 2016

I don't think this is caused by a group containing itself now that i've stepped through it in the debugger.

Not sure what exactly causes it, but on line 5425 GroupSearcher.FindOne() always returns my "BadGroup" after it sees badgroup the first time. Still debugging on my end.

(my line numbers may be off due to adding write-verbose statements all over)

ktwombley added a commit to ktwombley/BloodHound that referenced this issue Aug 10, 2016
after we have added PropertiesToLoad to $GroupSearcher once, subsequent calls to FindOne() will fail when trying to find the next group. If we still have a $Result, and that $Result contains a property named `member`, the loop will continue using the previous successful search results as though they are the current search results, resulting in reprocessing the previous group.
HarmJ0y added a commit that referenced this issue Aug 11, 2016
@HarmJ0y HarmJ0y mentioned this issue Aug 11, 2016
@HarmJ0y
Copy link
Contributor

HarmJ0y commented Aug 11, 2016

Fixed with ktwombley#1

@HarmJ0y HarmJ0y closed this as completed Aug 11, 2016
porterhau5 pushed a commit to porterhau5/BloodHound that referenced this issue Oct 22, 2017
after we have added PropertiesToLoad to $GroupSearcher once, subsequent calls to FindOne() will fail when trying to find the next group. If we still have a $Result, and that $Result contains a property named `member`, the loop will continue using the previous successful search results as though they are the current search results, resulting in reprocessing the previous group.
porterhau5 pushed a commit to porterhau5/BloodHound that referenced this issue Oct 22, 2017
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

No branches or pull requests

2 participants