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

栏目: 编程工具 · 发布时间: 7年前

内容简介:在之前的文章本文将会参考公开的资料,整理域普通用户获得DNS记录的方法,修复dns-dump.ps1在高版本Windows系统下的bug。0x01 简介

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))(!(<a href="/cdn-cgi/l/email-protection" data-cfemail="2561661865">[email protected]</a>))(!(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的查询效率较低。


以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

The Sovereign Individual

The Sovereign Individual

James Dale Davidson、William Rees-Mogg / Free Press / 1999-08-26 / USD 16.00

Two renowned investment advisors and authors of the bestseller The Great Reckoning bring to light both currents of disaster and the potential for prosperity and renewal in the face of radical changes ......一起来看看 《The Sovereign Individual》 这本书的介绍吧!

MD5 加密
MD5 加密

MD5 加密工具

正则表达式在线测试
正则表达式在线测试

正则表达式在线测试

RGB CMYK 转换工具
RGB CMYK 转换工具

RGB CMYK 互转工具