Regsvcs/Regasm
Adversaries may abuse Regsvcs and Regasm to proxy execution of code through trusted Windows utilities. Regsvcs and Regasm are Windows command-line utilities used to register .NET Component Object Model (COM) assemblies. Both are digitally signed by Microsoft. These utilities can bypass application control through use of attributes within the binary to specify code that should run before registration or unregistration: [ComRegisterFunction] or [ComUnregisterFunction] respectively. Critically, the code decorated with these attributes executes even if the process runs with insufficient privileges and fails. Agent Tesla is a notable malware family that uses Regasm.exe for proxy execution.
DeviceProcessEvents
| where Timestamp > ago(24h)
| where FileName in~ ("regsvcs.exe", "regasm.exe")
| extend SuspiciousPath = ProcessCommandLine has_any ("Temp", "AppData", "Downloads", "Public", "Desktop", "ProgramData")
| extend UnregisterFlag = ProcessCommandLine has_any ("/u", "/unregister")
| extend SilentFlag = ProcessCommandLine has_any ("/silent", "/s")
| extend SuspiciousParent = InitiatingProcessFileName has_any ("cmd.exe", "powershell.exe", "wscript.exe", "cscript.exe", "mshta.exe", "winword.exe", "excel.exe")
| extend RemotePath = ProcessCommandLine has_any ("http://", "https://", "\\\\")
| project Timestamp, DeviceName, AccountName, FileName, ProcessCommandLine, InitiatingProcessFileName,
InitiatingProcessCommandLine, SuspiciousPath, UnregisterFlag, SilentFlag, SuspiciousParent, RemotePath
| sort by Timestamp desc
union (
DeviceProcessEvents
| where Timestamp > ago(24h)
| where InitiatingProcessFileName in~ ("regsvcs.exe", "regasm.exe")
| project Timestamp, DeviceName, AccountName, FileName, ProcessCommandLine,
InitiatingProcessFileName, InitiatingProcessCommandLine
| sort by Timestamp desc
) Data Sources
Required Tables
False Positives
- Legitimate .NET software that registers COM interop assemblies via Regasm.exe during installation (common with Office interop assemblies)
- Software development activities where developers register and unregister .NET COM assemblies for testing
- Enterprise applications with .NET-based COM components registered during software deployment
- Windows SDK tools and Visual Studio that use Regasm.exe for .NET COM registration during build processes
References (7)
- https://attack.mitre.org/techniques/T1218/009/
- https://lolbas-project.github.io/lolbas/Binaries/Regsvcs/
- https://lolbas-project.github.io/lolbas/Binaries/Regasm/
- https://msdn.microsoft.com/en-us/library/04za0hca.aspx
- https://msdn.microsoft.com/en-us/library/tzat5yw6.aspx
- https://github.com/redcanaryco/atomic-red-team/blob/master/atomics/T1218.009/T1218.009.md
- https://www.sentinelone.com/labs/agent-tesla-old-rat-uses-new-tricks-to-stay-on-top/
Unlock Pro Content
Get the full detection package for T1218.009 including response playbook, investigation guide, and atomic red team tests.