Identifier / Programs / Windows
csc.exe
The Microsoft C# Compiler. tldr-pages
LOLBAS Compile 9 Sigma rules name it 6 ATT&CK techniques 2 documented commands 4 known copies with hashes
How csc.exe is abused
Compile T1127 Trusted Developer Utilities Proxy Execution
-outCompile T1127 Trusted Developer Utilities Proxy Execution
-targetEach abuse is LOLBAS's category and the options and words it uses; the full write-up is on LOLBAS's page for csc.exe.
2 documented commands
Compile T1127 Trusted Developer Utilities Proxy Execution User privileges
Use csc.exe to compile C# code, targeting the .NET Framework, stored in the specified .cs file and output the compiled version to the specified .exe path.
csc.exe -out:{PATH:.exe} {PATH:.cs}IdentifyCompile T1127 Trusted Developer Utilities Proxy Execution User privileges
Use csc.exe to compile C# code, targeting the .NET Framework, stored in the specified .cs file and output the compiled version to a DLL file with the same name.
csc -target:library {PATH:.cs}IdentifyNone of the 2 commands the identifier reads trips a Sigma process-creation rule. These commands and their descriptions are from LOLBAS’s entry for csc.exe, by Oddvar Moe, at commit 2056cb766250 of 2026-09-26, under the GPL-3.0 and LOLBAS’s notice, with no warranty. Changed: Markdown is shown formatted. The source is in lolbas-gtfobins-commands.json.gz, and the full entry is on LOLBAS’s page for csc.exe. The identifier reads each with LOLBAS’s placeholders filled in: a URL as https://example.com/file, a share as \\192.0.2.10\share\file, a path as C:\Data\file and a command as calc.exe.
What detects it
Is it the real csc.exe?
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\C:\Windows\Microsoft.NET\Framework\v4.0.30319\4 known copies
4.8.4161.0 built by: NET48REL1 · C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\csc.exe · signed by Microsoft Windows
4458132afc157ed1943f0fee08fb8dce30b46eca73ac07c45026378b47d8be644.8.4161.0 built by: NET48REL1 · C:\WINDOWS\Microsoft.NET\Framework64\v4.0.30319\csc.exe · signed by Microsoft Windows
adeda78a951529462f9411e016c1a1b87ddfd94c55912cbd2957817f39929af14.8.4084.0 built by: NET48REL1 · C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe · signed by Microsoft Windows
38c407dbf41e99396b78d00dd796930d8838dcb4af77c3f23ba0e800d1213ebe4.8.4084.0 built by: NET48REL1 · C:\Windows\Microsoft.NET\Framework64\v4.0.30319\csc.exe · signed by Microsoft Windows
4a6d0864e19c0368a47217c129b075dddf61a6a262388f9d21045d82f3423ed7From the file’s version info and the copies recorded by xCyclopedia (MIT). A copy in another folder, signed by someone else or with another hash is not necessarily malicious, but it is worth a closer look. In Ceplin, "<sha256>".whatis() says which known copy a hash is.
Everyday use
Compile one or more C# files to a CIL executable
csc path/to/input_file1.cs path/to/input_file2.cs ...IdentifySpecify the output filename
csc /out:path/to/file path/to/input_file.csIdentifyMatches LOLBAS abuse: Compile (T1127)
Compile into a .dll library instead of an executable
csc /target:library path/to/input_file.csIdentifyMatches LOLBAS abuse: Compile (T1127)
Of the 3 examples the identifier reads, 2 match LOLBAS abuse or trip a Sigma process-creation rule.