Skip to content

Instantly share code, notes, and snippets.

@jahands
Created August 3, 2017 19:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jahands/386a2b27658aea433c5602f41e163ef7 to your computer and use it in GitHub Desktop.
Save jahands/386a2b27658aea433c5602f41e163ef7 to your computer and use it in GitHub Desktop.
Function Send-PasswordHashesToDiscord {
<#
.SYNOPSIS
Sends password hashes from dump to Discord
#>
Param (
[string]$LastHash,
[switch]$FirstRun
)
$path = 'V:\NOBACKUP\TMP\pwned-passwords-1.0.txt'
$hook = 'https://discordapp.com/api/webhooks/<myhook>'
$statsHook = 'https://discordapp.com/api/webhooks/<myhook>'
$start = $false
if($FirstRun){
$start = $true
}
$msg = ''
$stats = @{}
$count = 0
$countSinceStatsPosted = 0
Get-Content $path | ForEach-Object {
$hash = $_
# Stats
$count++
foreach($c in $hash.ToString().ToCharArray()){
$stats[$c]++
}
# Process
if($start){
$countSinceStatsPosted++
$msg += $hash + "`n"
}elseif($hash -eq $LastHash){
$start = $true
Write-Output "Found last hash! Starting..."
}
if($msg.Length -ge (2000-40)){
try{
Send-DiscordMessage -Webhook $hook -Message $msg
}catch{
Write-Error 'Failed to send. Stopping' -ErrorAction:Stop
Send-DiscordMessage -Webhook $statsHook -Message "hmmm it seems there was an error! Last hash: $hash"
}
$msg = ''
Start-Sleep -Seconds 2
}
# Stats
if($countSinceStatsPosted -ge 1000){
$msg = @("Posted $count pwned passwords out of 306M"
"Time: $(Get-Date)"
"==================== **STATS** ==================="
"**Character frequency**"
'```'
($stats.GetEnumerator() | Sort-Object Name | Format-Table -AutoSize | Out-String)
'```'
) -join "`n"
Send-DiscordMessage -Webhook $statsHook -Message $msg
$countSinceStatsPosted = 0
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment