ad域同步其他ldap账号_域渗透——普通用户权限获得DNS记录
0x00 前言
在之前的文章《域滲透——DNS記錄的獲取》介紹了域滲透中獲得DNS管理員權限后獲取DNS記錄的方法,而更普遍的情況是只有域普通用戶的權限,也需要獲得DNS記錄。
本文將會參考公開的資料,整理域普通用戶獲得DNS記錄的方法,修復dns-dump.ps1在高版本Windows系統下的bug。
0x01 簡介
本文將要介紹以下內容:
· 實現原理
·?開源的工具和方法
0x02 實現原理
1.SharpAdidnsdump的實現原理
先通過LDAP查詢獲得域內計算機的名稱,再通過DNS查詢獲得對應的IP。
詳細實現細節可參考:
https://github.com/b4rtik/SharpAdidnsdump
測試環境:?test.com
(1)通過LDAP查詢獲得域內計算機的名稱
對應LDAP的查詢參數如下:
LDAP://test.com/DC=test.com,CN=microsoftdns,DC=DomainDnsZones,DC=test,DC=com(&(!(objectClass=DnsZone))(!(DC=@))(!(DC=*arpa))(!(DC=*DNSZones)))
(2)通過DNS查詢獲得域內計算機對應的IP
使用Dns.GetHostEntry方法,參考資料:
https://docs.microsoft.com/en-us/dotnet/api/system.net.dns.gethostentry?redirectedfrom=MSDN&view=netframework-3.5#System_Net_Dns_GetHostEntry_System_String_
2.dns-dump的實現原理
先通過LDAP查詢獲得DNS記錄,對二進制的DNS記錄進行解碼,獲得實際內容。
DNS記錄解碼的細節可參考:
https://github.com/mmessano/PowerShell/blob/master/dns-dump.ps1#L483
0x03 開源的工具和方法
測試環境:
·?test.com
· Server2012 R2
1.先通過LDAP查詢獲得域內計算機的名稱,再通過DNS查詢獲得對應的IP
(1)SharpAdidnsdump
https://github.com/b4rtik/SharpAdidnsdump
C#實現,用于查詢DNS記錄。
用法:
SharpAdidnsdump test.com
獲得的結果完整,同dnscmd的結果一致
注:dnscmd的用法可以參考之前的文章《域滲透——DNS記錄的獲取》
(2)adidnsdump
https://github.com/dirkjanm/adidnsdump
https://dirkjanm.io/getting-in-the-zone-dumping-active-directory-dns-with-adidnsdump/
Python實現,用于查詢DNS記錄。
適用于Linux,由于需要安裝impacket,因此無法直接在Windows系統下使用。
安裝方法:
git clone https://github.com/SecureAuthCorp/impacket.git
cd impacket
pip install .
cd ..
git clone https://github.com/dirkjanm/adidnsdump
cd adidnsdump
pip install .
需要先獲得一個域用戶的憑據(明文口令或NTLM hash)。
用法1.直接遠程查詢:
adidnsdump -u test\\testuser1 -p test123! dc.test.com -r
用法2.通過socks代理進行查詢:
proxychains adidnsdump -u test\\testuser1 -p test123! dc.test.com -r --dns-tcp
注:還可以使用NTLM hash作為登錄憑據。
2.先通過LDAP查詢獲得DNS記錄,對二進制的DNS記錄進行解碼,獲得實際內容
(1)dns-dump
https://github.com/mmessano/PowerShell/blob/master/dns-dump.ps1
Powershell實現,用于查詢DNS記錄。
這個powershell腳本較為古老,我在我的測試環境Server2008R2和Server2012R2下均失敗。
經過分析,需要修改LDAP的查詢語句,新的腳本已上傳至github,地址如下:
https://github.com/3gstudent/Homework-of-Powershell/blob/master/dns-dump.ps1
用法:
Powershell -ep bypass -f dns-dump.ps1 -zone test.com
獲得的結果完整,同dnscmd的結果一致。
(2)PowerView
https://github.com/PowerShellMafia/PowerSploit/blob/master/Recon/PowerView.ps1
也可用于查詢DNS記錄。
其中的Convert-DNSRecord可用來對二進制的DNS記錄進行解碼:
https://github.com/PowerShellMafia/PowerSploit/blob/master/Recon/PowerView.ps1#L1814
用法如下:
import-module PowerView.ps1
Get-DNSRecord -ZoneName test.com
3.其他工具
(1)AdFind
C++實現(未開源),用于查詢域內信息。
http://www.joeware.net/freetools/tools/adfind/index.htm
常用命令如下:
列出域控制器名稱:
AdFind -sc dclist
查詢當前域中在線的計算機:
AdFind -sc computers_active
注:對應的LDAP查詢條件如下:
Transformed Filter: (&(objectcategory=computer)(!(useraccountcontrol:1.2.840.113556.1.4.803:=2))(pwdlastset>=131932198595370000)(|(!lastlogontimestamp=*)(&(lastlogontimestamp=*)(lastlogontimestamp>=131932198595370000))))
查詢當前域中在線的計算機(只顯示名稱和操作系統):
AdFind -sc computers_active name operatingSystem
查詢當前域中所有計算機:
AdFind -f "objectcategory=computer"
查詢當前域中所有計算機(只顯示名稱和操作系統):
AdFind -f "objectcategory=computer" name operatingSystem
查詢域內所有用戶:
AdFind -users name
查詢所有GPO:
AdFind -sc gpodmp
或
AdFind -gpo
注:查詢GPO對應之前的文章《域滲透——利用GPO中的計劃任務實現遠程執行》
0x04 小結
本文介紹了多種域普通用戶獲得DNS記錄的方法,適用于不同的環境,在實際使用過程中,某些情況下AdFind的查詢效率較低。
創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎總結
以上是生活随笔為你收集整理的ad域同步其他ldap账号_域渗透——普通用户权限获得DNS记录的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: java 函数签名,Java签名getA
- 下一篇: vue create()获取ref_vu