elproducto Posted November 29, 2015 Share Posted November 29, 2015 (edited) Hello All,I have been meaning to try AutoIT for sometime. I finally got a chance to try AutoIT, and I am impressed so far. I have a use case where I need to automate creation of password hashes with a program that has no command line accessibility or built in API. The end goal is to read a text file with passwords on individual lines, process each password through hash generator, and finally dump those hashes into a separate text file. So far I have come up with the following script, first time so excuse my syntax. Issue I am experiencing is with the loop I put into the script, for some reason it is combing all passwords in my Password.txt into one single password hash. Password.txt has the password on individual lines. The file HashedPW.txt is the file the hashed passwords get saved in. Can anyone give me any pointers on how to fix this issue?Local $hPWFilepath=("d:\Password.txt") Local $hPWHashfilepath=("d:\HashedPW.txt") Local $sEncHash=ControlGetText("Password Generator", "",1003) Run("d:\users\elproducto\desktop\Password_Gen.exe") WinWait("Password_Gen") $i = 1 Do ControlSend("Password Generator", "", "Edit1", FileReadLine($hPWFilepath,$i)) ControlSend("Password Generator", "", "Edit2", FileReadLine($hPWFilepath,$i)) ControlClick("Password Generator", "", "Button5") FileWriteLine($hPWHashfilepath,$sEncHash) $i=$i+1 Until $i=3 Edited November 29, 2015 by elproducto Link to comment Share on other sites More sharing options...
JohnOne Posted November 29, 2015 Share Posted November 29, 2015 Are you writing the exact same text (sEncHash) that you get in the first place, to your output file? AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
elproducto Posted November 29, 2015 Author Share Posted November 29, 2015 I am not sure what you mean, the value for variable sEncHash is what is outputted to the file. This variable is extracted from the password generator. Link to comment Share on other sites More sharing options...
JohnOne Posted November 29, 2015 Share Posted November 29, 2015 Maybe you are getting it from the password generator, but that's before you do anything with it.You write $sEncHash to a file in your do loop, but $sEncHash remains the same on each iteration. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
elproducto Posted November 29, 2015 Author Share Posted November 29, 2015 @JohnOne Thanks, your clues and reading the "Learning To Script..." guide on this site gave me an idea on how to restructure this script. Everything is working now, and I am generating individual hashes per password. New code below, I hope this is structured correctly. I am now going to work on a GUI. Is there anyway to include the password generator in a bundle with the GUI?expandcollapse popup#include <Array.au3> #include <File.au3> #include <MsgBoxConstants.au3> Local $aPWArray = 0 Local $hPWFilepath=("d:\Password.txt") Local $hPWHashfilepath=("d:\HashedPW.txt") Local $hPWGenpath=("d:\users\elproducto\desktop\Password_Gen.exe") ;Password Generation Process PasswordArray() PassWordGen() Func PasswordArray() ; Read the current script file into an array using the variable defined previously. ; $iFlag is specified as 0 in which the array count will not be defined. Use UBound() to find the size of the array. If Not _FileReadToArray($hPWFilepath, $aPWArray, 0) Then MsgBox($MB_SYSTEMMODAL, "", "There was an error reading the password file. @error: " & @error) ; An error occurred reading the current file. EndIf EndFunc Func PassWordGen() ;Run the password generation and being the encrption process Run($hPWGenpath) WinWait("WYSE") ;Read Array For $elements in $aPWArray ;Populate fields in Password Generator & Click Encypt Password button ControlSend("Password Generator", "", "Edit1", $elements) ControlSend("Password Generator", "", "Edit2", $elements) ControlClick("Password Generator", "", "Button5") ;Clear fields for next encryption round FileWriteLine($hPWHashfilepath, ControlGetText("WYSE","",1003)) ControlSetText("Password Generator", "", "Edit1", "") ControlSetText("Password Generator", "", "Edit2", "") Next WinClose("WYSE") EndFunc 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