· 5 years ago · Sep 02, 2020, 07:00 AM
1$wr = Invoke-WebRequest 'https://www.stortinget.no/no/Stottemeny/kontakt/Partier-og-representanter/Representantenes-e-postadresser/' -UseBasicParsing
2$emails = [regex]::Matches($wr.Content, "[a-zA-Z\.]+@stortinget\.no") | Select -ExpandProperty Value | sort -Unique
3$apikey = read-host -Prompt "HaveIBeenPwned.com API KEY"
4$leaks = $emails | Foreach {
5 Write-Verbose $_ -Verbose
6 [PSCustomObject] @{
7 Email = $_
8 Leaks = Invoke-RestMethod -Uri "https://haveibeenpwned.com/api/v3/breachedaccount/$($_)" -Headers @{"hibp-api-key" = $apikey}
9 }
10 sleep -Seconds 1.5
11}
12
13$list = $leaks | ? Leaks | Foreach {
14 $e = $_.Email
15 $_.Leaks | Foreach {
16 [PSCustomObject] @{
17 Email = $e
18 Leak = $_.Name
19 }
20 }
21}
22$list | out-gridview