# MSBuild

Let's get some examples here we can add powershell code onto an XML file have msbuild compile it and execute to call a shell back to us this will automate the process to leverage the MSBuild technique to input a powershell payload into an inline-task XML file that can be launched.

{% embed url="<https://gist.github.com/mgeeky>" %}

I continued with the use of this tool for creating shell's using msbuild and converting the file into an XML format perfect use for MSBuild.

![](https://244509215-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lx2b2zLkTKHrsGfxMoR%2F-LxY8zKRjlk-zGlbx_rH%2F-LxYEuRrcRRDjZAea7Fr%2Fimage.png?alt=media\&token=8a1eaf7a-1dde-42d5-8252-7796ae8f3182)

Let's copy this onto our victim machine

We can see that we saved the z.xml file onto the machine (This name can be whatever) . From here we will need to move onto the MSBuild directory and load the executable

![z.xml](https://244509215-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lx2b2zLkTKHrsGfxMoR%2F-LxY8zKRjlk-zGlbx_rH%2F-LxYNGpFJlOG6VT__o3k%2Fimage.png?alt=media\&token=da5c7921-248d-4e16-90d7-a2b063bcbb24)

![MSBuild Path](https://244509215-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lx2b2zLkTKHrsGfxMoR%2F-LxY8zKRjlk-zGlbx_rH%2F-LxYNTKIIaDYIutARlpw%2Fimage.png?alt=media\&token=8813dcd4-9636-421b-86bd-0be56bc61dd2)

&#x20;Let's use MSBuild to execute our XML File

![](https://244509215-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lx2b2zLkTKHrsGfxMoR%2F-LxY8zKRjlk-zGlbx_rH%2F-LxYTPpQFcq0R8XfVOLs%2FMSBuild-Payload.gif?alt=media\&token=2de4b58b-62d4-4945-972b-75321863c16b)

We can also execute csproj files as MSBuild compiles these as well.

This tool uses techniques  that are already published as stated on the README `This script will generate payloads for basic intrusion detection avoidance. It utilizes publicly demonstrated techniques from several different sources.`
