Last active
June 26, 2016 09:27
-
-
Save dhcgn/ea65c3b96bfb120cda18cf6fc4510883 to your computer and use it in GitHub Desktop.
Powershell script to test a domain for most common subdomains
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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 ++ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I change from sequential to parallel would have a great performance gain, but for demonstration purpose I want a simple script.