Last active
March 2, 2018 21:13
-
-
Save ryancbutler/3353ce1bc4807056b875fb3eba456f4a to your computer and use it in GitHub Desktop.
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
#RUN AS ADMIN. WILL ERROR OUT ON CONNECTION | |
CLS | |
#SET TLS 1.2 | |
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 | |
Function Get-StringHash([String] $String,$HashName = "MD5") | |
{ | |
$StringBuilder = New-Object System.Text.StringBuilder | |
[System.Security.Cryptography.HashAlgorithm]::Create($HashName).ComputeHash([System.Text.Encoding]::UTF8.GetBytes($String))|%{ | |
[Void]$StringBuilder.Append($_.ToString("x2")) | |
} | |
$StringBuilder.ToString() | |
} | |
#KEEPASS EXPORT CSV | |
$mycsvpath = "D:\temp\mykeepassexport.csv" | |
$passwordcsv = Import-Csv -Path $mycsvpath | |
$passwords = $passwordcsv|select password|sort password|get-unique -asstring | |
foreach ($password in $passwords) | |
{ | |
$hash = Get-StringHash $password.password "SHA1" | |
$hash4 = $hash.Substring(0,5) | |
$hashsub = $hash.Substring(5) | |
$ami = Invoke-RestMethod "https://api.pwnedpasswords.com/range/$hash4" -UseBasicParsing -ContentType "application\json" | |
$amiarray = @() | |
$amiarray = ($ami -split '[\r\n]') |? {$_} | |
$found = $null | |
$found = $amiarray|?{$_ -like "$hashsub*"} | |
if ($found) | |
{ | |
$temp = $found -split ":" | |
write-host "FOUND: $hash $($temp[1]) times for Password: $($password.password)" -ForegroundColor Red | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment