內網滲透:域內DNS信息收集工具編寫
VSole2021-12-15 06:48:15
域內DNS信息收集
在一個大型的內網環境當中,如果我們在不確定目標資產定位在哪里我們就可以通過dns去定位,當然也可以通過活動目錄集成的dns服務。
這里舉例DC Locator Process

ffDAQa.png
第一步它會詢問_ldap._tcp.dc._msdcs.contoso.com注冊記錄是什么,dns就會返回所有的域控。

ffDMDu.png

ffDWiD.png
dnscmd
dnscmd.exe . /EnumRecords redteam.local .

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

ffDvtL.png
SharpAdidnsdump

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);
}
}
}
}

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

ffDayR.png
VSole
網絡安全專家