Skip to content

Commit 2553fd3

Browse files
authored
Merge branch 'v4' into BED-7724
2 parents 8eb6596 + 73ecc6c commit 2553fd3

9 files changed

Lines changed: 244 additions & 85 deletions

File tree

.github/pull_request_template.md

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,40 @@
11
## Description
2-
3-
<!--- Describe your changes in detail -->
2+
<!-- Describe your changes in detail -->
43

54
## Motivation and Context
5+
<!-- Why is this change required? What problem does it solve? -->
66

7-
<!--- Why is this change required? What problem does it solve? -->
8-
<!--- If it fixes an open issue, please link to the issue here. -->
7+
This PR addresses: [GitHub issue or Jira ticket number]
98

109
## How Has This Been Tested?
11-
12-
<!--- Please describe in detail how you tested your changes. -->
13-
<!--- Include details of your testing environment, and the tests you ran to -->
14-
<!--- see how your change affects other areas of the code, etc. -->
10+
<!--
11+
Please describe in detail how you tested your changes.
12+
Include details of your testing environment, and the tests you ran to
13+
see how your change affects other areas of the code, etc.*
14+
-->
1515

1616
## Screenshots (if appropriate):
1717

1818
## Types of changes
19+
<!-- What types of changes does your code introduce? Put an `x` in all the boxes that apply: -->
1920

20-
<!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: -->
21-
22-
- [ ] Chore (a change that does not modify the application functionality)
23-
- [ ] Bug fix (non-breaking change which fixes an issue)
24-
- [ ] New feature (non-breaking change which adds functionality)
25-
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
21+
- [ ] Chore (a change that does not modify the application functionality)
22+
- [ ] Bug fix (non-breaking change which fixes an issue)
23+
- [ ] New feature (non-breaking change which adds functionality)
24+
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
2625

2726
## Checklist:
28-
29-
<!--- Go over all the following points, and put an `x` in all the boxes that apply. -->
30-
<!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->
31-
32-
- [ ] Documentation updates are needed, and have been made accordingly.
33-
- [ ] I have added and/or updated tests to cover my changes.
34-
- [ ] All new and existing tests passed.
35-
- [ ] My changes include a database migration.
27+
<!-- Please make sure you have completed all following checks. -->
28+
<!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->
29+
30+
- [ ] I have met the contributing prerequisites
31+
- Assigned myself to this PR
32+
- Added the appropriate labels
33+
- Associated an issue: https://github.com/SpecterOps/BloodHound/issues/672
34+
- Read the Contributing guide: https://github.com/SpecterOps/BloodHound/wiki/Contributing
35+
- [ ] I have ensured that related documentation is up-to-date
36+
- Open API docs
37+
- Code comments
38+
- [ ] I have followed proper test practices
39+
- Added/updated tests to cover my changes
40+
- All new and existing tests passed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Build and Test
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- v4
7+
8+
jobs:
9+
build-and-test:
10+
runs-on: windows-latest
11+
steps:
12+
- name: Checkout repository
13+
uses: actions/checkout@v6
14+
15+
- name: Setup .NET
16+
uses: actions/setup-dotnet@v5
17+
with:
18+
dotnet-version: 8.0.x
19+
20+
- name: Restore dependencies
21+
run: dotnet restore
22+
23+
- name: Build
24+
run: dotnet build --no-restore
25+
26+
- name: Test
27+
run: dotnet test --no-build

.github/workflows/build.yml

Lines changed: 0 additions & 25 deletions
This file was deleted.
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
name: Publish Dev Package
2+
3+
on:
4+
push:
5+
branches:
6+
- "v4"
7+
8+
jobs:
9+
update-dev-package:
10+
name: update-dev-package
11+
runs-on: windows-latest
12+
steps:
13+
- name: Checkout repository
14+
uses: actions/checkout@v6
15+
16+
- name: Setup .NET
17+
uses: actions/setup-dotnet@v5
18+
with:
19+
dotnet-version: 8.0.x
20+
21+
- name: Compute dev version
22+
id: version
23+
shell: pwsh
24+
run: |
25+
$base_version = dotnet msbuild Directory.Build.props --getProperty:Version
26+
$parts = $base_version.Split('.')
27+
$parts[2] = [int]$parts[2] + 1
28+
$next_version = $parts -join '.'
29+
$date_stamp = Get-Date -Format 'yyyyMMddHHmm'
30+
"dev_version=$next_version-dev.$date_stamp" >> $env:GITHUB_OUTPUT
31+
32+
- name: Restore dependencies
33+
run: dotnet restore
34+
35+
- name: Pack
36+
run: |
37+
mkdir pkgs
38+
dotnet pack --no-restore -c Release -p:PackageVersion=${{ steps.version.outputs.dev_version }} -o ./pkgs
39+
40+
- name: Publish to SpecterOps Packages
41+
env:
42+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY }}
43+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_KEY }}
44+
run: |
45+
dotnet tool install -g sleet
46+
sleet push ./pkgs
47+
48+
#the prune command deletes older -dev package versions to avoid clutter
49+
#it deletes any versions of the $packageIds with "-dev" that are older than the first $maxDevVersions
50+
#set $dryRun to true for debugging without deleting any packages
51+
- name: Prune old -dev packages
52+
env:
53+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY }}
54+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_KEY }}
55+
shell: pwsh
56+
run: |
57+
$dryRun = $false
58+
$packageIndexUrl = 'https://s3.amazonaws.com/bloodhound-ad/sleet.packageindex.json'
59+
$packageIds = @('SharpHoundCommon', 'SharpHoundRPC')
60+
$maxDevVersions = 5
61+
62+
$packageIndex = Invoke-RestMethod -Uri $packageIndexUrl
63+
64+
foreach ($packageId in $packageIds) {
65+
#get all -dev packages sorted by descending versions
66+
$devPackages = @(
67+
foreach ($version in ($packageIndex.packages.$packageId | Where-Object { $_ -like '*-dev.*' })) {
68+
try {
69+
[pscustomobject]@{
70+
PackageId = $packageId
71+
Version = $version
72+
SemVer = [System.Management.Automation.SemanticVersion]$version
73+
}
74+
} catch {
75+
Write-Warning "Skipping unparseable version: $packageId $version"
76+
}
77+
}
78+
) | Sort-Object SemVer -Descending
79+
80+
Write-Host "($($devPackages.Length)) $packageId -dev versions in feed:"
81+
$devPackages | Format-Table -AutoSize
82+
83+
Write-Host "Beginning prune:"
84+
85+
#skip $maxDevVersions and delete remaining -dev packages
86+
$devPackages | Select-Object -Skip $maxDevVersions | ForEach-Object {
87+
if ($dryRun) {
88+
Write-Host "[DRY RUN] sleet delete --id $($_.PackageId) --version $($_.Version)"
89+
}
90+
else {
91+
sleet delete --id $_.PackageId --version $_.Version --reason "Prune old dev build"
92+
}
93+
}
94+
}

Directory.Build.props

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
11
<Project>
2+
<PropertyGroup>
3+
<TargetFramework>net472</TargetFramework>
4+
<OutputType>library</OutputType>
5+
<LangVersion>default</LangVersion>
6+
<Authors>Rohan Vazarkar</Authors>
7+
<Company>SpecterOps</Company>
8+
<PackageLicenseExpression>GPL-3.0-only</PackageLicenseExpression>
9+
<RepositoryUrl>https://github.com/SpecterOps/SharpHoundCommon</RepositoryUrl>
10+
<Version>4.6.0</Version>
11+
</PropertyGroup>
212
<ItemGroup>
313
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
414
<_Parameter1>CommonLibTest</_Parameter1>

src/CommonLib/README.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# SharpHoundCommon
2+
3+
SharpHoundCommon provides the high-level shared components used to build AD enumeration workflows. It includes initialization, caching, LDAP helpers, host and service processors, and registry and user-rights collection logic used by SharpHound collectors.
4+
5+
## When to use this package
6+
7+
Use `SharpHoundCommon` if you are building a collector or integration that needs higher-level enumeration behavior. This is the package most consumers should start with.
8+
9+
## Requirements
10+
11+
- .NET Framework 4.7.2
12+
- Windows and Active Directory oriented workloads
13+
14+
## Install
15+
16+
```powershell
17+
dotnet add package SharpHoundCommon
18+
```
19+
20+
## Getting started
21+
22+
```csharp
23+
using SharpHoundCommonLib;
24+
25+
CommonLib.InitializeCommonLib();
26+
```
27+
28+
You may optionally provide an `ILogger` and a pre-created `Cache` instance to `CommonLib.InitializeCommonLib(...)`.
29+
30+
## Included capabilities
31+
32+
- Shared initialization and cache management via `CommonLib` and `Cache`
33+
- LDAP querying and identity resolution via `LdapUtils`
34+
- Host availability, SMB, and LDAP service checks via `ComputerAvailability`, `SmbProcessor`, and `DCLdapProcessor`
35+
- Registry collection orchestration via `RegistryProcessor`
36+
- User rights, SPN, and certificate-related processing helpers
37+
38+
## Relationship to SharpHoundRPC
39+
40+
`SharpHoundCommon` depends on `SharpHoundRPC` and is intended to be the higher-level entry point. Most consumers should not reference `SharpHoundRPC` directly unless they need its lower-level SAM, LSA, NetAPI, or registry APIs.
41+
42+
## Source and support
43+
44+
- Source: https://github.com/SpecterOps/SharpHoundCommon
45+
- Issues: https://github.com/SpecterOps/SharpHoundCommon/issues
46+
- License: GPL-3.0-only
Lines changed: 4 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFramework>net472</TargetFramework>
4-
<OutputType>library</OutputType>
53
<PackageId>SharpHoundCommon</PackageId>
6-
<LangVersion>default</LangVersion>
7-
<Authors>Rohan Vazarkar</Authors>
8-
<Company>SpecterOps</Company>
94
<PackageDescription>Common library for C# BloodHound enumeration tasks</PackageDescription>
10-
<PackageLicenseExpression>GPL-3.0-only</PackageLicenseExpression>
11-
<RepositoryUrl>https://github.com/BloodHoundAD/SharpHoundCommon</RepositoryUrl>
12-
<Version>4.6.0</Version>
5+
<PackageReadmeFile>README.md</PackageReadmeFile>
136
<AssemblyName>SharpHoundCommonLib</AssemblyName>
147
<RootNamespace>SharpHoundCommonLib</RootNamespace>
8+
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
159
</PropertyGroup>
1610
<PropertyGroup>
1711
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
@@ -29,28 +23,9 @@
2923
<Reference Include="System.Net.Http" />
3024
</ItemGroup>
3125
<ItemGroup>
32-
<Folder Include="Properties" />
26+
<ProjectReference Include="..\SharpHoundRPC\SharpHoundRPC.csproj" />
3327
</ItemGroup>
3428
<ItemGroup>
35-
<ProjectReference Include="..\SharpHoundRPC\SharpHoundRPC.csproj" PrivateAssets="All" />
29+
<None Include="README.md" Pack="true" PackagePath="" />
3630
</ItemGroup>
37-
<PropertyGroup>
38-
<TargetsForTfmSpecificBuildOutput>
39-
$(TargetsForTfmSpecificBuildOutput);CopyProjectReferencesToPackage</TargetsForTfmSpecificBuildOutput>
40-
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
41-
</PropertyGroup>
42-
<Target Name="CopyProjectReferencesToPackage" DependsOnTargets="BuildOnlySettings;ResolveReferences">
43-
<ItemGroup>
44-
<!-- Filter out unnecessary files -->
45-
<_ReferenceCopyLocalPaths Include="@(ReferenceCopyLocalPaths-&gt;WithMetadataValue('ReferenceSourceTarget', 'ProjectReference')-&gt;WithMetadataValue('PrivateAssets', 'All'))" />
46-
</ItemGroup>
47-
48-
<!-- Print batches for debug purposes -->
49-
<Message Text="Batch for .nupkg: ReferenceCopyLocalPaths = @(_ReferenceCopyLocalPaths), ReferenceCopyLocalPaths.DestinationSubDirectory = %(_ReferenceCopyLocalPaths.DestinationSubDirectory) Filename = %(_ReferenceCopyLocalPaths.Filename) Extension = %(_ReferenceCopyLocalPaths.Extension)" Importance="High" Condition="'@(_ReferenceCopyLocalPaths)' != ''" />
50-
51-
<ItemGroup>
52-
<!-- Add file to package with consideration of sub folder. If empty, the root folder is chosen. -->
53-
<BuildOutputInPackage Include="@(_ReferenceCopyLocalPaths)" TargetPath="%(_ReferenceCopyLocalPaths.DestinationSubDirectory)" />
54-
</ItemGroup>
55-
</Target>
5631
</Project>

src/SharpHoundRPC/README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# SharpHoundRPC
2+
3+
SharpHoundRPC exposes low-level Windows RPC, Win32, and remote collection helpers used by SharpHoundCommon and SharpHound collectors. It wraps SAM, LSA, NetAPI, and remote registry operations behind C# interfaces and result types.
4+
5+
## When to use this package
6+
7+
Use `SharpHoundRPC` directly only if you need low-level RPC or interop access. If you want higher-level enumeration workflows, install `SharpHoundCommon` instead.
8+
9+
## Requirements
10+
11+
- .NET Framework 4.7.2
12+
- Windows-focused functionality
13+
- Appropriate privileges, network reachability, and RPC availability on target systems
14+
15+
## Install
16+
17+
```powershell
18+
dotnet add package SharpHoundRPC
19+
```
20+
21+
## Included capabilities
22+
23+
- SAM access through `ISAMServer`, `ISAMDomain`, `SAMServerAccessor`, and related wrappers
24+
- LSA policy access via `LSAPolicy` for SID lookup and privilege enumeration
25+
- NetAPI helpers for sessions, workstation information, and domain controller discovery
26+
- Remote registry strategies using WMI or Remote Registry
27+
- Shared `Result<T>` and related helper types for error handling
28+
29+
## Source and support
30+
31+
- Source: https://github.com/SpecterOps/SharpHoundCommon
32+
- Issues: https://github.com/SpecterOps/SharpHoundCommon/issues
33+
- License: GPL-3.0-only
Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFramework>net472</TargetFramework>
4-
<OutputType>library</OutputType>
53
<PackageId>SharpHoundRPC</PackageId>
6-
<LangVersion>default</LangVersion>
7-
<Authors>Rohan Vazarkar</Authors>
8-
<Company>SpecterOps</Company>
94
<PackageDescription>SAM/LSA Wrapper for C# BloodHound tasks</PackageDescription>
10-
<PackageLicenseExpression>GPL-3.0-only</PackageLicenseExpression>
11-
<Version>4.6.0</Version>
5+
<PackageReadmeFile>README.md</PackageReadmeFile>
126
<AssemblyName>SharpHoundRPC</AssemblyName>
137
<RootNamespace>SharpHoundRPC</RootNamespace>
148
</PropertyGroup>
@@ -20,9 +14,9 @@
2014
<PackageReference Include="System.ValueTuple" Version="4.5.0"/>
2115
</ItemGroup>
2216
<ItemGroup>
23-
<Folder Include="Properties"/>
17+
<Reference Include="System.Management" />
2418
</ItemGroup>
2519
<ItemGroup>
26-
<Reference Include="System.Management" />
20+
<None Include="README.md" Pack="true" PackagePath="" />
2721
</ItemGroup>
2822
</Project>

0 commit comments

Comments
 (0)