Skip to content

Instantly share code, notes, and snippets.

@dhcgn
Last active June 26, 2016 09:27
Show Gist options
  • Save dhcgn/ea65c3b96bfb120cda18cf6fc4510883 to your computer and use it in GitHub Desktop.
Save dhcgn/ea65c3b96bfb120cda18cf6fc4510883 to your computer and use it in GitHub Desktop.
Powershell script to test a domain for most common subdomains
$serverName = "example.org"
$url = 'https://raw.githubusercontent.com/rbsec/dnscan/master/subdomains-10000.txt'
$subdomains = ((Invoke-WebRequest -Uri $url -UseBasicParsing).Content).Split("`n")
$subdomainsCount = $subdomains.Length
Write-Host ('Will test {0} entries' -f $subdomainsCount)
$count = 1
foreach ($subdomain in $subdomains)
{
$testHost = ('{0}.{1}' -f $subdomain, $serverName)
Write-Progress -Activity "Testing SubDomains" -Status "Test Host $testHost ($count from $subdomainsCount)" -PercentComplete (($count/$subdomainsCount)*100)
$result = $null
$result = Resolve-DnsName -Name $testHost -DnsOnly -Type A -ErrorAction SilentlyContinue
if($result -ne $null)
{
Write-Host ('Got information about {0}' -f $testHost )
Write-Output $result
}
$count ++
}
@dhcgn
Copy link
Author

dhcgn commented Jun 26, 2016

I change from sequential to parallel would have a great performance gain, but for demonstration purpose I want a simple script.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment