-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDNSenum.ps1
More file actions
executable file
·26 lines (20 loc) · 836 Bytes
/
DNSenum.ps1
File metadata and controls
executable file
·26 lines (20 loc) · 836 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# Purpose: A DNS enumeration tool that takes a file containing a list of host names as input and returns the IP addresses of those hosts.
# Usage: powershell -ExecutionPolicy Bypass -File .\DNSenum.ps1 [hosts.txt]
Import-Module DnsClient
# The number of commandline arguments is 0, error
if ($args.Count -eq 0) {
"Please specify a file containing hostnames to resolve";
exit;
}
# For each line in the given file
Get-Content $args[0] | ForEach-Object {
# Resolve the line as a hostname
$resolution_result = Resolve-DnsName -Name $_ -Type A -DnsOnly -ErrorAction SilentlyContinue
if ($resolution_result) {
# Output the IP address if address resolution was successful
"The IP address of $_ is " + $resolution_result.IPAddress
}
else {
"Failed resolving $_"
}
}