Huddled Masses
The internet home of Joel "Jaykul" Bennett...
Browse: Home / 2008 Scripting Games – Solution for Advanced Event 5

2008 Scripting Games – Solution for Advanced Event 5

By Joel 'Jaykul' Bennett on 28-Feb-2008

This continues my series of solution posts for the 2008 Scripting Games with my solution for the Advanced Event 5 which was a joke of a challenge — basically you have to run an arbitrary set of password “strength” rules over a string. The rules are not very complete, and result in such vagaries as “PASSword” getting a worse score than “Password” ... and my randomly generated “KiVExXwMxocScnIjUinCTKTA” getting a WORSE score than “PassWord1” ...

Anyway. Here’s the script, just for the sake of completeness. Please don’t use it for anything you care about ;) .


param([string]$password="a")
$score = 13
$words = get-content wordlist.txt;
if($words -contains $password) {
   $score--
   "Password is an actual word"
}

if( $words -contains ($password.SubString(0,$password.Length-1))) {
   $score--
   "Password begins with an actual word"
}

if( $words -contains ($password.SubString(1,$password.Length-1))) {
   $score--
   "Password ends with an actual word"
}

if( $password.contains("0") -and ($words -contains ($password -replace "0","o"))) {
   $score--
   "Password is an actual word, with o=>0 replacement"
}

if( $password.contains("1") -and ($words -contains ($password -replace "1","l"))) {
   $score--
   "Password is an actual word, with l=>1 replacement"
}

if( $password.Length -lt 10 ) {
   $score--
   "Password doesn't have at least 10 characters"
}

if( $password.Length -gt 20 ) {
   $score--
   "Password has more than 20 characters"
}

if( -not ($password -match "\d") ) {
   $score--
   "Password has no numbers"
}

if( -not ($password -cmatch "[A-Z]") ) {
   $score--
   "Password has no uppercase letters"
}

if( -not ($password -cmatch "[a-z]") ) {
   $score--
   "Password has no lowercase letters"
}

if( -not ($password -match "[^a-zA-Z0-9]") ) {
   $score--
   "Password has no symbols"
}

if( $password -cmatch "[a-z]{4}" ) {
   $score--
   "Password has four consecutive lowercase letters"
}

if( $password -cmatch "[A-Z]{4}" ) {
   $score--
   "Password has four consecutive uppercase letters"
}

if($password.ToCharArray() | group -case | ? {$_.Count -gt 1}){
   $score--
   "Password has some duplicate characters"
}

if($score -le 6)
{"Your password score of $score indicates a weak password."}
elseif(($score -gt 6) -and ($score -lt 11))
{"Your password score of $score indicates a moderately-strong password."}
elseif($score -ge 11)
{"Your password score of $score indicates a strong password."}

Similar Posts:

  • The problem with calling legacy/native apps from PowerShell
  • Better error messages for PowerShell ValidatePattern
  • Parenthesis in PowerShell
  • A DSL for XML in PowerShell: New-XDocument
  • Working with multiple versions of PowerShell Modules

Posted in Huddled | Tagged 2008 Scripting Games, PowerShell, Scripting, Solutions

« Previous Next »

Lijit Search

Tags

.Net .Net 2008 Scripting Games Automation Bugs Design Development Funny Gadgets GeoShell GUI Huddled Masses Internet licensing Microsoft Modules My Software News Personal PInvoke Pipeline Politics PoshCode PoshConsole PowerBoots PowerShell PowerShell Functions PowerTips Rants Recommender Repository Scripting ShowUI Software Solutions Textile Tips User Group UserInterface WalkThrough WebHosting Windows 7 WordPress WPF Xml

About Huddled Masses

This is web site is dedicated to the musings of Joel Bennett (aka Jaykul) about technology, software, software development, the web, and the world.

Any resemblance of the views expressed and the views of my employer, my terminal, or the view out my window are purely coincidental. The resemblance between them and my own views is non-deterministic. The question of the existence of views in the absence of anyone to hold them is left as an exercise for the reader.

P.S.: I occasionally link to things I think are great. When I do, I occasionally find a "referral code" so I can make a little cash. I promise that I don't link to anything just because of that cash (I wouldn't cross the street for the amount of cash those links bring in, never mind write a whole blog post) ... but I do not promise that things I link to will stay great as time passes, nor that you will agree with me about their greatness!

Archives

  • January 2012
  • October 2011
  • August 2011
  • July 2011
  • June 2011
  • March 2011
  • February 2011
  • January 2011
  • November 2010
  • August 2010

Copyright © 2012 Joel Bennett.

Powered by WordPress and Hybrid.