Downloaded source code files from remote addresses then compiled them locally via GCC in victim environments.1
Compile After Delivery T1027.004
- Tactic
- Stealth
- Platforms
- Linux, macOS, Windows
- Version
- 2.0
- Created
- 16 March 2020
- Last modified
- 12 May 2026
- Contributors
- Liran Ravich, CardinalOps; Praetorian; Ye Yint Min Thu Htut, Offensive Security Team, DBS Bank
Adversaries may attempt to make payloads difficult to discover and analyze by delivering files to victims as uncompiled code. Text-based source code files may subvert analysis and scrutiny from protections targeting executables/binaries. These payloads will need to be compiled before execution; typically via native utilities such as ilasm.exe[1], csc.exe, or GCC/MinGW.[2]
Compile After Delivery MITRE reference T1027.004
4 groups have been recorded using this technique. Newest first; each entry carries MITRE’s procedure text and a link to the group’s full record. Click a name to filter the rules below.
Has compiled malware, delivered to victims as .c files, with the GNU Compiler Collection (GCC).1
Has used the .NET csc.exe tool to compile executables from downloaded C# code.1
Has compiled the source code for a downloader directly on the infected system using the built-in Microsoft.CSharp.CSharpCodeProvider class.1
All 4 groups for this technique
6 software entries are documented implementing this technique. MITRE files each as a tool or as malware; newest first, then by how many groups carry them.
Can compile and execute downloaded modules at runtime.1
Has used the csc.exe tool to compile a C# executable.1
Can compile and execute source code sent to the compromised AD FS server via a specific HTTP POST.1
Includes functionality to retrieve source code and compile locally prior to execution in victim environments.1
Has used AutoIt to compile the payload and main script into a single executable after delivery.1
And its watchdog component are compiled and executed after being delivered to victims as embedded, uncompiled source code.1
All 6 software entries for this technique
Offense vs defense T1027.004
Is defensive coverage keeping up with adversary use? Eight counts, each ranked against all 697 ATT&CK techniques. Attack sits left, defense right, so a shape leaning left means adversaries are better documented here than defenders are equipped. Hover any spoke for its percentile and the share of techniques that have more. The timeline below shows when each side arrived.
How it got here
Adversary activity (campaign spans) over cumulative rule output. Each source is plotted independently from zero, so neither line includes the other. Campaign dates are year-granularity.
Compile After Delivery detection strategy DET0501
MITRE names one behaviour worth catching for this technique and breaks it into 3 analytics, one per platform. Each carries the log sources it needs and the fields you tune per environment.
Detection Strategy for Compile After Delivery - Source Code to Executable Transformation
AN1381 · Windows
Detects compilation activity using csc.exe, ilasm.exe, or msbuild.exe initiated by user-space processes outside typical development environments, followed by execution or network activity from newly written binaries.
Log sources
The data this analytic draws on. You do not need every component — each one you already collect covers part of it. Each links to its ATT&CK record.
| Data component | Name | Channel |
|---|---|---|
| Process CreationDC0032 | WinEventLog:Sysmon | EventCode=1 |
| File CreationDC0039 | WinEventLog:Sysmon | EventCode=11 |
| Network Connection CreationDC0082 | WinEventLog:Sysmon | EventCode=3, 22 |
Tunable fields
MITRE calls these the analytic’s mutable elements: the thresholds and filters you set for your own environment.
| Field | What you tune |
|---|---|
| ParentProcessName | Filter for unexpected users (non-dev) launching compilers like csc.exe or msbuild.exe |
| OutputDirectoryPath | Adjust paths for sensitive file write zones (e.g., C:\Users\Public\, %TEMP%, or Desktop) |
| TimeWindow | Tune the correlation window between compilation and subsequent execution or C2 |
AN1382 · Linux
Detects GCC or Clang invoked on suspicious file paths (e.g., /tmp/, ~/Downloads) with output to executable binaries, followed by execution or outbound traffic from these binaries.
Log sources
The data this analytic draws on. You do not need every component — each one you already collect covers part of it. Each links to its ATT&CK record.
| Data component | Name | Channel |
|---|---|---|
| Process CreationDC0032 | auditd:SYSCALL | execve |
| File CreationDC0039 | auditd:SYSCALL | open,create |
| Network Connection CreationDC0082 | NSM:Flow | conn.log |
Tunable fields
MITRE calls these the analytic’s mutable elements: the thresholds and filters you set for your own environment.
| Field | What you tune |
|---|---|
| CompilerBinaryPath | Specify path and binaries for detection (e.g., /usr/bin/gcc, /opt/mingw/bin/gcc) |
| FilePermissionProfile | Match uncommon chmod behavior post-compilation (e.g., +x in /tmp or home directories) |
AN1383 · macOS
Detects non-standard compilation activity via Xcode CLI tools or bundled GCC/MONO packages writing new executable files and executing them outside dev environments (e.g., user Downloads folder).
Log sources
The data this analytic draws on. You do not need every component — each one you already collect covers part of it. Each links to its ATT&CK record.
| Data component | Name | Channel |
|---|---|---|
| Process CreationDC0032 | macos:unifiedlog | process activity, exec events |
| File CreationDC0039 | macos:osquery | file_events |
| Network Connection CreationDC0082 | macos:unifiedlog | networkd or socket |
Tunable fields
MITRE calls these the analytic’s mutable elements: the thresholds and filters you set for your own environment.
| Field | What you tune |
|---|---|
| CompilerInvocationPattern | Detect calls to xcodebuild, clang, or /Applications/Mono.app/... from non-admin users |
| OutputBinaryPath | Monitor for output files in user-writable paths (e.g., ~/Library/Caches, ~/Downloads) |
Tests from Atomic Red Team (MIT licence) · technique definition