Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
- name: Build
run: |
VERSION=${{ github.ref_name }}
dotnet build -c ${{ matrix.release.type }} -p:Version=${VERSION:1} -p:CommonLibSource=Release
dotnet build -c ${{ matrix.release.type }} -p:Version=${VERSION:1} -p:CommonSource=Stable

- name: Zip
run: 7z a -tzip -mx9 SharpHound_${{ github.ref_name }}${{ matrix.release.suffix }}_windows_x86.zip $PWD/bin/${{ matrix.release.type }}/net472/*
Expand Down
31 changes: 24 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,37 @@ To determine the SharpHound version compatible with a deployed BloodHound CE ins

Please refer to the [SharpHound section](https://bloodhound.specterops.io/collect-data/ce-collection/sharphound), part of the [BloodHound Community Edition documentation](https://bloodhound.specterops.io/home).

## Compile Instructions
## Compilation Instructions

To build this project, use .net 5.0 and run the following:
To build this project, using a .NET SDK run the following:

```
dotnet restore .
```bash
dotnet restore
dotnet build
```

By default, the project will build with the latest version of the [SharpHoundCommon Library](https://github.com/SpecterOps/SharpHoundCommon).
By default, the project builds against the next prerelease `-dev` version of the
[SharpHoundCommon Library](https://github.com/SpecterOps/SharpHoundCommon)
(tracking the v4 branch).

If you wish to build against a local copy of the library, ensure the `_CommonLibPath` and `_RPCPath` properties point to the correct DLLs, and run `dotnet build -p:CommonSource=Local`.

If `CommonLibsVersion` already contains a prerelease tag (e.g. `4.6.0-rc1`),
that exact version is used as-is for both `Stable` and `Dev` sources.

To build against the latest stable release of the library, you can run `dotnet build -p:CommonLibSource=Stable`.
| `CommonSource` (default: `Dev`) | Package resolved |
|---------------------------------|-----------------------------------------------------------------------------|
| `Dev` | Prerelease (e.g. `4.6.0-rc1`) or next patch `-dev*` (e.g. `4.6.1-dev*`) |
| `Stable` | Current CommonLibsVersion (e.g. `4.6.0`) |
| `Local` | Local `SharpHoundCommon` DLLs |
Comment thread
lrfalslev marked this conversation as resolved.

```bash
dotnet build # Dev (default)
dotnet build -p:CommonSource=Stable
dotnet build -p:CommonSource=Local
dotnet build --tl:off # To view CommonLib resolution logs
```

If you wish to build against a local copy of the library, ensure the `CommonLibPath` and `RPCPath` properties point to the correct DLLs, and run `dotnet build -p:CommonLibSource=Local`.

## Requirements

Expand Down
76 changes: 40 additions & 36 deletions Sharphound.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,50 @@
</PropertyGroup>

<PropertyGroup>
<CommonLibsStableVersion>4.6.1</CommonLibsStableVersion>
<CommonLibsReleaseVersion>4.6.1</CommonLibsReleaseVersion>
<CommonLibPath>..\SharpHoundCommon\src\CommonLib\bin\$(Configuration)\net472\SharpHoundCommonLib.dll</CommonLibPath>
<RPCPath>..\SharpHoundCommon\src\SharpHoundRPC\bin\$(Configuration)\net472\SharpHoundRPC.dll</RPCPath>

<!-- Derive the dev version by incrementing the patch of the stable version, mirroring
the auto-increment logic in SharpHoundCommon's publish-dev-package pipeline.
e.g. stable=4.6.0 → dev wildcard=4.6.1-dev* -->
<_StablePatch>$([System.Text.RegularExpressions.Regex]::Match($(CommonLibsStableVersion), '[0-9]+$').Value)</_StablePatch>
<_MajorMinor>$([System.Text.RegularExpressions.Regex]::Match($(CommonLibsStableVersion), '^[0-9]+\.[0-9]+').Value)</_MajorMinor>
<CommonLibsDevVersion>$(_MajorMinor).$([MSBuild]::Add($(_StablePatch), 1))-dev*</CommonLibsDevVersion>

<CommonLibsVersion>4.6.1</CommonLibsVersion>
<CommonSource>Dev</CommonSource>
<_CommonSource>$(CommonSource.ToLower())</_CommonSource>
<_CommonLibPath>..\SharpHoundCommon\src\CommonLib\bin\$(Configuration)\net472\SharpHoundCommonLib.dll</_CommonLibPath>
<_RPCPath>..\SharpHoundCommon\src\SharpHoundRPC\bin\$(Configuration)\net472\SharpHoundRPC.dll</_RPCPath>
</PropertyGroup>

<!-- Determine if we should use local DLLs -->
<_UseLocalLibs Condition="'$(CommonSource.ToLower())' == 'local'">true</_UseLocalLibs>
<_UseLocalLibs Condition="'$(_UseLocalLibs)' == ''">false</_UseLocalLibs>
<Target Name="ValidateCommonSource" BeforeTargets="Build">
<Error Condition="'$(_CommonSource)' != 'dev' AND '$(_CommonSource)' != 'stable' AND '$(_CommonSource)' != 'local'"
Text="Invalid CommonSource value '$(CommonSource)'. Valid values are: Dev, Stable, Local." />
</Target>

<PropertyGroup Condition="'$(_CommonSource)' == 'dev' AND !$(CommonLibsVersion.Contains('-'))">
Comment thread
mykeelium marked this conversation as resolved.
<!-- Derive the dev version by incrementing the patch of the stable version e.g. 4.6.0 → 4.6.1-dev* -->
<_Major>$([System.Version]::Parse('$(CommonLibsVersion)').Major)</_Major>
<_Minor>$([System.Version]::Parse('$(CommonLibsVersion)').Minor)</_Minor>
<_Patch>$([System.Version]::Parse('$(CommonLibsVersion)').Build)</_Patch>
<_DevVersion>$(_Major).$(_Minor).$([MSBuild]::Add($(_Patch), 1))-dev*</_DevVersion>
</PropertyGroup>

<!-- Determine the package version -->
<_CommonLibsVersion Condition="'$(CommonSource.ToLower())' == 'stable'">$(CommonLibsStableVersion)</_CommonLibsVersion>
<_CommonLibsVersion Condition="'$(CommonSource.ToLower())' == 'release'">$(CommonLibsReleaseVersion)</_CommonLibsVersion>
<_CommonLibsVersion Condition="'$(_CommonLibsVersion)' == ''">$(CommonLibsDevVersion)</_CommonLibsVersion>
<PropertyGroup Condition="'$(_CommonSource)' != 'local'">
<_ResolvedCommonVersion Condition="$(CommonLibsVersion.Contains('-'))">$(CommonLibsVersion)</_ResolvedCommonVersion>
<_ResolvedCommonVersion Condition="'$(_ResolvedCommonVersion)' == '' AND '$(_CommonSource)' == 'dev'">$(_DevVersion)</_ResolvedCommonVersion>
<_ResolvedCommonVersion Condition="'$(_ResolvedCommonVersion)' == ''">$(CommonLibsVersion)</_ResolvedCommonVersion>
</PropertyGroup>

<ItemGroup Condition="'$(_CommonSource)' == 'local'">
<Reference Include="SharpHoundCommonLib">
<HintPath>$(_CommonLibPath)</HintPath>
</Reference>
<Reference Include="SharpHoundRPC">
<HintPath>$(_RPCPath)</HintPath>
</Reference>
</ItemGroup>
<ItemGroup Condition="'$(_CommonSource)' != 'local'">
<PackageReference Include="SharpHoundCommon" Version="$(_ResolvedCommonVersion)" />
<PackageReference Include="SharpHoundRPC" Version="$(_ResolvedCommonVersion)" />
</ItemGroup>

<Target Name="LogCommonLibsSource" BeforeTargets="Build">
<Message Text='CommonLib Source "$(CommonSource)":' Importance="high" />
<Message Condition="'$(_CommonSource)' == 'local'" Text=" Resolved Using Local DLLs" Importance="high" />
<Message Condition="'$(_CommonSource)' != 'local'" Text=" Resolved to NuGet Version: $(_ResolvedCommonVersion)" Importance="high" />
</Target>

<ItemGroup>
<PackageReference Include="CommandLineParser" Version="2.8.0" />
Expand All @@ -55,18 +76,6 @@
<PackageReference Include="System.Threading.Channels" Version="8.0.0" />
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
</ItemGroup>
<ItemGroup Condition="'$(_UseLocalLibs)' == 'true'">
<Reference Include="SharpHoundCommonLib">
<HintPath>$(CommonLibPath)</HintPath>
</Reference>
<Reference Include="SharpHoundRPC">
<HintPath>$(RPCPath)</HintPath>
</Reference>
</ItemGroup>
<ItemGroup Condition="'$(_UseLocalLibs)' != 'true'">
<PackageReference Include="SharpHoundCommon" Version="$(_CommonLibsVersion)" />
<PackageReference Include="SharpHoundRPC" Version="$(_CommonLibsVersion)" />
</ItemGroup>
<ItemGroup>
<Reference Include="System.DirectoryServices" />
<Reference Include="System.DirectoryServices.Protocols" />
Expand All @@ -76,9 +85,4 @@
<Message Text="Test" />
<Exec Command="powershell -ep bypass -c &quot;. '$(ProjectDir)src\Powershell\Out-CompressedDLL.ps1';Out-CompressedDll -FilePath '$(TargetPath)' -TemplatePath '$(ProjectDir)src\\Powershell\Template.ps1' | Out-File -Encoding ASCII '$(TargetDir)$(TargetName).ps1'&quot;" />
</Target>
<Target Name="LogCommonLibsVersion" BeforeTargets="Build">
<Message Text="Loading CommonLib Dependency:" Importance="high" />
<Message Condition="'$(_UseLocalLibs)' == 'true'" Text=" Using Local DLLs" Importance="high" />
<Message Condition="'$(_UseLocalLibs)' == 'false'" Text=" Package Version: $(_CommonLibsVersion)" Importance="high" />
</Target>
</Project>
Loading