Add to Technorati Favorites
Welcome to ThePowerShellGuy.com Sign in | Join | Help

Scripting Games 2008 Advanced Windows PowerShell Event 5

Also on this event I was a bit lazy and mostly copied and pasted the lines.

PARAM ($Password)

$wl = gc c:\scripts\WordList.txt

$Score = 13
&{
 if ($wl -contains $password) {Write-warning "Password is word";$score--;return}
 if ($wl -contains $password.replace('0','o')) {Write-warning "Password simply substitute 0 (zero) for the letter o";$score--;return}
 if ($wl -contains $password.replace('1','l')) {Write-warning "Password simply substitute 1 (one) for the letter i";$score--}
}
if ($wl -contains $password.Remove($password.length -1,1)) {Write-warning "Password minus the last letter is word";$score--}
if ($wl -contains $password.Remove(0,1)) {Write-warning "Password minus the first letter is word";$score--}
if ($password.length -lt 10) {Write-warning "Not at least 10 characters long but no more than 20 characters ";$score--}
if ($password.length -gt 20) {Write-warning "Not at least 10 characters long but no more than 20 characters ";$score--}
if ($password -notmatch '\d') {Write-warning "Not at least one number";$score--}
if ($password -cnotmatch '[A-Z]') {Write-warning "Not at least one uppercase letter";$score--}
if ($password -cnotmatch '[a-z]') {Write-warning "Not at least one lowercase letter";$score--}
if ($password -notmatch '\W') {Write-warning "Not at least one Special Character";$score--}
if ($password -cmatch '[A-Z]{4,}') {Write-warning "four (or more) uppercase letters in succession";$score--}
if ($password -cmatch '[a-z]{4,}') {Write-warning "four (or more) lowercase letters in succession";$score--}
if ($password.ToCharArray() | group |? {$_.count -gt 1}) {Write-warning "duplicate characters";$score--}

switch ($Score) { 
  {$_ -le 6} {"A password score of $score indicates a weak password";break}
  {$_ -le 10} {"A password score of $score indicates a moderately-strong password"}
  {$_ -gt 10} {"A password score of $score indicates a strong password"}
}

I used the &{} block to escape the 1 or 0 replacement checking for the Word, to make a word only cost 1 point

Enjoy,

Greetings /\/\o\/\/

Published Tuesday, February 26, 2008 3:47 PM by MoW

Comments

# Scripting Games: Advanced PowerShell - Event 5 « PowerShell ?? ???????????? ??????????????

Anonymous comments are disabled