File tree Expand file tree Collapse file tree 1 file changed +65
-0
lines changed Expand file tree Collapse file tree 1 file changed +65
-0
lines changed Original file line number Diff line number Diff line change 1+ function Get-DomainSubdomains {
2+ <#
3+ . SYNOPSIS
4+ Discover sub-domains in a domain.
5+
6+ . DESCRIPTION
7+ This function uses the VirusTotal API to discover subdomains in a given domain namespace.
8+
9+ . PARAMETER Domain
10+ The domain to check for subdomains.
11+
12+ . EXAMPLE
13+ Get-DomainSubdomains -Domain 'example.com'
14+
15+ . NOTES
16+ This requires a VirusTotal API key.
17+
18+ #>
19+ [CmdletBinding ()]
20+ param (
21+ # The domain to discover subdomains in
22+ [Parameter (Mandatory , Position = 0 , ValueFromPipeline )]
23+ [string ]
24+ $Domain ,
25+
26+ # Your VirusTotal API key. (Need to make this more secure, but it's a working POC.)
27+ [Parameter (Position = 1 )]
28+ $VtApiKey
29+ )
30+
31+ begin {
32+
33+ }
34+
35+ process {
36+ $IrmParams = @ {
37+ Uri = " https://www.virustotal.com/api/v3/domains/$Domain /subdomains"
38+ Method = ' GET'
39+ Headers = @ {
40+ ' X-ApiKey' = $VtApiKey
41+ ' Content-Type' = ' application/json'
42+ }
43+ }
44+ $Subdomains = ( (Invoke-RestMethod @IrmParams ) | ConvertFrom-Json ).data
45+ $Subdomains.id
46+
47+ <# Output 👀
48+ elections.x.com
49+ transparency-staging.x.com
50+ about-dev.x.com
51+ careers-dev.x.com
52+ engineering.x.com
53+ gdpr-dev.x.com
54+ insights.x.com
55+ legal-dev.x.com
56+ marketing-dev.x.com
57+ partners-dev.x.com
58+ #>
59+
60+ }
61+
62+ end {
63+
64+ }
65+ }
You can’t perform that action at this time.
0 commit comments