I have a piece of software written by a colleague who no longer works at the company. The settings for this software are protected with a password (I'm not sure why). I found the following script on a website (viewtopic.php?f=76&t=63551&start=20). I have modified the script to go up to 6 characters instead of the original 4.
I need to add the following to the script:
WinActivate, Login ahk_class WindowsForms10.Window.8.app.0.34f5582_r7_ad1 ; Activates the password window
**** uses the script to enter the password ****
Send, {Tab}{Tab}{NumpadEnter} ; clicks the OK button
**** now one of two things can happen, either a window pop-up with the message "password invalid" or the password is accepted. ****
**** if the "Password Invalid" window pops up ****
Send, {NumpadEnter}
**** retry with new password ****
Code: Select all
;-------------------------------------------------------------------------------
; LuckyDay.ahk - Brute Force 4-digit Password using AHK
; https://www.autohotkey.com/boards/viewtopic.php?p=272076#p272076
;-------------------------------------------------------------------------------
#NoEnv
#SingleInstance Force
OnExit("Logging")
Numbers = 0123456789
UPPER_CASE = ABCDEFGHIJKLMNOPQRSTUVWXYZ
lower_case = abcdefghijklmnopqrstuvwxyz
special_characters = !\/
global Characters := Numbers UPPER_CASE lower_case special_characters
global SaveFile := A_ScriptDir "\Password.txt"
global LastCombination := ""
Combination := "000000" ; a 6-letter string
if FileExist(SaveFile) {
FileRead, Content, %SaveFile%
if RegExMatch(Content, ".*Last: (.*)\r\n$", Match)
Combination := Match1
}
global Combo := [] ; a simple array (built from 4-letter string)
for each, Char in StrSplit(Combination)
Combo.Push( InStr(Characters, Char) )
loop
Test(getNext())
return ; end of auto-execute section
F5:: Reload
Esc:: ExitApp
;-------------------------------------------------------------------------------
Logging() { ; logging the last combo (super-global variable)
;-------------------------------------------------------------------------------
FileAppend, % "Last: " LastCombination "`n", %SaveFile%
}
;-------------------------------------------------------------------------------
Test(Combination) { ; test code
;-------------------------------------------------------------------------------
; test code for Combination
MsgBox,,, %Combination%, .5
sleep, 100
; after test code: store this Combination in super-global variable
LastCombination := Combination
}
;-------------------------------------------------------------------------------
getNext() { ; return the next string to test
;-------------------------------------------------------------------------------
if StrLen(Characters) > Combo[6]
Combo[6]++
else if StrLen(Characters) > Combo[5]
Combo[5]++, Combo[6] := 1
else if StrLen(Characters) > Combo[4]
Combo[4]++, Combo[5] := 1
else if StrLen(Characters) > Combo[3]
Combo[3]++, Combo[4] := 1
else if StrLen(Characters) > Combo[2]
Combo[2]++, Combo[3] := Combo[4] := 1
else if StrLen(Characters) > Combo[1]
Combo[1]++, Combo[2] := Combo[3] := Combo[4] := Combo[5] := Combo[6] := 1
else
MsgBox, Done!
return SubStr(Characters, Combo[1], 1)
. SubStr(Characters, Combo[2], 1)
. SubStr(Characters, Combo[3], 1)
. SubStr(Characters, Combo[4], 1)
. SubStr(Characters, Combo[5], 1)
. SubStr(Characters, Combo[6], 1)
}