Skip to content

Commit

Permalink
Merge pull request #22 from dschaudel/master
Browse files Browse the repository at this point in the history
Utilizing the Neo4j transactional HTTP endpoint
  • Loading branch information
HarmJ0y authored Aug 10, 2016
2 parents 683c599 + 72d1641 commit f931910
Showing 1 changed file with 11 additions and 16 deletions.
27 changes: 11 additions & 16 deletions PowerShell/BloodHound.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13737,7 +13737,7 @@ function Export-BloodHoundData {
}

$Authorized = $True
$ObjectBuffer = New-Object System.Collections.ArrayList
$Statements = New-Object System.Collections.ArrayList

$UserDomainMappings = @{}
if(-not $SkipGCDeconfliction) {
Expand Down Expand Up @@ -14088,20 +14088,14 @@ function Export-BloodHoundData {
Write-Verbose "No matching type name"
}

# built the batch object submission object for each query
ForEach($Query in $Queries) {
$BatchObject = @{
"method" = "POST";
"to" = "/cypher";
"body" = @{"query"=$Query};
}
$Null = $ObjectBuffer.Add($BatchObject)
$Null = $Statements.Add( @{ "statement"=$Query } )
}

if ($ObjectBuffer.Count -ge $Throttle) {
$JsonRequest = ConvertTo-Json20 $ObjectBuffer
$Null = $WebClient.UploadString($URI.AbsoluteUri + "db/data/batch", $JsonRequest)
$ObjectBuffer.Clear()
if ($Statements.Count -ge $Throttle) {
$Json = @{ "statements"=[System.Collections.Hashtable[]]$Statements }
$JsonRequest = ConvertTo-Json20 $Json
$Null = $WebClient.UploadString($URI.AbsoluteUri + "db/data/transaction/commit", $JsonRequest)
$Statements.Clear()
}
}
else {
Expand All @@ -14110,9 +14104,10 @@ function Export-BloodHoundData {
}
end {
if($Authorized) {
$JsonRequest = ConvertTo-Json20 $ObjectBuffer
$Null = $WebClient.UploadString($URI.AbsoluteUri + "db/data/batch", $JsonRequest)
$ObjectBuffer.Clear()
$Json = @{ "statements"=[System.Collections.Hashtable[]]$Statements }
$JsonRequest = ConvertTo-Json20 $Json
$Null = $WebClient.UploadString($URI.AbsoluteUri + "db/data/transaction/commit", $JsonRequest)
$Statements.Clear()
}
}
}
Expand Down

0 comments on commit f931910

Please sign in to comment.