-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #36 from BloodHoundAD/NewNodes
feat: Add collection of several new node types
- Loading branch information
Showing
38 changed files
with
2,182 additions
and
152 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
// Copyright (C) 2022 Specter Ops, Inc. | ||
// | ||
// This file is part of AzureHound. | ||
// | ||
// AzureHound is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// AzureHound is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
package client | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"net/url" | ||
|
||
"github.com/bloodhoundad/azurehound/client/query" | ||
"github.com/bloodhoundad/azurehound/client/rest" | ||
"github.com/bloodhoundad/azurehound/models/azure" | ||
) | ||
|
||
func (s *azureClient) GetAzureContainerRegistry(ctx context.Context, subscriptionId, groupName, crName, expand string) (*azure.ContainerRegistry, error) { | ||
var ( | ||
path = fmt.Sprintf("/subscriptions/%s/resourceGroups/%s/providers/Microsoft.ContainerRegistry/registries/%s", subscriptionId, groupName, crName) | ||
params = query.Params{ApiVersion: "2023-01-01-preview", Expand: expand}.AsMap() | ||
headers map[string]string | ||
response azure.ContainerRegistry | ||
) | ||
if res, err := s.resourceManager.Get(ctx, path, params, headers); err != nil { | ||
return nil, err | ||
} else if err := rest.Decode(res.Body, &response); err != nil { | ||
return nil, err | ||
} else { | ||
return &response, nil | ||
} | ||
} | ||
|
||
func (s *azureClient) GetAzureContainerRegistries(ctx context.Context, subscriptionId string) (azure.ContainerRegistryList, error) { | ||
var ( | ||
path = fmt.Sprintf("/subscriptions/%s/providers/Microsoft.ContainerRegistry/registries", subscriptionId) | ||
params = query.Params{ApiVersion: "2023-01-01-preview"}.AsMap() | ||
headers map[string]string | ||
response azure.ContainerRegistryList | ||
) | ||
|
||
if res, err := s.resourceManager.Get(ctx, path, params, headers); err != nil { | ||
return response, err | ||
} else if err := rest.Decode(res.Body, &response); err != nil { | ||
return response, err | ||
} else { | ||
return response, nil | ||
} | ||
} | ||
|
||
func (s *azureClient) ListAzureContainerRegistries(ctx context.Context, subscriptionId string) <-chan azure.ContainerRegistryResult { | ||
out := make(chan azure.ContainerRegistryResult) | ||
|
||
go func() { | ||
defer close(out) | ||
|
||
var ( | ||
errResult = azure.ContainerRegistryResult{ | ||
SubscriptionId: subscriptionId, | ||
} | ||
nextLink string | ||
) | ||
|
||
if result, err := s.GetAzureContainerRegistries(ctx, subscriptionId); err != nil { | ||
errResult.Error = err | ||
out <- errResult | ||
} else { | ||
for _, u := range result.Value { | ||
out <- azure.ContainerRegistryResult{SubscriptionId: subscriptionId, Ok: u} | ||
} | ||
|
||
nextLink = result.NextLink | ||
for nextLink != "" { | ||
var list azure.ContainerRegistryList | ||
if url, err := url.Parse(nextLink); err != nil { | ||
errResult.Error = err | ||
out <- errResult | ||
nextLink = "" | ||
} else if req, err := rest.NewRequest(ctx, "GET", url, nil, nil, nil); err != nil { | ||
errResult.Error = err | ||
out <- errResult | ||
nextLink = "" | ||
} else if res, err := s.resourceManager.Send(req); err != nil { | ||
errResult.Error = err | ||
out <- errResult | ||
nextLink = "" | ||
} else if err := rest.Decode(res.Body, &list); err != nil { | ||
errResult.Error = err | ||
out <- errResult | ||
nextLink = "" | ||
} else { | ||
for _, u := range list.Value { | ||
out <- azure.ContainerRegistryResult{ | ||
SubscriptionId: "/subscriptions/" + subscriptionId, | ||
Ok: u, | ||
} | ||
} | ||
nextLink = list.NextLink | ||
} | ||
} | ||
} | ||
}() | ||
return out | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
// Copyright (C) 2022 Specter Ops, Inc. | ||
// | ||
// This file is part of AzureHound. | ||
// | ||
// AzureHound is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// AzureHound is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
package client | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"net/url" | ||
|
||
"github.com/bloodhoundad/azurehound/client/query" | ||
"github.com/bloodhoundad/azurehound/client/rest" | ||
"github.com/bloodhoundad/azurehound/models/azure" | ||
) | ||
|
||
func (s *azureClient) GetAzureManagedCluster(ctx context.Context, subscriptionId, groupName, mcName, expand string) (*azure.ManagedCluster, error) { | ||
var ( | ||
path = fmt.Sprintf("/subscriptions/%s/resourceGroups/%s/providers/Microsoft.ContainerService/managedClusters/%s", subscriptionId, groupName, mcName) | ||
params = query.Params{ApiVersion: "2021-07-01", Expand: expand}.AsMap() | ||
headers map[string]string | ||
response azure.ManagedCluster | ||
) | ||
if res, err := s.resourceManager.Get(ctx, path, params, headers); err != nil { | ||
return nil, err | ||
} else if err := rest.Decode(res.Body, &response); err != nil { | ||
return nil, err | ||
} else { | ||
return &response, nil | ||
} | ||
} | ||
|
||
func (s *azureClient) GetAzureManagedClusters(ctx context.Context, subscriptionId string, statusOnly bool) (azure.ManagedClusterList, error) { | ||
var ( | ||
path = fmt.Sprintf("/subscriptions/%s/providers/Microsoft.ContainerService/managedClusters", subscriptionId) | ||
params = query.Params{ApiVersion: "2021-07-01", StatusOnly: statusOnly}.AsMap() | ||
headers map[string]string | ||
response azure.ManagedClusterList | ||
) | ||
|
||
if res, err := s.resourceManager.Get(ctx, path, params, headers); err != nil { | ||
return response, err | ||
} else if err := rest.Decode(res.Body, &response); err != nil { | ||
return response, err | ||
} else { | ||
return response, nil | ||
} | ||
} | ||
|
||
func (s *azureClient) ListAzureManagedClusters(ctx context.Context, subscriptionId string, statusOnly bool) <-chan azure.ManagedClusterResult { | ||
out := make(chan azure.ManagedClusterResult) | ||
|
||
go func() { | ||
defer close(out) | ||
|
||
var ( | ||
errResult = azure.ManagedClusterResult{ | ||
SubscriptionId: subscriptionId, | ||
} | ||
nextLink string | ||
) | ||
|
||
if result, err := s.GetAzureManagedClusters(ctx, subscriptionId, statusOnly); err != nil { | ||
errResult.Error = err | ||
out <- errResult | ||
} else { | ||
for _, u := range result.Value { | ||
out <- azure.ManagedClusterResult{SubscriptionId: subscriptionId, Ok: u} | ||
} | ||
|
||
nextLink = result.NextLink | ||
for nextLink != "" { | ||
var list azure.ManagedClusterList | ||
if url, err := url.Parse(nextLink); err != nil { | ||
errResult.Error = err | ||
out <- errResult | ||
nextLink = "" | ||
} else if req, err := rest.NewRequest(ctx, "GET", url, nil, nil, nil); err != nil { | ||
errResult.Error = err | ||
out <- errResult | ||
nextLink = "" | ||
} else if res, err := s.resourceManager.Send(req); err != nil { | ||
errResult.Error = err | ||
out <- errResult | ||
nextLink = "" | ||
} else if err := rest.Decode(res.Body, &list); err != nil { | ||
errResult.Error = err | ||
out <- errResult | ||
nextLink = "" | ||
} else { | ||
for _, u := range list.Value { | ||
out <- azure.ManagedClusterResult{ | ||
SubscriptionId: "/subscriptions/" + subscriptionId, | ||
Ok: u, | ||
} | ||
} | ||
nextLink = list.NextLink | ||
} | ||
} | ||
} | ||
}() | ||
return out | ||
} |
Oops, something went wrong.