Can I execute arbitrary shellcode directly with MSBuild, and what are the platform considerations?

Yes, you can execute shellcode by embedding a byte array and calling `VirtualAlloc` and `CreateThread` from kernel32.dll within an MSBuild Inline Task. For 32-bit shellcode, use `C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe`; for 64-bit, you must use the 64-bit MSBuild and corresponding shellcode. The article [Use MSBuild To Do More](/news/use-msbuild-to-do-more) shows a full example that successfully launches calc.exe, and the technique can be combined with [Penetration Techniques - Multiple Methods for Downloading Files from GitHub](/news/penetration-techniques-multiple-methods-for-downloading-files-from-github) to fetch shellcode remotely.

Related article:

Use MSBuild To Do More