Search This Blog

Thursday, December 18, 2014

Powershell - Perfect Passwords

In homage to the folks at the Gibson Research Corporation and their Perfect Passwords page, which has been up for as long as I can remember, I present the following...

Make sure to check out their How Big is Your Haystack? page too.

I was reading about strings in Powershell and realized I could pretty easily make a random string generator similar to the folks at GRC.


PerfectPassword.ps1
$strChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%^&*()`~-_=+[]{}\/|?<>,.;':"""
$strResult = ""
$strResult = For ($i=1; $i -lt 65; $i++){$StrResult + $strChars.substring((get-random 93),1)}
[string]::concat("Printable ascii: ", ($strResult -join ""))

$strChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"
$strResult = ""
$strResult = For ($i=1; $i -lt 65; $i++){$StrResult + $strChars.substring((get-random 62),1)}
[string]::concat("Alpha numeric:   ", ($strResult -join ""))

$strChars = "0123456789ABCDEF"
$strResult = ""
$strResult = For ($i=1; $i -lt 65; $i++){$StrResult + $strChars.substring((get-random 16),1)}
[string]::concat("Hex:             ", ($strResult -join ""))

$strResult = ""
$strResult = For ($i=1; $i -lt 65; $i++){$StrResult + "0123456789ABCDEF".substring((get-random 16),1)}
[string]::concat("Hex without arg: ", ($strResult -join ""))

$strChars = "ÆƷűʘ ̊░▒▓"
$strResult = ""
$strResult = For ($i=1; $i -lt 65; $i++){$StrResult + $strChars.substring((get-random $strChars.length),1)}
[string]::concat("Silly string:    ", ($strResult -join ""))


Generated the following ...
PS D:\> ./perfectpassword.ps1
Printable ascii: O2c5:sf%4Qn>ckr_6oz-DEGhadY8/{Qw5XOQ2TnJ7WdbqP%[D^.dK=aju.5.9N+*
Alpha numeric:   a5uFPTohb4kXsv5ItStk5A1XGvoM4mTmRsaqhnjKEZaEOmX3ccN6gOZJdG9uFLoY
Hex:             2F105A618BA16525859D9C1076393D1E935A1C869855FC2B6AC20645D08E7DDB
hex without arg: AC73073BC3306B0B47390ED3EFC04AFCAAB34FBE615D23F20DAFA4BBE440A272
Silly string:    ű ʘ░Æ▒ ʘ░űƷ▓̊ÆÆ░Æ Æ ÆÆƷ ▓▓ű▓  űű̊Ʒ  ▒ƷƷƷ ʘƷʘÆ░Ʒ▒ű̊Æ▓ƷÆƷűʘ▓▒Æ̊  Ʒ

PS D:\> ./perfectpassword.ps1
Printable ascii: b|JLNI{]V/;%]~Et{M*k3zoVgJEVJ
Alpha numeric:   r8cZBh2h83yxW7yPaUsQ9DtiBJDEyzZWRf7jwHhEWblYhm8XCPcrMZzXN4y2OxTI
Hex:             0AABF347ADEF48039A0B582DA28724D64AC884C359ACE781E24F50387C0DBD45
hex without arg: F8AAB8B5EC5CE5F3A690FD04740B4F7844D6DD666E18A692DC3544617537701E
Silly string:    ű▒ ̊  ʘ░ÆƷ̊Æ░ ̊Æ̊▓▒ ░ƷűÆ▓░▓ ̊▓▓ʘ▒Ʒű▒▓Æ̊űʘ űÆ░űʘ▓░Ʒ▒̊Ʒ̊űƷ̊ ░▒̊▓ƷƷ

PS D:\> ./perfectpassword.ps1
Printable ascii: Cpv3w[g5y1ex[qC5Hb~OeBAv,jvSG{&VDs~Xh)%}lwE11;DLohM1m#ha\"8m44xM
Alpha numeric:   ZG7NyWGKs5tX8SP9XZtrAkxMhVOfiJqG05TcbPaxHZqnxrcjuPvWr99OjtGNiBCS
Hex:             ACC0FAF1DFB9E23DB7C73730F1EB263168997F2BB3F536BF1BEABF728C1EB3F6
Hex without arg: BA369A5B50C08EC85EA77966060AE4F748A92566525A37AA088D98F13D52AAD0
Silly string:    Æű░▓űƷʘ▓ űƷűű░Ʒ̊▒ʘ̊ű░Ʒ▓░̊̊ʘűÆű░̊űű ▓░̊ʘ▒Ʒ̊ʘűʘ̊▒ ░░ʘűÆ ű▓ʘ▓ʘ░░Æ▓Ʒ


There is some extra stuff I was playing around with in there.

The Silly string was made using the Character Map accessory.