Atrax27 Posted June 30, 2020 Share Posted June 30, 2020 I fully understand the risks involved with using the following code, I simply want it to be able to store several of my own personal login passwords without being stored as plain text in the body of the script. For example, I have a very simple login script which just preforms a Send("password") Send ({ENTER}) But I'd like to obfuscate the plain text password into something that is not so readily insecure. Hence, the below: #include <Crypt.au3> ; Code provided by Robjong - Autoit _Crypt_Startup() Global $sPasswordCT = '0x3F10544A42DE8D16C2C590C20640A00D' Global $sJoinDomainPassword = '' $sJoinDomainPassword = _Decrypt("password", $sPasswordCT) MsgBox(0,"Password","Admin password: " & $sJoinDomainPassword) _Crypt_Shutdown() Func _Decrypt($sKey, $sData) Local $hKey = _Crypt_DeriveKey($sKey, $CALG_AES_256) Local $sDecrypted = BinaryToString(_Crypt_DecryptData(Binary($sData), $hKey, $CALG_USERKEY)) _Crypt_DestroyKey($hKey) Return $sDecrypted EndFunc Found this on the forums, but simply cannot find a way to change "secret" to any other text. The "0x3F10544A42DE8D16C2C590C20640A00D" is locked and I have no idea how to generate my own set of AES 256 hashes to correspond with the passwords I want to use. Ideally I'd have a dozen variables, each equaling one of my dozen passwords, but again I can't figure out a way to change "$sJoinDomainPassword" PS I love the forums, very helpful and thanks in advance :) Link to comment Share on other sites More sharing options...
Nine Posted June 30, 2020 Share Posted June 30, 2020 You need 2 scripts. The first will generate the binary passwords. The second (the one you have written) will use the encrypted password. I have put the 2 scripts into a single one for simplicity. #include <Crypt.au3> _Crypt_Startup() ;script 1 (script to generate encrypt password) Local $password = InputBox("Encryption", "Enter password") If @error Then Exit Local $result = _Encrypt("password", $password) MsgBox($MB_SYSTEMMODAL, "", $result) ; ClipBoard now contains the binary password : paste it into your script or save it into a file or registry ;script 2 (script to use encrypted password) Local $sPasswordCT = ClipGet() ; replace ClipGet with the binary string or read it from a file or registry Local $sJoinDomainPassword = _Decrypt("password", $sPasswordCT) MsgBox(0, "Password", "Admin password: " & $sJoinDomainPassword) _Crypt_Shutdown() Func _Decrypt($sKey, $sData) Local $hKey = _Crypt_DeriveKey($sKey, $CALG_AES_256) Local $sDecrypted = BinaryToString(_Crypt_DecryptData(Binary($sData), $hKey, $CALG_USERKEY)) _Crypt_DestroyKey($hKey) Return $sDecrypted EndFunc ;==>_Decrypt Func _Encrypt($sKey, $sData) Local $hKey = _Crypt_DeriveKey($sKey, $CALG_AES_256) Local $sEncrypted = _Crypt_EncryptData($sData, $hKey, $CALG_USERKEY) _Crypt_DestroyKey($hKey) ClipPut($sEncrypted) Return $sEncrypted EndFunc ;==>_Encrypt Atrax27 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Atrax27 Posted July 1, 2020 Author Share Posted July 1, 2020 Worked perfect thank you. I'd like to learn how to read the resulting hashes from a key file like you're saying but that's not necessary for what I'm doing. Thank you again 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