内网渗透 | 域内DNS信息收集工具编写

admin 2021年12月11日21:43:02评论151 views字数 1753阅读5分50秒阅读模式

域内DNS信息收集

在一个大型的内网环境当中,如果我们在不确定目标资产定位在哪里我们就可以通过dns去定位,当然也可以通过活动目录集成的dns服务。

这里举例DC Locator Process

内网渗透 | 域内DNS信息收集工具编写

ffDAQa.png

第一步它会询问_ldap._tcp.dc._msdcs.contoso.com注册记录是什么,dns就会返回所有的域控。

内网渗透 | 域内DNS信息收集工具编写

ffDMDu.png

内网渗透 | 域内DNS信息收集工具编写

ffDWiD.png

dnscmd

dnscmd.exe . /EnumRecords redteam.local .

内网渗透 | 域内DNS信息收集工具编写

ffD7Ti.png
dnscmd /zoneexport redteam.local redteam.local.dns.txt 

内网渗透 | 域内DNS信息收集工具编写

ffDvtL.png

SharpAdidnsdump

内网渗透 | 域内DNS信息收集工具编写

ffD35W.png

这里我们也可以通过获取域内机器然后通过Dns.GetHostEntry解析ip。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.DirectoryServices;
using System.Net;

namespace QueryDomainIp
{
    class Program
    {
        static void Main(string[] args)
        {
            DirectoryEntry coon = new DirectoryEntry();
            DirectorySearcher search = new DirectorySearcher(coon);
            search.Filter = "(&(objectclass=computer))";
            try
            {
                foreach (SearchResult r in search.FindAll())
                {
                    string computername = "";
                    computername = r.Properties["cn"][0].ToString();
                    IPHostEntry hostInfo = Dns.GetHostEntry(computername);
                    foreach (IPAddress result_ip in hostInfo.AddressList)
                    {
                        Console.WriteLine("HostName:{0} IP:{1}", computername, result_ip);
                    }
                }
            }
            catch (System.Exception ex)
            {
                Console.WriteLine("[-] error");
                Console.WriteLine("[-] Exception: " + ex.Message);
            }
        }
    }
}

内网渗透 | 域内DNS信息收集工具编写

ffDNXw.png

PowerView.ps1

import-module PowerView.ps1
Get-DNSRecord -ZoneName redteam.local

内网渗透 | 域内DNS信息收集工具编写

ffDayR.png

内网渗透 | 域内DNS信息收集工具编写


推荐阅读:


内网渗透 | 域渗透之Dcsync的利用实战


实战|内网渗透hash窃取技巧


内网渗透|LAPS的使用小技巧


内网渗透 | 横向移动中MSTSC的密码获取


内网渗透 | 内网穿透之多层代理


点赞,转发,在看


内网渗透 | 域内DNS信息收集工具编写

原文始发于微信公众号(HACK学习呀):内网渗透 | 域内DNS信息收集工具编写

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2021年12月11日21:43:02
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   内网渗透 | 域内DNS信息收集工具编写http://cn-sec.com/archives/671418.html

发表评论

匿名网友 填写信息