<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Csc.exe — CraftedSignal Threat Feed</title><link>https://feed.craftedsignal.io/tags/csc.exe/</link><description>Trending threats, MITRE ATT&amp;CK coverage, and detection metadata — refreshed continuously.</description><generator>Hugo</generator><language>en</language><managingEditor>hello@craftedsignal.io</managingEditor><webMaster>hello@craftedsignal.io</webMaster><lastBuildDate>Wed, 03 Jan 2024 12:00:00 +0000</lastBuildDate><atom:link href="https://feed.craftedsignal.io/tags/csc.exe/feed.xml" rel="self" type="application/rss+xml"/><item><title>Suspicious Dynamic .NET Compilation via Csc.exe</title><link>https://feed.craftedsignal.io/briefs/2024-01-dynamic-net-compilation/</link><pubDate>Wed, 03 Jan 2024 12:00:00 +0000</pubDate><author>hello@craftedsignal.io</author><guid isPermaLink="true">https://feed.craftedsignal.io/briefs/2024-01-dynamic-net-compilation/</guid><description>Attackers may use csc.exe to compile .NET code on the fly to evade detection, often placing the compiler and source code in suspicious locations, which can be detected by monitoring process creation events.</description><content:encoded><![CDATA[<p>Attackers often utilize the .NET Framework&rsquo;s command-line compiler, <code>csc.exe</code>, to compile malicious code dynamically on compromised systems. This tactic allows them to evade traditional signature-based detections and execute code in memory. The compilation often occurs from unusual or temporary directories such as <code>\Perflogs\</code>, <code>\Users\Public\</code>, or within the <code>AppData</code> directory. This technique has been observed in campaigns involving malware such as Agent Tesla and by actors like MuddyWater. Detection focuses on identifying <code>csc.exe</code> executions originating from or utilizing paths indicative of suspicious activity outside of normal software development workflows.</p>
<h2 id="attack-chain">Attack Chain</h2>
<ol>
<li>Initial Access: The attacker gains initial access to the system through an exploit or social engineering.</li>
<li>Payload Delivery: A malicious payload containing .NET source code is delivered to the system, often dropped in a temporary directory or a user&rsquo;s profile directory.</li>
<li>Command Execution: The attacker uses a command-line interface (cmd.exe or powershell.exe) to execute <code>csc.exe</code>.</li>
<li>Dynamic Compilation: <code>csc.exe</code> compiles the .NET source code into an executable or DLL file.</li>
<li>File Creation: The compiled assembly is written to disk in a specified location.</li>
<li>Code Injection/Execution: The compiled assembly is loaded into memory and executed, often using techniques like reflective DLL injection.</li>
<li>Persistence (Optional): The attacker may establish persistence by creating a scheduled task or modifying registry keys to recompile and execute the malicious code on system startup.</li>
<li>Achieve Objectives: The attacker achieves their objectives, such as data exfiltration, lateral movement, or establishing a command and control channel.</li>
</ol>
<h2 id="impact">Impact</h2>
<p>Successful exploitation can lead to arbitrary code execution, allowing attackers to perform a wide range of malicious activities. This can result in data theft, system compromise, and the deployment of ransomware. While the number of victims and sectors targeted varies depending on the specific campaign, dynamic compilation techniques significantly increase the difficulty of detection and response, making systems vulnerable to persistent and stealthy attacks.</p>
<h2 id="recommendation">Recommendation</h2>
<ul>
<li>Deploy the provided Sigma rules to your SIEM to detect suspicious executions of <code>csc.exe</code> from unusual locations (process_creation logs).</li>
<li>Tune the Sigma rules for your environment to reduce false positives, considering legitimate uses of <code>csc.exe</code> by developers (Sigma rules).</li>
<li>Monitor process creation events for <code>csc.exe</code> with command-line arguments containing suspicious directory locations like <code>\Perflogs\</code>, <code>\Users\Public\</code>, <code>\AppData\Local\Temp\</code> (process_creation logs).</li>
<li>Investigate any instances where <code>csc.exe</code> is executed by processes other than legitimate software development tools, filtering out known good parent processes like <code>sdiagnhost.exe</code> or <code>w3wp.exe</code> (process_creation logs).</li>
<li>Consider blocking execution of <code>csc.exe</code> from user-writable directories if it is not a legitimate use case in your environment.</li>
</ul>
]]></content:encoded><category domain="severity">medium</category><category domain="type">advisory</category><category>defense-evasion</category><category>dynamic-compilation</category><category>csc.exe</category></item><item><title>Suspicious CSC.exe Parent Process</title><link>https://feed.craftedsignal.io/briefs/2024-01-02-csc-suspicious-parent/</link><pubDate>Tue, 02 Jan 2024 15:00:00 +0000</pubDate><author>hello@craftedsignal.io</author><guid isPermaLink="true">https://feed.craftedsignal.io/briefs/2024-01-02-csc-suspicious-parent/</guid><description>The Csc.exe (C# compiler) process is being launched by unusual parent processes or from suspicious locations, indicating potential malware execution or defense evasion.</description><content:encoded><![CDATA[<p>Attackers are leveraging the legitimate Csc.exe (C# compiler) to execute malicious code, often as a part of defense evasion or payload delivery. This is achieved by spawning Csc.exe from unusual parent processes such as scripting hosts (cscript.exe, wscript.exe), Office applications (excel.exe, winword.exe), or PowerShell, especially when combined with encoded commands. Observed techniques also include launching Csc.exe from temporary or unusual directories. This activity bypasses traditional application whitelisting and can lead to the execution of arbitrary code. This activity has been associated with WarzoneRAT, DarkVNC, and the delivery of IMAPLoader malware.</p>
<h2 id="attack-chain">Attack Chain</h2>
<ol>
<li>An attacker gains initial access, potentially through phishing or exploiting a vulnerability.</li>
<li>A script or Office macro executes, initiating a command-line process.</li>
<li>This process then invokes a scripting host (e.g., cscript.exe) or PowerShell.</li>
<li>The scripting host or PowerShell executes a command that downloads or creates a C# source code file.</li>
<li>Csc.exe is then invoked, often from a temporary directory, to compile the downloaded/created C# code.</li>
<li>The compiled C# code executes, performing malicious actions.</li>
<li>The malicious code may establish persistence, communicate with a C2 server, or perform data exfiltration.</li>
<li>The final objective might be to deploy ransomware, steal sensitive data, or establish a persistent backdoor.</li>
</ol>
<h2 id="impact">Impact</h2>
<p>Successful exploitation can lead to arbitrary code execution, allowing attackers to compromise systems, steal data, or deploy malware. Depending on the user&rsquo;s permissions, the attacker could gain elevated privileges. The observed techniques have been associated with ransomware deployment, data theft, and remote access trojans (RATs).</p>
<h2 id="recommendation">Recommendation</h2>
<ul>
<li>Deploy the Sigma rule &ldquo;Csc.EXE Execution Form Potentially Suspicious Parent&rdquo; to detect suspicious parent processes of csc.exe.</li>
<li>Monitor process creation events for csc.exe with parent processes like scripting hosts or Office applications.</li>
<li>Investigate any instances of csc.exe being executed from temporary directories or user profile locations by reviewing process_creation logs.</li>
<li>Enable Sysmon process creation logging to capture detailed process information, including parent-child relationships, for effective detection.</li>
</ul>
]]></content:encoded><category domain="severity">high</category><category domain="type">advisory</category><category>attack.execution</category><category>attack.defense-evasion</category><category>csc.exe</category><category>payload-delivery</category></item></channel></rss>