FSecureLABS / SharpGPOAbuse

SharpGPOAbuse is a .NET application written in C# that can be used to take advantage of a user's edit rights on a Group Policy Object (GPO) in order to compromise the objects that are controlled by that GPO.
1.03k stars 135 forks source link

Building SharpGPOAbuse on Linux #14

Open noraj opened 2 years ago

noraj commented 2 years ago

Context

One may not want to install a Windows VM + install Visual Studio just to build a tool. So I tried to build SharpGPOAbuse exe with Mono, MSBuild, .NET SDk, and NuGet on Linux.

Prerequisites

On ArchLinux:

$ pacman -S mono-msbuild dotnet-sdk nuget
$ pikaur -S mono-git

Version

Build steps

$ git clone https://github.com/FSecureLABS/SharpGPOAbuse.git
$ cd SharpGPOAbuse
$ nuget restore
$ msbuild SharpGPOAbuse.sln
Microsoft (R) Build Engine version 16.10.1 for Mono
Copyright (C) Microsoft Corporation. All rights reserved.

Building the projects in this solution one at a time. To enable parallel build, please add the "-m" switch.
Build started 12/22/2021 5:34:00 PM.
Project "/tmp/SharpGPOAbuse/SharpGPOAbuse.sln" on node 1 (default targets).
ValidateSolutionConfiguration:
  Building solution configuration "Debug|Any CPU".
Project "/tmp/SharpGPOAbuse/SharpGPOAbuse.sln" (1) is building "/tmp/SharpGPOAbuse/SharpGPOAbuse/SharpGPOAbuse.csproj" (2) on node 1 (default targets).
PrepareForBuild:
  Creating directory "bin/Debug/".
  Creating directory "obj/Debug/".
ResolveAssemblyReferences:
  Primary reference "System.DirectoryServices.AccountManagement".
/usr/lib/mono/msbuild/Current/bin/Microsoft.Common.CurrentVersion.targets(2218,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "System.DirectoryServices.AccountManagement". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [/tmp/SharpGPOAbuse/SharpGPOAbuse/SharpGPOAbuse.csproj]
          For SearchPath "{TargetFrameworkDirectory}".
          Considered "/usr/lib/mono/xbuild-frameworks/.NETFramework/v3.5/System.DirectoryServices.AccountManagement.winmd", but it didn't exist.
          Considered "/usr/lib/mono/xbuild-frameworks/.NETFramework/v3.5/System.DirectoryServices.AccountManagement.dll", but it didn't exist.
          Considered "/usr/lib/mono/xbuild-frameworks/.NETFramework/v3.5/System.DirectoryServices.AccountManagement.exe", but it didn't exist.
          Considered "/usr/lib/mono/xbuild-frameworks/.NETFramework/v3.0/System.DirectoryServices.AccountManagement.winmd", but it didn't exist.
          Considered "/usr/lib/mono/xbuild-frameworks/.NETFramework/v3.0/System.DirectoryServices.AccountManagement.dll", but it didn't exist.
          Considered "/usr/lib/mono/xbuild-frameworks/.NETFramework/v3.0/System.DirectoryServices.AccountManagement.exe", but it didn't exist.
          Considered "/usr/lib/mono/2.0-api/System.DirectoryServices.AccountManagement.winmd", but it didn't exist.
          Considered "/usr/lib/mono/2.0-api/System.DirectoryServices.AccountManagement.dll", but it didn't exist.
          Considered "/usr/lib/mono/2.0-api/System.DirectoryServices.AccountManagement.exe", but it didn't exist.
          For SearchPath "{GAC}".
          Considered "System.DirectoryServices.AccountManagement", which was not found in the GAC.
          For SearchPath "{RawFileName}".
          Considered treating "System.DirectoryServices.AccountManagement" as a file name, but it didn't exist.
          For SearchPath "bin/Debug/".
          Considered "bin/Debug/System.DirectoryServices.AccountManagement.winmd", but it didn't exist.
          Considered "bin/Debug/System.DirectoryServices.AccountManagement.dll", but it didn't exist.
          Considered "bin/Debug/System.DirectoryServices.AccountManagement.exe", but it didn't exist.
CoreCompile:
  /usr/lib/mono/msbuild/Current/bin/Roslyn/csc.exe /noconfig /nowarn:1701,1702 /fullpaths /nostdlib+ /platform:AnyCPU /errorreport:prompt /warn:4 /define:DEBUG;TRACE /highentropyva- /reference:/tmp/SharpGPOAbuse/packages/CommandLineParser.1.9.3.15/lib/CommandLine.dll /reference:/usr/lib/mono/2.0-api/mscorlib.dll /reference:/usr/lib/mono/2.0-api/System.Core.dll /reference:/usr/lib/mono/2.0-api/System.Data.DataSetExtensions.dll /reference:/usr/lib/mono/2.0-api/System.Data.dll /reference:/usr/lib/mono/2.0-api/System.DirectoryServices.dll /reference:/usr/lib/mono/2.0-api/System.DirectoryServices.Protocols.dll /reference:/usr/lib/mono/2.0-api/System.dll /reference:/usr/lib/mono/2.0-api/System.Xml.dll /reference:/usr/lib/mono/2.0-api/System.Xml.Linq.dll /debug+ /debug:full /filealign:512 /optimize- /out:obj/Debug/SharpGPOAbuse.exe /target:exe /utf8output /deterministic+ /langversion:7.3 Program.cs Properties/AssemblyInfo.cs
  Using shared compilation with compiler from directory: /usr/lib/mono/msbuild/Current/bin/Roslyn
/tmp/SharpGPOAbuse/SharpGPOAbuse/Program.cs(593,38): error CS0234: The type or namespace name 'AccountManagement' does not exist in the namespace 'System.DirectoryServices' (are you missing an assembly reference?) [/tmp/SharpGPOAbuse/SharpGPOAbuse/SharpGPOAbuse.csproj]
/tmp/SharpGPOAbuse/SharpGPOAbuse/Program.cs(593,108): error CS0234: The type or namespace name 'AccountManagement' does not exist in the namespace 'System.DirectoryServices' (are you missing an assembly reference?) [/tmp/SharpGPOAbuse/SharpGPOAbuse/SharpGPOAbuse.csproj]
/tmp/SharpGPOAbuse/SharpGPOAbuse/Program.cs(593,143): error CS0234: The type or namespace name 'AccountManagement' does not exist in the namespace 'System.DirectoryServices' (are you missing an assembly reference?) [/tmp/SharpGPOAbuse/SharpGPOAbuse/SharpGPOAbuse.csproj]
/tmp/SharpGPOAbuse/SharpGPOAbuse/Program.cs(594,38): error CS0234: The type or namespace name 'AccountManagement' does not exist in the namespace 'System.DirectoryServices' (are you missing an assembly reference?) [/tmp/SharpGPOAbuse/SharpGPOAbuse/SharpGPOAbuse.csproj]
/tmp/SharpGPOAbuse/SharpGPOAbuse/Program.cs(597,23): error CS0234: The type or namespace name 'AccountManagement' does not exist in the namespace 'System.DirectoryServices' (are you missing an assembly reference?) [/tmp/SharpGPOAbuse/SharpGPOAbuse/SharpGPOAbuse.csproj]
/tmp/SharpGPOAbuse/SharpGPOAbuse/Program.cs(597,100): error CS0234: The type or namespace name 'AccountManagement' does not exist in the namespace 'System.DirectoryServices' (are you missing an assembly reference?) [/tmp/SharpGPOAbuse/SharpGPOAbuse/SharpGPOAbuse.csproj]
/tmp/SharpGPOAbuse/SharpGPOAbuse/Program.cs(951,38): error CS0234: The type or namespace name 'AccountManagement' does not exist in the namespace 'System.DirectoryServices' (are you missing an assembly reference?) [/tmp/SharpGPOAbuse/SharpGPOAbuse/SharpGPOAbuse.csproj]
/tmp/SharpGPOAbuse/SharpGPOAbuse/Program.cs(951,108): error CS0234: The type or namespace name 'AccountManagement' does not exist in the namespace 'System.DirectoryServices' (are you missing an assembly reference?) [/tmp/SharpGPOAbuse/SharpGPOAbuse/SharpGPOAbuse.csproj]
/tmp/SharpGPOAbuse/SharpGPOAbuse/Program.cs(951,143): error CS0234: The type or namespace name 'AccountManagement' does not exist in the namespace 'System.DirectoryServices' (are you missing an assembly reference?) [/tmp/SharpGPOAbuse/SharpGPOAbuse/SharpGPOAbuse.csproj]
/tmp/SharpGPOAbuse/SharpGPOAbuse/Program.cs(952,38): error CS0234: The type or namespace name 'AccountManagement' does not exist in the namespace 'System.DirectoryServices' (are you missing an assembly reference?) [/tmp/SharpGPOAbuse/SharpGPOAbuse/SharpGPOAbuse.csproj]
/tmp/SharpGPOAbuse/SharpGPOAbuse/Program.cs(955,23): error CS0234: The type or namespace name 'AccountManagement' does not exist in the namespace 'System.DirectoryServices' (are you missing an assembly reference?) [/tmp/SharpGPOAbuse/SharpGPOAbuse/SharpGPOAbuse.csproj]
/tmp/SharpGPOAbuse/SharpGPOAbuse/Program.cs(955,100): error CS0234: The type or namespace name 'AccountManagement' does not exist in the namespace 'System.DirectoryServices' (are you missing an assembly reference?) [/tmp/SharpGPOAbuse/SharpGPOAbuse/SharpGPOAbuse.csproj]
Done Building Project "/tmp/SharpGPOAbuse/SharpGPOAbuse/SharpGPOAbuse.csproj" (default targets) -- FAILED.
Done Building Project "/tmp/SharpGPOAbuse/SharpGPOAbuse.sln" (default targets) -- FAILED.

Build FAILED.

"/tmp/SharpGPOAbuse/SharpGPOAbuse.sln" (default target) (1) ->
"/tmp/SharpGPOAbuse/SharpGPOAbuse/SharpGPOAbuse.csproj" (default target) (2) ->
(ResolveAssemblyReferences target) ->
  /usr/lib/mono/msbuild/Current/bin/Microsoft.Common.CurrentVersion.targets(2218,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "System.DirectoryServices.AccountManagement". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [/tmp/SharpGPOAbuse/SharpGPOAbuse/SharpGPOAbuse.csproj]

"/tmp/SharpGPOAbuse/SharpGPOAbuse.sln" (default target) (1) ->
"/tmp/SharpGPOAbuse/SharpGPOAbuse/SharpGPOAbuse.csproj" (default target) (2) ->
(CoreCompile target) ->
  /tmp/SharpGPOAbuse/SharpGPOAbuse/Program.cs(593,38): error CS0234: The type or namespace name 'AccountManagement' does not exist in the namespace 'System.DirectoryServices' (are you missing an assembly reference?) [/tmp/SharpGPOAbuse/SharpGPOAbuse/SharpGPOAbuse.csproj]
  /tmp/SharpGPOAbuse/SharpGPOAbuse/Program.cs(593,108): error CS0234: The type or namespace name 'AccountManagement' does not exist in the namespace 'System.DirectoryServices' (are you missing an assembly reference?) [/tmp/SharpGPOAbuse/SharpGPOAbuse/SharpGPOAbuse.csproj]
  /tmp/SharpGPOAbuse/SharpGPOAbuse/Program.cs(593,143): error CS0234: The type or namespace name 'AccountManagement' does not exist in the namespace 'System.DirectoryServices' (are you missing an assembly reference?) [/tmp/SharpGPOAbuse/SharpGPOAbuse/SharpGPOAbuse.csproj]
  /tmp/SharpGPOAbuse/SharpGPOAbuse/Program.cs(594,38): error CS0234: The type or namespace name 'AccountManagement' does not exist in the namespace 'System.DirectoryServices' (are you missing an assembly reference?) [/tmp/SharpGPOAbuse/SharpGPOAbuse/SharpGPOAbuse.csproj]
  /tmp/SharpGPOAbuse/SharpGPOAbuse/Program.cs(597,23): error CS0234: The type or namespace name 'AccountManagement' does not exist in the namespace 'System.DirectoryServices' (are you missing an assembly reference?) [/tmp/SharpGPOAbuse/SharpGPOAbuse/SharpGPOAbuse.csproj]
  /tmp/SharpGPOAbuse/SharpGPOAbuse/Program.cs(597,100): error CS0234: The type or namespace name 'AccountManagement' does not exist in the namespace 'System.DirectoryServices' (are you missing an assembly reference?) [/tmp/SharpGPOAbuse/SharpGPOAbuse/SharpGPOAbuse.csproj]
  /tmp/SharpGPOAbuse/SharpGPOAbuse/Program.cs(951,38): error CS0234: The type or namespace name 'AccountManagement' does not exist in the namespace 'System.DirectoryServices' (are you missing an assembly reference?) [/tmp/SharpGPOAbuse/SharpGPOAbuse/SharpGPOAbuse.csproj]
  /tmp/SharpGPOAbuse/SharpGPOAbuse/Program.cs(951,108): error CS0234: The type or namespace name 'AccountManagement' does not exist in the namespace 'System.DirectoryServices' (are you missing an assembly reference?) [/tmp/SharpGPOAbuse/SharpGPOAbuse/SharpGPOAbuse.csproj]
  /tmp/SharpGPOAbuse/SharpGPOAbuse/Program.cs(951,143): error CS0234: The type or namespace name 'AccountManagement' does not exist in the namespace 'System.DirectoryServices' (are you missing an assembly reference?) [/tmp/SharpGPOAbuse/SharpGPOAbuse/SharpGPOAbuse.csproj]
  /tmp/SharpGPOAbuse/SharpGPOAbuse/Program.cs(952,38): error CS0234: The type or namespace name 'AccountManagement' does not exist in the namespace 'System.DirectoryServices' (are you missing an assembly reference?) [/tmp/SharpGPOAbuse/SharpGPOAbuse/SharpGPOAbuse.csproj]
  /tmp/SharpGPOAbuse/SharpGPOAbuse/Program.cs(955,23): error CS0234: The type or namespace name 'AccountManagement' does not exist in the namespace 'System.DirectoryServices' (are you missing an assembly reference?) [/tmp/SharpGPOAbuse/SharpGPOAbuse/SharpGPOAbuse.csproj]
  /tmp/SharpGPOAbuse/SharpGPOAbuse/Program.cs(955,100): error CS0234: The type or namespace name 'AccountManagement' does not exist in the namespace 'System.DirectoryServices' (are you missing an assembly reference?) [/tmp/SharpGPOAbuse/SharpGPOAbuse/SharpGPOAbuse.csproj]

    1 Warning(s)
    12 Error(s)

Time Elapsed 00:00:01.26

Question

How to build SharpGPOAbuse exe from Linux?