Apr4h / CobaltStrikeScan

Scan files or process memory for CobaltStrike beacons and parse their configuration
MIT License
893 stars 114 forks source link

Build errors - Visual Studio 2019 #2

Closed x3419 closed 3 years ago

x3419 commented 3 years ago

Hi, I've been trying to build your project for a few days to no avail. I've configured the project to build a x64 .NET 4.6 assembly

Error:

Severity Code Description Project File Line Suppression State Error CS0006 Metadata file 'C:\Users\\CobaltStrikeScan\CobaltStrikeConfigParser\bin\Debug\CobaltStrikeConfigParser.dll' could not be found ConsoleUI C:\Users\\CobaltStrikeScan\ConsoleUI\CSC 1 Active

Error CS0006 Metadata file 'C:\Users\\CobaltStrikeScan\GetInjectedThreads\bin\Debug\GetInjectedThreads.dll' could not be found ConsoleUI C:\Users\\CobaltStrikeScan\ConsoleUI\CSC 1 Active

Error This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is packages\Microsoft.O365.Security.Native.libyara.NET.4.0.2\build\net46\Microsoft.O365.Security.Native.libyara.NET.props. CobaltStrikeConfigParser C:\Users\\CobaltStrikeScan\CobaltStrikeConfigParser\CobaltStrikeConfigParser.csproj 93

I've tried building CobaltStrikeConfigParser/GetInjectedThreads first before building the project, I've tried adding all the different versions of Microsoft.O365.Security.Native.libyara.NET via NuGet package manager, I've made sure that I cloned with the --recursive flag...nothing seems to work. This seems like a great project and I'd like to contribute

Apr4h commented 3 years ago

Hi, thanks so much for your interest in my project, and for raising this issue. I cloned the repo on a fresh Win10 machine to confirm the issue myself and also had trouble building.

I've included the the Nuget packages for each of the projects in the repository as of 8cc77c2f6f0c1b815483a13b4182a6d86e42c34b which seems to have fixed the issue, at least on my end.

I've also updated README.md with build instructions, as the CobaltStrikeConfigParser and GetInjectedThreads projects need to be built (with x64 Platform set) before ConsoleUI for Costura.Fody to properly embed all resources in a single assembly.

Hopefully, you should now be able to clone the repo, set Platform to x64, and build successfully. Please let me know if you're still having issues. If you're now able to build successfully, please feel free to close this issue :)

x3419 commented 3 years ago

Hi, thanks so much for the quick response. I've tried cloning again in a fresh win10 vm and unfortunately I'm still having issues building. If I load the solution and try to only build CobaltStrikeConfigParser, I receive the following errors. image

I think the problem might be a conflict or something with the libyara library. If you look under References in that screenshot you can see that the project is referencing both libyara.NET and Microsoft.O365.Security.Native.libyara.NET which may be different libraries? Not sure. I'm not familiar with Costura and the build process but I love the idea of making this portable.

Apr4h commented 3 years ago

As now-mentioned in the readme, you should just need to change your active platform, as libyaraNET is x64 only. In the top of your screenshot, where you have "Debug | Any CPU" - change "Any CPU to x64 and I believe you should be good to go!

image

If you don't currently have an x64 solution platform, you can create one by clicking Build -> Configuration Manager -> Platform (dropdown) -> New - and selecting x64.

image

x3419 commented 3 years ago

You're the man! Thank you so much, it's building successfully now. I'll close this issue.