Malware Analysis / Incident Response

From obfuscated PowerShell to MSBuild injection

I unpacked a staged loader to explain its MSBuild injection, C2 and registry persistence, then checked which behaviours had occurred on the affected endpoint.

Growing MSSP with Offensive ServicesHands-on malware analysis and incident investigation2 min read

A CrowdStrike detection left two questions to resolve: what could the supplied malware do, and how much of that behaviour had reached the client endpoint? I analysed the sample and then compared its execution chain with the endpoint evidence.

The ZIP contained obfuscated PowerShell saved with a .cmd extension. I reformatted the code, renamed variables and identified the decoding and execution functions. Changing the execution function to print decoded commands exposed the first-stage download behaviour and the second-stage files.

I moved to controlled dynamic analysis when the next stage proved more heavily obfuscated. It dropped a PowerShell script and shellcode; extracted strings suggested memory allocation and reflective Windows API loading. Procmon and process observations helped me follow a suspended msbuild.exe process, shellcode loading, subsequent C2 communication and Autorun registry persistence.

The client evidence showed that CrowdStrike had interrupted the chain: the corresponding MSBuild activity, C2 traffic and Autorun persistence were absent from the records reviewed. My report distinguished the behaviour demonstrated in analysis from the stages evidenced on the endpoint, giving detection work a precise account of the chain.

Methods, evidence & technical decisions

Decoding the first stage

The .cmd extension concealed the underlying PowerShell content. I exposed its structure by reformatting the code and renaming variables, then changed the execution function to print decoded commands. This revealed how the loader retrieved its next stage.

Open this detail ↗
Following the MSBuild execution chain

Controlled dynamic analysis produced a PowerShell script and shellcode. Script strings suggested memory allocation and reflective Windows API use. Process and registry analysis, including Procmon, showed the MSBuild chain, C2 communication and Autorun persistence in the analysis environment.

Open this detail ↗
Checking what ran on the endpoint

I searched client records for the behaviours seen during controlled execution. They did not show corresponding MSBuild activity, C2 communication or Autorun persistence after CrowdStrike interrupted the chain. The report preserved that distinction when describing detection-relevant behaviour.

Open this detail ↗

Skills used in this work

This work connects to

SOC & incident response

Your exploration

Viewed history

Saved only in this browser.

Ask my portfolio

Ask about my work.

Ask about an investigation, a technology or my contribution. Answers link to the relevant case and technical detail.

Every answer links to the work.
How this works

When AI is connected, your question, recent questions and relevant published pages are sent to MiniMax to select supporting passages. Otherwise, this searches the site directly. Answers quote the saved website and link to their sources. This website does not save chat transcripts. Clearing or leaving the page clears this conversation.

Help improve this website

Report an issue

Spotted something broken or inaccurate? Tell me what happened and what you expected.