域渗透——普通用户权限获得DNS记录 - 嘶吼 RoarTalk – 网络安全行业综合服务平台,4hou.com

域渗透——普通用户权限获得DNS记录

3gstudent 技术 2019-05-20 09:15:44
582360
收藏

导语:本文介绍了多种域普通用户获得DNS记录的方法,适用于不同的环境,在实际使用过程中,某些情况下AdFind的查询效率较低。

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的查询效率较低。

  • 分享至
取消

感谢您的支持,我会继续努力的!

扫码支持

打开微信扫一扫后点击右上角即可分享哟

发表评论

 
本站4hou.com,所使用的字体和图片文字等素材部分来源于原作者或互联网共享平台。如使用任何字体和图片文字有侵犯其版权所有方的,嘶吼将配合联系原作者核实,并做出删除处理。
©2022 北京嘶吼文化传媒有限公司 京ICP备16063439号-1 本站由 提供云计算服务