{"description":"Trending threats, MITRE ATT\u0026CK coverage, and detection metadata — refreshed continuously.","feed_url":"https://feed.craftedsignal.io/tags/dynamic-compilation/","home_page_url":"https://feed.craftedsignal.io/","items":[{"_cs_actors":[],"_cs_cves":[],"_cs_exploited":false,"_cs_products":[".NET Framework"],"_cs_severities":["medium"],"_cs_tags":["defense-evasion","dynamic-compilation","csc.exe"],"_cs_type":"advisory","_cs_vendors":["Microsoft"],"content_html":"\u003cp\u003eAttackers often utilize the .NET Framework\u0026rsquo;s command-line compiler, \u003ccode\u003ecsc.exe\u003c/code\u003e, 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 \u003ccode\u003e\\Perflogs\\\u003c/code\u003e, \u003ccode\u003e\\Users\\Public\\\u003c/code\u003e, or within the \u003ccode\u003eAppData\u003c/code\u003e directory. This technique has been observed in campaigns involving malware such as Agent Tesla and by actors like MuddyWater. Detection focuses on identifying \u003ccode\u003ecsc.exe\u003c/code\u003e executions originating from or utilizing paths indicative of suspicious activity outside of normal software development workflows.\u003c/p\u003e\n\u003ch2 id=\"attack-chain\"\u003eAttack Chain\u003c/h2\u003e\n\u003col\u003e\n\u003cli\u003eInitial Access: The attacker gains initial access to the system through an exploit or social engineering.\u003c/li\u003e\n\u003cli\u003ePayload Delivery: A malicious payload containing .NET source code is delivered to the system, often dropped in a temporary directory or a user\u0026rsquo;s profile directory.\u003c/li\u003e\n\u003cli\u003eCommand Execution: The attacker uses a command-line interface (cmd.exe or powershell.exe) to execute \u003ccode\u003ecsc.exe\u003c/code\u003e.\u003c/li\u003e\n\u003cli\u003eDynamic Compilation: \u003ccode\u003ecsc.exe\u003c/code\u003e compiles the .NET source code into an executable or DLL file.\u003c/li\u003e\n\u003cli\u003eFile Creation: The compiled assembly is written to disk in a specified location.\u003c/li\u003e\n\u003cli\u003eCode Injection/Execution: The compiled assembly is loaded into memory and executed, often using techniques like reflective DLL injection.\u003c/li\u003e\n\u003cli\u003ePersistence (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.\u003c/li\u003e\n\u003cli\u003eAchieve Objectives: The attacker achieves their objectives, such as data exfiltration, lateral movement, or establishing a command and control channel.\u003c/li\u003e\n\u003c/ol\u003e\n\u003ch2 id=\"impact\"\u003eImpact\u003c/h2\u003e\n\u003cp\u003eSuccessful 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.\u003c/p\u003e\n\u003ch2 id=\"recommendation\"\u003eRecommendation\u003c/h2\u003e\n\u003cul\u003e\n\u003cli\u003eDeploy the provided Sigma rules to your SIEM to detect suspicious executions of \u003ccode\u003ecsc.exe\u003c/code\u003e from unusual locations (process_creation logs).\u003c/li\u003e\n\u003cli\u003eTune the Sigma rules for your environment to reduce false positives, considering legitimate uses of \u003ccode\u003ecsc.exe\u003c/code\u003e by developers (Sigma rules).\u003c/li\u003e\n\u003cli\u003eMonitor process creation events for \u003ccode\u003ecsc.exe\u003c/code\u003e with command-line arguments containing suspicious directory locations like \u003ccode\u003e\\Perflogs\\\u003c/code\u003e, \u003ccode\u003e\\Users\\Public\\\u003c/code\u003e, \u003ccode\u003e\\AppData\\Local\\Temp\\\u003c/code\u003e (process_creation logs).\u003c/li\u003e\n\u003cli\u003eInvestigate any instances where \u003ccode\u003ecsc.exe\u003c/code\u003e is executed by processes other than legitimate software development tools, filtering out known good parent processes like \u003ccode\u003esdiagnhost.exe\u003c/code\u003e or \u003ccode\u003ew3wp.exe\u003c/code\u003e (process_creation logs).\u003c/li\u003e\n\u003cli\u003eConsider blocking execution of \u003ccode\u003ecsc.exe\u003c/code\u003e from user-writable directories if it is not a legitimate use case in your environment.\u003c/li\u003e\n\u003c/ul\u003e\n","date_modified":"2024-01-03T12:00:00Z","date_published":"2024-01-03T12:00:00Z","id":"/briefs/2024-01-dynamic-net-compilation/","summary":"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.","title":"Suspicious Dynamic .NET Compilation via Csc.exe","url":"https://feed.craftedsignal.io/briefs/2024-01-dynamic-net-compilation/"}],"language":"en","title":"CraftedSignal Threat Feed — Dynamic-Compilation","version":"https://jsonfeed.org/version/1.1"}