Skip to content

Instantly share code, notes, and snippets.

@0xbadjuju
Last active December 12, 2017 17:27
Show Gist options
  • Save 0xbadjuju/6d69e4e32a77905415f0141758f749bb to your computer and use it in GitHub Desktop.
Save 0xbadjuju/6d69e4e32a77905415f0141758f749bb to your computer and use it in GitHub Desktop.
Get-Emails
Function Get-EmailsHunter()
{
[CmdletBinding()]
Param(
[Parameter(Mandatory=$True, HelpMessage="Domain to harvest.")]
[String]$Domain,
[Parameter(Mandatory=$True, HelpMessage="https://hunter.io/api_keys")]
[string]$ApiKey
)
$offset=0;
while ($true) {
$webrequest = Invoke-WebRequest -Uri "https://api.hunter.io/v2/domain-search?domain=$domain&limit=100&offset=$offset&api_key=$ApiKey";
if ($webrequest.StatusCode -ne 200)
{
return;
}
$json = ConvertFrom-Json -InputObject $webrequest;
$emails = [string[]]$json.data.emails.value;
$emails | %{ $_ | Tee-Object -Append -FilePath "$($domain)_hunter_emails.txt" };
if ($emails.Count -lt 100)
{
return;
}
$offset += 100;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment