#include #include #include #include #include #include #include #include #include #include ;Declare local variable $HomeFolder to equal the home drive (C:\) and then combine it with the user's home directory with & (@HomeDrive & @HomePath) Local $HomeFolder = @HomeDrive & @HomePath ;Declare variable to set file location of the blacklist.txt $filepath = ($HomeFolder & "\Autoit\Blacklist\blacklist.txt") ;Declare variable $file to open the blacklist file $file = FileOpen($HomeFolder & "\Autoit\Blacklist\blacklist.txt", 0) ;Declare variable $read to perform the FileOpen on the blacklist file $read = FileRead($file) #Region $Form1 = GUICreate("Password Checker", 332, 126, 373, 136) $InfoTextBlock = GUICtrlCreateLabel("Enter the email and password to check below", 54, 8, 219, 17) $EmailAddressBox = GUICtrlCreateInput("Address", 91, 32, 153, 21) $PasswordBox = GUICtrlCreateInput("Password", 90, 63, 153, 21) $CheckButton = GUICtrlCreateButton("Check!", 50, 89, 113, 25) $CancelButton = GUICtrlCreateButton("Cancel", 168, 89, 113, 25) GUISetState(@SW_SHOW) #EndRegion Func CheckExistsBlacklistFile() ;Check to make sure the blacklist.txt can be found/read from, exit otherwise If Not FileExists($filepath) Then MsgBox(0, "Validation failed!", "The blacklist file is missing, cannot validate the password! Please contact Batman!") Exit EndIf EndFunc ;==>CheckExistsBlacklistFile Func uppercheck() $password = GUICtrlRead($PasswordBox) $UpperCaseCheck = StringRegExp($password, '[A-Z\s]+', 0) If $UpperCaseCheck = 0 Then MsgBox(0, "Uppercase check results", "Uppercase letter not detected. Please suggest another password.") Exit EndIf EndFunc ;==>uppercheck Func lowercheck() ;Lowercase check begin $password = GUICtrlRead($PasswordBox) $LowerCaseCheck = StringRegExp($password, '[a-z\s]+', 0) If $LowerCaseCheck = 0 Then MsgBox(0, "Lowercase check results", "Lowercase letter not detected. Please suggest another password.") Exit EndIf EndFunc ;==>lowercheck Func symbolcheck() ;Symbol check begin $password = GUICtrlRead($PasswordBox) $SymbolCheck = StringRegExp($password, '[0-9\W]+', 0) If $SymbolCheck = 0 Then MsgBox(0, "Symbol check results", "Symbol not detected. Please suggest another password.") Exit EndIf EndFunc ;==>symbolcheck Func blacklistcheck() ;If the blacklist.txt was found, blacklistcheck function opens the file for reading and performs a regex search on the input $password variable to check for a matching blacklisted word/term. $password = GUICtrlRead($PasswordBox) If StringRegExp($read, $password) Then MsgBox(0, "Password Invalid", "Password contains a commonly used word/number combination and is invalid. Please suggest a new password!") Exit EndIf EndFunc ;==>blacklistcheck Func PasswordLengthCheck() ;Use StringLen to count the number of characters in the password. If it is less than 6 or more than 40 then return error to user. $password = GUICtrlRead($PasswordBox) If StringLen($password) < 6 Then MsgBox(0, "Password too short", "Please suggest a password at least six characters long.") Exit EndIf If StringLen($password) > 40 Then MsgBox(0, "Password too long.", "Please suggest a password less than forty characters long.") Exit EndIf EndFunc ;==>PasswordLengthCheck Func EmailPasswordCompare() $password = GUICtrlRead($PasswordBox) $emailpassword = GUICtrlRead($EmailAddressBox) If StringRegExp($password, $emailpassword) Then MsgBox(0, "Password invalid", "Password cannot contain a portion of the email address! Example - if the email address is bob@etex.net, the password cannot be Bob123!") Exit EndIf EndFunc ;==>EmailPasswordCompare While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case ($CancelButton) Exit Case ($CheckButton) Call(CheckExistsBlacklistFile) Call(PasswordLengthCheck) Call(blacklistcheck) Call(uppercheck) Call(lowercheck) Call(symbolcheck) Call(EmailPasswordCompare) MsgBox(0, "Password is Valid", "The password passed all the complexity requirement checks. The password has been copied into the clipboard to enter into the system.") $password = GUICtrlRead($PasswordBox) ClipPut($password) FileClose($file) Exit EndSwitch WEnd