01 / TRADECRAFT
5 examplesCommand reference
AWL Bypass1
EXAMPLE 01T1127.001
Build and execute a C# project stored in the target XML file.
COMMAND
msbuild.exe {PATH:.xml}Execute4
EXAMPLE 01T1127.001
Build and execute a C# project stored in the target csproj file.
COMMAND
msbuild.exe {PATH:.csproj}EXAMPLE 02T1127.001
Executes generated Logger DLL file with TargetLogger export.
COMMAND
msbuild.exe /logger:TargetLogger,{PATH_ABSOLUTE:.dll};MyParameters,FooEXAMPLE 03T1127.001
Execute JScript/VBScript code through XML/XSL Transformation. Requires Visual Studio MSBuild v14.0+.
COMMAND
msbuild.exe {PATH:.proj}EXAMPLE 04T1036
By putting any valid msbuild.exe command-line options in an RSP file and calling it as above will interpret the options as if they were passed on the command line.
COMMAND
msbuild.exe @{PATH:.rsp}02 / ON DISK
Known paths
C:\Windows\Microsoft.NET\Framework\v2.0.50727\Msbuild.exeC:\Windows\Microsoft.NET\Framework64\v2.0.50727\Msbuild.exeC:\Windows\Microsoft.NET\Framework\v3.5\Msbuild.exeC:\Windows\Microsoft.NET\Framework64\v3.5\Msbuild.exeC:\Windows\Microsoft.NET\Framework\v4.0.30319\Msbuild.exeC:\Windows\Microsoft.NET\Framework64\v4.0.30319\Msbuild.exeC:\Program Files (x86)\MSBuild\14.0\bin\MSBuild.exe03 / DEFENSIVE INTELLIGENCE
12 resourcesDetection & indicators
- Sigmafile_event_win_shell_write_susp_directory.ymlgithub.com
- Sigmaproc_creation_win_msbuild_susp_parent_process.ymlgithub.com
- Sigmanet_connection_win_silenttrinity_stager_msbuild_activity.ymlgithub.com
- Splunksuspicious_msbuild_spawn.ymlgithub.com
- Splunksuspicious_msbuild_rename.ymlgithub.com
- Splunkmsbuild_suspicious_spawned_by_script_process.ymlgithub.com
- Elasticdefense_evasion_msbuild_beacon_sequence.tomlgithub.com
- Elasticdefense_evasion_msbuild_making_network_connections.tomlgithub.com
- Elasticdefense_evasion_execution_msbuild_started_by_script.tomlgithub.com
- Elasticdefense_evasion_execution_msbuild_started_by_office_app.tomlgithub.com
- Elasticdefense_evasion_execution_msbuild_started_renamed.tomlgithub.com
- BlockRulemicrosoft recommended block rulesdocs.microsoft.com
Indicators & detection notes
- IOC
Msbuild.exe should not normally be executed on workstations
FURTHER READING
Research & resources
- READT1127.mdgithub.com
- READMSBuildShellgithub.com
- READapplocker bypass msbuildpentestlab.blog
- READapplocker case study how insecure is it really part 1oddvar.moe
- READCode & research by bohopsgist.github.com
- READ165github.com
- READmsbuild response filesdocs.microsoft.com
- READmsbuild loggers and logging eventswww.daveaglick.com
COMMUNITY RESEARCH
Acknowledgements
Casey Smith@subtee
Cn33liz@Cneelis
Jimmy@bohops