guinness Posted August 13, 2013 Share Posted August 13, 2013 Did I do something wrong? Edano 1 UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
jazzyjeff Posted August 13, 2013 Author Share Posted August 13, 2013 Thanks Guiness, I'll try this out. Link to comment Share on other sites More sharing options...
kylomas Posted August 13, 2013 Share Posted August 13, 2013 (edited) Did I do something wrong? No. The requirements seem to be expanding/changing... edit: @guiness - does this '(.)1' mean any character followed by itself (because it was the previous capture)? Edited August 13, 2013 by kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
jchd Posted August 13, 2013 Share Posted August 13, 2013 Correct. (.) has capture number 1 and 1 is backreference to it. So that it matches "aa", "abbc", etc. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
kylomas Posted August 13, 2013 Share Posted August 13, 2013 @jchd - Thanks Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
guinness Posted August 13, 2013 Share Posted August 13, 2013 I thought my expression was wrong, but that's what I wanted it to do. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
jazzyjeff Posted August 14, 2013 Author Share Posted August 14, 2013 Hey everyone, So I thought this was working perfect, but while it is better, it unfortunately isn't perfect. So the issue is still trying to pick out 3 consecutive characters that appear in the typed password and see if they appear in the username of the person who runs the script. The username is: wshtechs The password is: Il0veWSH Both the username and password contain "WSH". Unfortunately the script isn't picking this out. If I set the password to: Ilovetec1 The script see's that the username contains "tec" and brings up a message. JCHD provided some code to use the StringRegExp function and I was able to use a for loop to extract each letter and put it into the string with the formula that JCHD provided. $arrayString = StringSplit(GUICtrlRead($txtPassword),"") ;_ArrayDisplay($arrayString) Global $string = "" For $i = 1 To $arrayString[0] $string = $string & $arrayString[$i] & "?" Next $arrayString1 = StringRegExp($rUser, "(" & $string & ")", 3) $arrayTotal = UBound($arrayString1) Global $passwordString = "" For $i = 0 To $arrayTotal - 1 If StringLen($arrayString1[$i]) = 3 Then $passwordString = $arrayString1[$i] ExitLoop EndIf Next This seems to work great for some password's, but not all. Sorry to be a pain, but I am just throwing it back out there to see if anyone else has any other ideas/solutions for this. Here is the full script. expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <Array.au3> #include <AD.au3> #include <Crypt.au3> #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <Misc.au3> $lower = 0 $upper = 0 $digit = 0 $special = 0 $pwChange = 0 Global $newPassword, $val $rUser = @UserName HotKeySet("{LWIN}","_Windows") HotKeySet("{RWIN}","_Windows") #Region ### START Koda GUI section ### Form= $formBKG = GUICreate("",@DesktopWidth, @DesktopHeight, 0, 0,$WS_POPUP) GUISetBkColor(0x000000) GUISetState(@SW_SHOW) $formMain = GUICreate("Password Utility", 664, 200, -1,-1) $lblPassword = GUICtrlCreateLabel("Your Password has expired. Please enter a new password for your account.", 8, 8, 288, 37) $txtPassword = GUICtrlCreateInput("", 8, 45, 281, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_PASSWORD)) $txtPasswordConfirm = GUICtrlCreateInput("", 8, 75, 281, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_PASSWORD)) $btnPassword = GUICtrlCreateButton("Set Password", 216, 115, 75, 25) $lblSuggestions = GUICtrlCreateLabel("", 8, 150, 300, 50) $lblFname = GUICtrlCreateLabel("First Name: ", 420, 8, 237, 17) $lblLName = GUICtrlCreateLabel("Last Name: ", 420, 37, 237, 17) $lblUName = GUICtrlCreateLabel("Username: ", 420, 66, 237, 17) $lblID = GUICtrlCreateLabel("Student ID: ", 420, 95, 237, 17) $lblPasswordExp = GUICtrlCreateLabel("Password Expiration:", 420, 128, 237, 17) GUISetState(@SW_SHOW) ;_ArrayDisplay($winPos) WinSetOnTop("Password Utility","",1) #EndRegion ### END Koda GUI section ### _AD_Open() $objProperties = _AD_GetObjectProperties($rUser) $objCN = _AD_GetObjectProperties($rUser,"cn") $objGivenName = _AD_GetObjectProperties($rUser,"givenName") $objEmployeeID = _AD_GetObjectProperties($rUser,"employeeID") $objSN = _AD_GetObjectProperties($rUser,"sn") $objPWExpiration = _AD_GetObjectProperties($rUser,"msDS-UserPasswordExpiryTimeComputed") $objFQDN = _AD_GetObjectProperties($rUser,"distinguishedName") If IsArray($objCN) Then If $objCN[0][0] <> 0 Then $userName = $objCN[1][1] Else $userNameName = "Unavailable" EndIf EndIf If IsArray($objSN) Then If $objSN[0][0] <> 0 Then $lastName = $objSN[1][1] Else $lastName = "Unavailable" EndIf EndIf If IsArray($objGivenName) Then If $objGivenName[0][0] <> 0 Then $firstName = $objGivenName[1][1] Else $firstName = "Unavailable" EndIf EndIf If IsArray($objEmployeeID) Then If $objEmployeeID[0][0] <> 0 Then $employeeID = $objEmployeeID[1][1] Else $employeeID = "Unavailable" EndIf EndIf If IsArray($objPWExpiration) Then If $objPWExpiration[0][0] <> 0 Then $pwExpiration = $objPWExpiration[1][1] Else $pwExpiration = "Unavailable" EndIf EndIf ;_ArrayDisplay($objProperties) _AD_Close() GUICtrlSetData($lblFname,"First Name: " & $firstName) GUICtrlSetData($lblLName,"Last Name: " & $lastName) GUICtrlSetData($lblUName,"Username: " & $userName) GUICtrlSetData($lblID,"Student ID: " & $employeeID) GUICtrlSetData($lblPasswordExp,"Password Expiration: " & $pwExpiration) $Pic1 = GUICtrlCreatePic("C:\" & $employeeID & ".jpg", 312, 8, 100, 108) While 1 $winPos = WinGetPos("Password Utility") _MouseTrap($winPos[0],$winPos[1],$winPos[2],$winPos[3]) $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $btnPassword GUICtrlSetData($lblSuggestions,"") $pwChange = 0 $lower = 0 $upper = 0 $digit = 0 $special = 0 If GUICtrlRead($txtPassword) = GUICtrlRead($txtPasswordConfirm) Then $stringLen = StringLen(GUICtrlRead($txtPassword)) $stringUp = StringIsUpper(GUICtrlRead($txtPassword)) $stringLow = StringIsLower(GUICtrlRead($txtPassword)) $stringDig = StringIsDigit(GUICtrlRead($txtPassword)) $arrayString = StringSplit(GUICtrlRead($txtPassword),"") ;_ArrayDisplay($arrayString) Global $string = "" For $i = 1 To $arrayString[0] $string = $string & $arrayString[$i] & "?" Next $arrayString1 = StringRegExp($rUser, "(" & $string & ")", 3) $arrayTotal = UBound($arrayString1) Global $passwordString = "" For $i = 0 To $arrayTotal - 1 If StringLen($arrayString1[$i]) = 3 Then $passwordString = $arrayString1[$i] ExitLoop EndIf Next _ArrayDisplay($arrayString1) MsgBox(0,"","Password String: " & $passwordString & @CR & "String: " & $string) If $stringLen < 8 Then GUICtrlSetData($lblSuggestions,"Password not long enough. You used " & $stringLen & " characters and you need to use at least 8.") GUICtrlSetData($txtPasswordConfirm,"") GUICtrlSetData($txtPassword,"") ElseIf $stringUp = 1 Then For $i = 1 To $arrayString[0] If StringIsUpper($arrayString[$i]) Then $val = $i ExitLoop EndIf Next $lowerPassword = StringLower($arrayString[$val]) _ArrayDelete($arrayString,$val) $arrayPassword = _ArrayInsert($arrayString,$val,$lowerPassword) $newPassword = _ArrayToString($arrayString,"") $digitPassword = Random(1,99,1) GUICtrlSetData($lblSuggestions,"Password only upper case. You could try this as your new password." & @CR & StringTrimLeft($newPassword,1) & $digitPassword) GUICtrlSetData($txtPasswordConfirm,"") GUICtrlSetData($txtPassword,"") ElseIf $stringLow = 1 Then For $i = 1 To $arrayString[0] If StringIsLower($arrayString[$i]) Then $val = $i ExitLoop EndIf Next $upperPassword = StringUpper($arrayString[$val]) _ArrayDelete($arrayString,$val) $arrayPassword = _ArrayInsert($arrayString,$val,$upperPassword) $newPassword = _ArrayToString($arrayString,"") $digitPassword = Random(1,99,1) GUICtrlSetData($lblSuggestions,"Password only lower case. You could try this as your new password." & @CR & StringTrimLeft($newPassword,1) & $digitPassword) GUICtrlSetData($txtPasswordConfirm,"") GUICtrlSetData($txtPassword,"") ElseIf $stringDig = 1 Then GUICtrlSetData($lblSuggestions,"Password only digits. Please add some characters to the password, with at least 1 upper case and 1 lower case letter.") GUICtrlSetData($txtPasswordConfirm,"") GUICtrlSetData($txtPassword,"") ElseIf StringInStr($rUser,$passwordString) And StringLen($passwordString) > 2 Then GUICtrlSetData($lblSuggestions,"Password contains part of the username. There are at least 3 consecutive characters in your name that you have used for your password. The 3 consecutive letters are, " & $passwordString & ".") GUICtrlSetData($txtPasswordConfirm,"") GUICtrlSetData($txtPassword,"") ElseIf StringIsAlNum(GUICtrlRead($txtPassword)) Then For $i = 1 To $arrayString[0] If StringIsUpper($arrayString[$i]) Then $upper = 1 EndIf If StringIsLower($arrayString[$i]) Then $lower = 1 EndIf If StringIsDigit($arrayString[$i]) Then $digit = 1 EndIf Next If $upper + $lower + $digit <> 3 Then If $upper = 0 Then For $i = 1 To $arrayString[0] If StringIsLower($arrayString[$i]) Then $val = $i ExitLoop EndIf Next $upperPassword = StringUpper($arrayString[$val]) _ArrayDelete($arrayString,$val) $arrayPassword = _ArrayInsert($arrayString,$val,$upperPassword) $newPassword = _ArrayToString($arrayString,"") GUICtrlSetData($lblSuggestions,"Your password needs an upper case character. You could try this as your new password." & @CR & StringTrimLeft($newPassword,1)) GUICtrlSetData($txtPasswordConfirm,"") GUICtrlSetData($txtPassword,"") $pwChange = 1 EndIf If $pwChange = 0 Then If $lower = 0 Then For $i = 1 To $arrayString[0] If StringIsUpper($arrayString[$i]) Then $val = $i ExitLoop EndIf Next $lowerPassword = StringLower($arrayString[$val]) _ArrayDelete($arrayString,$val) $arrayPassword = _ArrayInsert($arrayString,$val,$lowerPassword) $newPassword = _ArrayToString($arrayString,"") GUICtrlSetData($lblSuggestions,"Your password needs a lower case character. You could try this as your new password." & @CR & StringTrimLeft($newPassword,1)) GUICtrlSetData($txtPasswordConfirm,"") GUICtrlSetData($txtPassword,"") $pwChange = 1 EndIf EndIf If $pwChange = 0 Then If $digit = 0 Then $digitPassword = Random(1,99,1) $newPassword = GUICtrlRead($txtPassword) & $digitPassword GUICtrlSetData($lblSuggestions,"Your password needs a number. You could try this as your new password." & @CR & $newPassword) GUICtrlSetData($txtPasswordConfirm,"") GUICtrlSetData($txtPassword,"") EndIf EndIf Else _AD_Open() $pw = 1 If $pw = 1 Then GUICtrlSetData($lblSuggestions,"Your new password has been set.") Sleep(3000) ;Exit ElseIf @error = 1 Then MsgBox(64, "Active Directory", "User '" & $rUser & "' does not exist") Else MsgBox(64, "Active Directory", "Return code '" & @error & "' from Active Directory") EndIf _AD_Close() GUICtrlSetData($txtPasswordConfirm,"") GUICtrlSetData($txtPassword,"") EndIf Else For $i = 1 To $arrayString[0] If StringIsUpper($arrayString[$i]) Then $upper = 1 EndIf If StringIsLower($arrayString[$i]) Then $lower = 1 EndIf If StringIsDigit($arrayString[$i]) Then $digit = 1 EndIf If StringIsUpper($arrayString[$i]) = 0 And StringIsLower($arrayString[$i]) = 0 And StringIsDigit($arrayString[$i]) = 0 Then $special = 1 EndIf Next If $upper + $lower + $digit + $special < 3 Then If $upper = 0 Then For $i = 1 To $arrayString[0] If StringIsLower($arrayString[$i]) Then $val = $i ExitLoop EndIf Next $upperPassword = StringUpper($arrayString[$val]) _ArrayDelete($arrayString,$val) $arrayPassword = _ArrayInsert($arrayString,$val,$upperPassword) $newPassword = _ArrayToString($arrayString,"") $upper = 1 GUICtrlSetData($lblSuggestions,"Your password needs an upper case character. You could use this as your password:" & @CR & StringTrimLeft($newPassword,1)) GUICtrlSetData($txtPasswordConfirm,"") GUICtrlSetData($txtPassword,"") EndIf If $upper + $lower + $digit + $special < 3 Then If $lower = 0 Then If $newPassword = "" Then $arrayStringNew = StringSplit(GUICtrlRead($txtPassword),"") Else $arrayStringNew = StringSplit(StringTrimLeft($newPassword,1),"") EndIf For $i = 1 To $arrayStringNew[0] If StringIsUpper($arrayStringNew[$i]) Then $val = $i ExitLoop EndIf Next $lowerPassword = StringLower($arrayStringNew[$val]) _ArrayDelete($arrayStringNew,$val) $arrayPassword = _ArrayInsert($arrayStringNew,$val,$lowerPassword) $newPassword = _ArrayToString($arrayStringNew,"") $lower = 1 GUICtrlSetData($lblSuggestions,"Your password needs a lower case character. You could use this as your password:" & @CR & StringTrimLeft($newPassword,1)) GUICtrlSetData($txtPasswordConfirm,"") GUICtrlSetData($txtPassword,"") EndIf EndIf If $upper + $lower + $digit + $special < 3 Then If $digit = 0 Then $digitPassword = Random(1,99,1) $newPassword = $newPassword & $digitPassword $digit = 1 GUICtrlSetData($lblSuggestions,"Your password needs a number. You could use this as your password:" & @CR & StringTrimLeft($newPassword,1)) GUICtrlSetData($txtPasswordConfirm,"") GUICtrlSetData($txtPassword,"") EndIf EndIf Else _AD_Open() $pw = 1 If $pw = 1 Then GUICtrlSetData($lblSuggestions,"Your new password has been set.") Sleep(3000) ;Exit ElseIf @error = 1 Then MsgBox(64, "Active Directory", "User '" & $rUser & "' does not exist") Else MsgBox(64, "Active Directory", "Return code '" & @error & "' from Active Directory") EndIf _AD_Close() GUICtrlSetData($txtPasswordConfirm,"") GUICtrlSetData($txtPassword,"") EndIf EndIf Else GUICtrlSetData($lblSuggestions,"The passwords you entered do not match. Please enter them again.") GUICtrlSetData($txtPasswordConfirm,"") GUICtrlSetData($txtPassword,"") EndIf EndSwitch WEnd Func _Windows() Sleep(50) EndFunc Link to comment Share on other sites More sharing options...
kylomas Posted August 14, 2013 Share Posted August 14, 2013 (edited) Try adding case insensitivity to the regexp like this (not tested) $arrayString = StringSplit(GUICtrlRead($txtPassword),"") ;_ArrayDisplay($arrayString) Global $string = "(?i)" For $i = 1 To $arrayString[0] $string = $string & $arrayString[$i] & "?" Next $arrayString1 = StringRegExp($rUser, "(?i)(" & $string & ")", 3) $arrayTotal = UBound($arrayString1) Global $passwordString = "" For $i = 0 To $arrayTotal - 1 If StringLen($arrayString1[$i]) = 3 Then $passwordString = $arrayString1[$i] ExitLoop EndIf Next kylomas edit: added insensitivity flag to wrong place Edited August 14, 2013 by kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
jazzyjeff Posted August 14, 2013 Author Share Posted August 14, 2013 For $i = 1 To $arrayString[0] If $i + 2 <= $arrayString[0] Then If StringInStr($rUser,$arrayString[$i] & $arrayString[$i+1] & $arrayString[$i+2]) And $passwordString = "" Then $passwordString = $arrayString[$i] & $arrayString[$i+1] & $arrayString[$i+2] ExitLoop EndIf EndIf Next I ended up adding this code and it seems to work. Thanks Kylomas for the code you posted. Link to comment Share on other sites More sharing options...
jazzyjeff Posted August 14, 2013 Author Share Posted August 14, 2013 Here is the full code. The new piece that I added starts on line 129. Thanks all. expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <Array.au3> #include <AD.au3> #include <Crypt.au3> #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <Misc.au3> $lower = 0 $upper = 0 $digit = 0 $special = 0 $pwChange = 0 Global $newPassword, $val $rUser = @UserName HotKeySet("{LWIN}","_Windows") HotKeySet("{RWIN}","_Windows") #Region ### START Koda GUI section ### Form= $formBKG = GUICreate("",@DesktopWidth, @DesktopHeight, 0, 0,$WS_POPUP) GUISetBkColor(0x000000) GUISetState(@SW_SHOW) $formMain = GUICreate("Password Utility", 664, 200, -1,-1) $lblPassword = GUICtrlCreateLabel("Your Password has expired. Please enter a new password for your account.", 8, 8, 288, 37) $txtPassword = GUICtrlCreateInput("", 8, 45, 281, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_PASSWORD)) $txtPasswordConfirm = GUICtrlCreateInput("", 8, 75, 281, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_PASSWORD)) $btnPassword = GUICtrlCreateButton("Set Password", 216, 115, 75, 25) $lblSuggestions = GUICtrlCreateLabel("", 8, 150, 300, 50) $lblFname = GUICtrlCreateLabel("First Name: ", 420, 8, 237, 17) $lblLName = GUICtrlCreateLabel("Last Name: ", 420, 37, 237, 17) $lblUName = GUICtrlCreateLabel("Username: ", 420, 66, 237, 17) $lblID = GUICtrlCreateLabel("Student ID: ", 420, 95, 237, 17) $lblPasswordExp = GUICtrlCreateLabel("Password Expiration:", 420, 128, 237, 17) GUISetState(@SW_SHOW) ;_ArrayDisplay($winPos) WinSetOnTop("Password Utility","",1) #EndRegion ### END Koda GUI section ### _AD_Open() $objProperties = _AD_GetObjectProperties($rUser) $objCN = _AD_GetObjectProperties($rUser,"cn") $objGivenName = _AD_GetObjectProperties($rUser,"givenName") $objEmployeeID = _AD_GetObjectProperties($rUser,"employeeID") $objSN = _AD_GetObjectProperties($rUser,"sn") $objPWExpiration = _AD_GetObjectProperties($rUser,"msDS-UserPasswordExpiryTimeComputed") $objFQDN = _AD_GetObjectProperties($rUser,"distinguishedName") If IsArray($objCN) Then If $objCN[0][0] <> 0 Then $userName = $objCN[1][1] Else $userNameName = "Unavailable" EndIf EndIf If IsArray($objSN) Then If $objSN[0][0] <> 0 Then $lastName = $objSN[1][1] Else $lastName = "Unavailable" EndIf EndIf If IsArray($objGivenName) Then If $objGivenName[0][0] <> 0 Then $firstName = $objGivenName[1][1] Else $firstName = "Unavailable" EndIf EndIf If IsArray($objEmployeeID) Then If $objEmployeeID[0][0] <> 0 Then $employeeID = $objEmployeeID[1][1] Else $employeeID = "Unavailable" EndIf EndIf If IsArray($objPWExpiration) Then If $objPWExpiration[0][0] <> 0 Then $pwExpiration = $objPWExpiration[1][1] Else $pwExpiration = "Unavailable" EndIf EndIf ;_ArrayDisplay($objProperties) _AD_Close() GUICtrlSetData($lblFname,"First Name: " & $firstName) GUICtrlSetData($lblLName,"Last Name: " & $lastName) GUICtrlSetData($lblUName,"Username: " & $userName) GUICtrlSetData($lblID,"Student ID: " & $employeeID) GUICtrlSetData($lblPasswordExp,"Password Expiration: " & $pwExpiration) $Pic1 = GUICtrlCreatePic("C:\" & $employeeID & ".jpg", 312, 8, 100, 108) While 1 $winPos = WinGetPos("Password Utility") _MouseTrap($winPos[0],$winPos[1],$winPos[2],$winPos[3]) $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $btnPassword GUICtrlSetData($lblSuggestions,"") $pwChange = 0 $lower = 0 $upper = 0 $digit = 0 $special = 0 If GUICtrlRead($txtPassword) = GUICtrlRead($txtPasswordConfirm) Then $stringLen = StringLen(GUICtrlRead($txtPassword)) $stringUp = StringIsUpper(GUICtrlRead($txtPassword)) $stringLow = StringIsLower(GUICtrlRead($txtPassword)) $stringDig = StringIsDigit(GUICtrlRead($txtPassword)) $arrayString = StringSplit(GUICtrlRead($txtPassword),"") ;_ArrayDisplay($arrayString) Global $string = "" For $i = 1 To $arrayString[0] $string = $string & $arrayString[$i] & "?" Next $arrayString1 = StringRegExp($rUser, "(" & $string & ")", 3) $arrayTotal = UBound($arrayString1) Global $passwordString = "" For $i = 0 To $arrayTotal - 1 If StringLen($arrayString1[$i]) = 3 Then $passwordString = $arrayString1[$i] ExitLoop EndIf Next For $i = 1 To $arrayString[0] If $i + 2 <= $arrayString[0] Then If StringInStr($rUser,$arrayString[$i] & $arrayString[$i+1] & $arrayString[$i+2]) And $passwordString = "" Then $passwordString = $arrayString[$i] & $arrayString[$i+1] & $arrayString[$i+2] ExitLoop EndIf EndIf Next _ArrayDisplay($arrayString1) MsgBox(0,"","Password String: " & $passwordString & @CR & "String: " & $string) If $stringLen < 8 Then GUICtrlSetData($lblSuggestions,"Password not long enough. You used " & $stringLen & " characters and you need to use at least 8.") GUICtrlSetData($txtPasswordConfirm,"") GUICtrlSetData($txtPassword,"") ElseIf $stringUp = 1 Then For $i = 1 To $arrayString[0] If StringIsUpper($arrayString[$i]) Then $val = $i ExitLoop EndIf Next $lowerPassword = StringLower($arrayString[$val]) _ArrayDelete($arrayString,$val) $arrayPassword = _ArrayInsert($arrayString,$val,$lowerPassword) $newPassword = _ArrayToString($arrayString,"") $digitPassword = Random(1,99,1) GUICtrlSetData($lblSuggestions,"Password only upper case. You could try this as your new password." & @CR & StringTrimLeft($newPassword,1) & $digitPassword) GUICtrlSetData($txtPasswordConfirm,"") GUICtrlSetData($txtPassword,"") ElseIf $stringLow = 1 Then For $i = 1 To $arrayString[0] If StringIsLower($arrayString[$i]) Then $val = $i ExitLoop EndIf Next $upperPassword = StringUpper($arrayString[$val]) _ArrayDelete($arrayString,$val) $arrayPassword = _ArrayInsert($arrayString,$val,$upperPassword) $newPassword = _ArrayToString($arrayString,"") $digitPassword = Random(1,99,1) GUICtrlSetData($lblSuggestions,"Password only lower case. You could try this as your new password." & @CR & StringTrimLeft($newPassword,1) & $digitPassword) GUICtrlSetData($txtPasswordConfirm,"") GUICtrlSetData($txtPassword,"") ElseIf $stringDig = 1 Then GUICtrlSetData($lblSuggestions,"Password only digits. Please add some characters to the password, with at least 1 upper case and 1 lower case letter.") GUICtrlSetData($txtPasswordConfirm,"") GUICtrlSetData($txtPassword,"") ElseIf StringInStr($rUser,$passwordString) And StringLen($passwordString) > 2 Then GUICtrlSetData($lblSuggestions,"Password contains part of the username. There are at least 3 consecutive characters in your name that you have used for your password. The 3 consecutive letters are, " & $passwordString & ".") GUICtrlSetData($txtPasswordConfirm,"") GUICtrlSetData($txtPassword,"") ElseIf StringIsAlNum(GUICtrlRead($txtPassword)) Then For $i = 1 To $arrayString[0] If StringIsUpper($arrayString[$i]) Then $upper = 1 EndIf If StringIsLower($arrayString[$i]) Then $lower = 1 EndIf If StringIsDigit($arrayString[$i]) Then $digit = 1 EndIf Next If $upper + $lower + $digit <> 3 Then If $upper = 0 Then For $i = 1 To $arrayString[0] If StringIsLower($arrayString[$i]) Then $val = $i ExitLoop EndIf Next $upperPassword = StringUpper($arrayString[$val]) _ArrayDelete($arrayString,$val) $arrayPassword = _ArrayInsert($arrayString,$val,$upperPassword) $newPassword = _ArrayToString($arrayString,"") GUICtrlSetData($lblSuggestions,"Your password needs an upper case character. You could try this as your new password." & @CR & StringTrimLeft($newPassword,1)) GUICtrlSetData($txtPasswordConfirm,"") GUICtrlSetData($txtPassword,"") $pwChange = 1 EndIf If $pwChange = 0 Then If $lower = 0 Then For $i = 1 To $arrayString[0] If StringIsUpper($arrayString[$i]) Then $val = $i ExitLoop EndIf Next $lowerPassword = StringLower($arrayString[$val]) _ArrayDelete($arrayString,$val) $arrayPassword = _ArrayInsert($arrayString,$val,$lowerPassword) $newPassword = _ArrayToString($arrayString,"") GUICtrlSetData($lblSuggestions,"Your password needs a lower case character. You could try this as your new password." & @CR & StringTrimLeft($newPassword,1)) GUICtrlSetData($txtPasswordConfirm,"") GUICtrlSetData($txtPassword,"") $pwChange = 1 EndIf EndIf If $pwChange = 0 Then If $digit = 0 Then $digitPassword = Random(1,99,1) $newPassword = GUICtrlRead($txtPassword) & $digitPassword GUICtrlSetData($lblSuggestions,"Your password needs a number. You could try this as your new password." & @CR & $newPassword) GUICtrlSetData($txtPasswordConfirm,"") GUICtrlSetData($txtPassword,"") EndIf EndIf Else _AD_Open() $pw = 1 If $pw = 1 Then GUICtrlSetData($lblSuggestions,"Your new password has been set.") Sleep(3000) ;Exit ElseIf @error = 1 Then MsgBox(64, "Active Directory", "User '" & $rUser & "' does not exist") Else MsgBox(64, "Active Directory", "Return code '" & @error & "' from Active Directory") EndIf _AD_Close() GUICtrlSetData($txtPasswordConfirm,"") GUICtrlSetData($txtPassword,"") EndIf Else For $i = 1 To $arrayString[0] If StringIsUpper($arrayString[$i]) Then $upper = 1 EndIf If StringIsLower($arrayString[$i]) Then $lower = 1 EndIf If StringIsDigit($arrayString[$i]) Then $digit = 1 EndIf If StringIsUpper($arrayString[$i]) = 0 And StringIsLower($arrayString[$i]) = 0 And StringIsDigit($arrayString[$i]) = 0 Then $special = 1 EndIf Next If $upper + $lower + $digit + $special < 3 Then If $upper = 0 Then For $i = 1 To $arrayString[0] If StringIsLower($arrayString[$i]) Then $val = $i ExitLoop EndIf Next $upperPassword = StringUpper($arrayString[$val]) _ArrayDelete($arrayString,$val) $arrayPassword = _ArrayInsert($arrayString,$val,$upperPassword) $newPassword = _ArrayToString($arrayString,"") $upper = 1 GUICtrlSetData($lblSuggestions,"Your password needs an upper case character. You could use this as your password:" & @CR & StringTrimLeft($newPassword,1)) GUICtrlSetData($txtPasswordConfirm,"") GUICtrlSetData($txtPassword,"") EndIf If $upper + $lower + $digit + $special < 3 Then If $lower = 0 Then If $newPassword = "" Then $arrayStringNew = StringSplit(GUICtrlRead($txtPassword),"") Else $arrayStringNew = StringSplit(StringTrimLeft($newPassword,1),"") EndIf For $i = 1 To $arrayStringNew[0] If StringIsUpper($arrayStringNew[$i]) Then $val = $i ExitLoop EndIf Next $lowerPassword = StringLower($arrayStringNew[$val]) _ArrayDelete($arrayStringNew,$val) $arrayPassword = _ArrayInsert($arrayStringNew,$val,$lowerPassword) $newPassword = _ArrayToString($arrayStringNew,"") $lower = 1 GUICtrlSetData($lblSuggestions,"Your password needs a lower case character. You could use this as your password:" & @CR & StringTrimLeft($newPassword,1)) GUICtrlSetData($txtPasswordConfirm,"") GUICtrlSetData($txtPassword,"") EndIf EndIf If $upper + $lower + $digit + $special < 3 Then If $digit = 0 Then $digitPassword = Random(1,99,1) $newPassword = $newPassword & $digitPassword $digit = 1 GUICtrlSetData($lblSuggestions,"Your password needs a number. You could use this as your password:" & @CR & StringTrimLeft($newPassword,1)) GUICtrlSetData($txtPasswordConfirm,"") GUICtrlSetData($txtPassword,"") EndIf EndIf Else _AD_Open() $pw = 1 If $pw = 1 Then GUICtrlSetData($lblSuggestions,"Your new password has been set.") Sleep(3000) ;Exit ElseIf @error = 1 Then MsgBox(64, "Active Directory", "User '" & $rUser & "' does not exist") Else MsgBox(64, "Active Directory", "Return code '" & @error & "' from Active Directory") EndIf _AD_Close() GUICtrlSetData($txtPasswordConfirm,"") GUICtrlSetData($txtPassword,"") EndIf EndIf Else GUICtrlSetData($lblSuggestions,"The passwords you entered do not match. Please enter them again.") GUICtrlSetData($txtPasswordConfirm,"") GUICtrlSetData($txtPassword,"") EndIf EndSwitch WEnd Func _Windows() Sleep(50) EndFunc Link to comment Share on other sites More sharing options...
kylomas Posted August 14, 2013 Share Posted August 14, 2013 Thanks Kylomas for the code you posted. Did it help at all? I was just guessing based on the fact that 'WSH' did not match but 'tec' did. Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
guinness Posted August 14, 2013 Share Posted August 14, 2013 It would be easier to debug if you moved to separating the password validation into manageable functions. Like I did. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
guinness Posted August 14, 2013 Share Posted August 14, 2013 I also noticed you do alot of this in the code above. It will cause an error eventually when the likes of _AD_GetObjectProperties() don't return an array. #include <Constants.au3> Local $aArray = 0 ; This can be assigned using a function. Thankfully so far it has returned an array If IsArray($aArray) Then If $aArray[0] > 0 Then $sSomeVar = 'OK' ; This variable will never be created. Else $sSomeVar = 'Error' ; And neither will this if $aArray isn't an array. EndIf EndIf MsgBox($MB_SYSTEMMODAL, '', $sSomeVar) ; So this causes an error. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
guinness Posted August 14, 2013 Share Posted August 14, 2013 Maybe I misunderstood, but is this what you wanted to do? #include <Constants.au3> MsgBox($MB_SYSTEMMODAL, '', IsUsernameInPassword('myUsername', 'myUserPass')) MsgBox($MB_SYSTEMMODAL, '', IsUsernameInPassword('myUsername', 'myPass')) ; Returns True/False if part of the username is found in the password. $iMinChrs is the minimum number of similar characters. Func IsUsernameInPassword($sUsername, $sPassword, $iMinChrs = 3) Local $aPasswordChrs = StringSplit($sPassword, ''), _ $sPasswordPattern = '' For $i = 1 To $aPasswordChrs[0] $sPasswordPattern &= $aPasswordChrs[$i] & '?' Next Local $fReturn = False, _ $aUsername = StringRegExp($sUsername, '(?i)(' & $sPasswordPattern & ')', 3) If @error = 0 Then $fReturn = StringLen($aUsername[0]) >= $iMinChrs Return $fReturn EndFunc ;==>IsUsernameInPassword I ask because I am looking at incorporating in my UDF. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
Edano Posted August 15, 2013 Share Posted August 15, 2013 (edited) why don't you like my suggestion from >post 17: . $user="wshtechs" $pass="Il0veWSH" $len=3 ; length of consecutive letter search string For $i=1 To StringLen($user)-$len $checkstring=StringMid($user,$i,$len) If StringInStr($pass,$checkstring) Then MsgBox(0,"","Password contains following String from username: "&$checkstring) Next . just because it's not strregex and no array ? it's simple .... but it works perfectly Edited August 15, 2013 by Edano [color=rgb(255,0,0);][font="'comic sans ms', cursive;"]FukuLeaks[/color][/font] Link to comment Share on other sites More sharing options...
guinness Posted August 15, 2013 Share Posted August 15, 2013 (edited) I dunno, but it seems alright. #include <Constants.au3> MsgBox($MB_SYSTEMMODAL, '', IsUsernameInPassword('myUsername', 'myUserPass')) MsgBox($MB_SYSTEMMODAL, '', IsUsernameInPassword('myUsername', 'myPass')) ; Returns True/False if part of the username is found in the password. $iMinChrs is the minimum number of similar characters. Func IsUsernameInPassword($sUsername, $sPassword, $iMinChrs = 3) Local $fReturn = False, _ $sChrs = '' For $i = 1 To StringLen($sUsername) - $iMinChrs ; Concept by Edano. $sChrs = StringMid($sUsername, $i, $iMinChrs) If StringInStr($sPassword, $sChrs) Then $fReturn = True ExitLoop EndIf Next Return $fReturn EndFunc ;==>IsUsernameInPassword I couldn't understand why you had StringLen(...) - 2. What's the minus 2 for? Edited August 15, 2013 by guinness UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
czardas Posted August 15, 2013 Share Posted August 15, 2013 (edited) I've been thinking about this myself. I like the idea of measuring strength in terms of the time it takes to brute force the password at a predefined number of tries per second. I'm not quite sure how to go about it - it requires further thought. The strength of a password should alter as more sets are included - numeric, alphanumeric, lower/upper case, symbols, ascii, ansi, unicode (bytes). I think the maths is somewhat confusing. Edited August 15, 2013 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
Edano Posted August 15, 2013 Share Posted August 15, 2013 (edited) must be -3 right. sorry. will correct it. the -2/-3 is important, if you don't want stringmid to produce 2 or 1 letter search strings at the end. stringlen-3 is the last substring with 3 letters Edited August 15, 2013 by Edano [color=rgb(255,0,0);][font="'comic sans ms', cursive;"]FukuLeaks[/color][/font] Link to comment Share on other sites More sharing options...
guinness Posted August 15, 2013 Share Posted August 15, 2013 must be -3 right. sorry. will correct it. OK, so it's the minimum value of similar characters in succession of one another. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
Edano Posted August 15, 2013 Share Posted August 15, 2013 OK, so it's the minimum value of similar characters in succession of one another. . yep. i edited my last 2 posts while you were responding. didn't notice it. [color=rgb(255,0,0);][font="'comic sans ms', cursive;"]FukuLeaks[/color][/font] Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now