Sign in to follow this  
Followers 0
Mechaflash

_AutoMD5 - Create and test MD5 hash from string

1 post in this topic

#1 ·  Posted (edited)

_AutoMD5 allows you to input a string password and it outputs an md5 hash for you. It also allows you to test it via a pseudo GUI login.

At the end of the script, it outputs the MD5 encrypted string as well as the source code for a simple autoit login prompt in a txt file.

Notice in the source output, _Get_Stored_Encrytped_Password() is whatever method you use to store the original encrypted password. I.E. you create the encrypted password and store it in an INI file. Replace _Get_Stored_Encrypted_Password() with a function that's made to retireve it from the INI file.

#include <Crypt.au3>

$vData = InputBox(@ScriptName, "Enter a password to encrypt.")
$sOutFile = FileSelectFolder("Select folder to output your encrypted key to.", "", 6)
If @error Then Exit
$sOutFile&="EncryptedPass.txt"
_AutoMD5_Data_Create($vData, $sOutFile)
If msgbox(4 + 32 + 262144, @ScriptName, "Do you wish to view your encrypted key?") = 6 Then ShellExecute($sOutFile)
Exit

Func _AutoMD5_Data_Create($vData, $sOutFile)
    _Crypt_StartUp()
    $sEncryptedString = _Crypt_HashData($vData, $CALG_MD5)
    If $sEncryptedString = -1 Then
        msgbox(16 + 262144, @ScriptName, "Failed to create MD5 hash. Error in command. " & @error)
        Exit
    Else
        $hFile = FileOpen($sOutFile, 2)
        FileWrite($hFile, String($sEncryptedString) & @CRLF)
        FileClose($hFile)
    EndIf
    _Crypt_Shutdown()
    If msgbox(4 + 32 + 262144, @ScriptName, "Do you wish to test the output?") = 6 Then
        $sInput = InputBox(@ScriptName, "Enter your password...")
        _AutoMD5_Test_Decryption($sInput, $sEncryptedString, $sOutFile)
    EndIf
    _AutoMD5_Create_Commands($sOutFile)
    Return $sEncryptedString
EndFunc

Func _AutoMD5_Test_Decryption($sInput, $sEncryptedString, $sOutFile)
    _Crypt_Startup()
    $sInputEncryptedString = _Crypt_HashData($sInput, $CALG_MD5)
    _Crypt_Shutdown()
    If String($sInputEncryptedString) = String($sEncryptedString) Then
        msgbox(64 + 262144, @ScriptName, "WORKS!" &@LF&@LF& _
            "Encrypted Password Shows As: " & @TAB & $sEncryptedString &@LF&@LF& _
            "The Input Password Shows As: " & @TAB & $sInputEncryptedString)
    Else
        msgbox(64 + 262144, @ScriptName, "FAILED!" &@LF&@LF& _
        "Encrypted Password Shows As: " & @TAB & $sEncryptedString &@LF&@LF& _
            "The Input Password Shows As: " & @TAB & $sInputEncryptedString)
    EndIf
EndFunc

Func _AutoMD5_Create_Commands($sOutFile)
    $hFile = FileOpen($sOutFile, 1)
    FileWrite($hFile,  @CRLF & '#include <Crypt.au3>' & @CRLF & @CRLF & _
        '$sInput = InputBox(@ScriptName, "Enter your password...")' & @CRLF & @CRLF & _
        'Func _AutoMD5_Data_Decrypt($sInput) ; Returns true if passwords match, or false if they don''t.' & @CRLF & @TAB & _
        '$sPass = _Get_Stored_Encrypted_Password() ; Retrieve the password via whatever method you choose to store it.' & @CRLF & @TAB & _
        '_Crypt_Startup()' & @CRLF & @TAB & _
        '$sEncryptedInput = _Crypt_HashData($sInput, $CALG_MD5)' & @CRLF & @TAB & _
        '_Crypt_Shutdown()' & @CRLF & @TAB & _
        'If String($sInputEncryptedString) = String($sEncryptedString) Then' & @CRLF & @TAB & @TAB & _
        'Return True' & @CRLF & @TAB & _
        'Else' & @CRLF & @TAB & @TAB & _
        'Return False' & @CRLF & @TAB & _
        'EndIf' & @CRLF & _
        'EndFunc')
    FileClose($hFile)
EndFunc

Edited by mechaflash213

Spoiler

“Hello, ladies, look at your man, now back to me, now back at your man, now back to me. Sadly, he isn’t me, but if he stopped using ladies scented body wash and switched to Old Spice, he could smell like he’s me. Look down, back up, where are you? You’re on a boat with the man your man could smell like. What’s in your hand, back at me. I have it, it’s an oyster with two tickets to that thing you love. Look again, the tickets are now diamonds. Anything is possible when your man smells like Old Spice and not a lady. I’m on a horse.”

 

Share this post


Link to post
Share on other sites



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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Similar Content

    • RTFC
      By RTFC
      CodeCrypter enables you to encrypt scripts without placing the key inside the script.
      This is because this key is extracted from the user environment at runtime by, for example:
      password user query any macro (e.g., @username) any AutoIt function call any UDF call some permanent environment variable on a specific machine (and not created by your script) a server response a device response anything else you can think of, as long as it's not stored in the script any combination of the above You need several scripts to get this to work, and they are scattered over several threads, so here's a single bundle that contains them all (including a patched version of Ward's AES.au3; with many thanks to Ward for allowing me to include this script here):
      CodeScannerCrypter.bundle.v2.2.7z
      Note: if you experience issues under Win8/8.1 (as some users have reported), please upgrade to Win10 (or use Win7) if you can; as far as I can tell, the scripts in the bundle all work under Win7 & Win10 (and XP). Moreover, I have no access to a Win8 box, so these issues will not be fixed, at least not by yours truly.
       
      How the bits and pieces fit together:
      CodeCrypter is a front-end for the MCF UDF library (you need version 1.3 or later). Its thread is here:
      '?do=embed' frameborder='0' data-embedContent>>
      The MCF package (also contained in the CodeScannerCrypter bundle) contains MCF.au3 (the library itself) plus a little include file called MCFinclude.au3. The latter you have to include in any script you wish to encrypt. Any code preceding it will not be encrypted, any code following it will be encrypted. You define the dynamic key inside MCFinclude.au3, in the UDF: _MCFCC_Init().
      From the same post you can download an MCF Tutorial which I heartily recommend, because encrypting a script requires a number of steps in the right order, namely:
      In MCFinclude.au3, define and/or choose your dynamic key(s) (skip this step = use default setting) include MCFinclude.au3 in your target script Run CodeScanner (version 2.3+) on your target script, with setting WriteMetaCode=True (see '?do=embed' frameborder='0' data-embedContent>>), then close CodeScanner. Start CodeCrypter press the Source button to load your target file enable Write MCF0 (tick the first option in Main Settings) Enable "Encrypt" (last option in the Main Settings) Go to the Tab Encrypt and set up the encryption the way you want (skip this = use default settings) Return to Main Tab and press "Run" if all goes well, a new script called MCF0test.au3 is created in the same directory as your target. It has no includes and no redundant parts. Please check that it works as normal. (see Remarks if not) It all sounds far more complicated than it is, really.
      Not convinced? Check out this updated and extended Q & A pdf (FAQ, also included in the bundle) to help you get started:
      CodeCrypterFAQ.pdf
       
      BackTranslation is a test to check that the MetaCode translation worked. Skip it at your peril. It also turns your multi-include composite script into a single portable file without redundant parts (you can opt to leave the redundant parts in, if you want).
      CodeCrypter can also obfuscate (vars and UDF names) and replace strings, variable names and UDF names with anything else you provide, for  example, for language translation). After CodeScanner separates your target's structure from its contents, CodeCrypter (actually MCF, under the hood) can change any part, and then generate a new script from whichever pieces you define. See the MCF Tutorial for more explanation and examples.
       
      Important!
      You need the following additional scripts to get anything to work (now all included in the bundle):
      CodeScanner.au3 version 2.9+ (in the CodeScanner zip in the CodeScanner thread, link above) readCSdatadump.au3 (version 1.1+, in the CodeScanner zip) MCF.au3 (version 1.3+, in the MCF zip in the MCF thread, link above) MCFinclude.au3 (version 1.1+, in the MCF zip) AES.au3, by Ward (now also included in bundle, thanks to Ward), see '?do=embed' frameborder='0' data-embedContent>> As you can see, encryption currently relies on Ward excellent AES UDF, but you can replace this with any other algorithm you like; just edit MCFinclude.au3 UDF _MCFCC(), and MCF.au3 UDF _EncryptEntry().
      Going to lie down now...
      RT
      CodeCrypterFAQ.pdf
    • Graeme
      By Graeme
      I was looking for a way to calculate the sha512 value of files downloaded and eventually came across crypt.au3 in my include folder. It looks good but when I looked at the global constants the three values for Sha 2 are commented out. Is there a reason for that or should these be made available?
    • usmiv4o
      By usmiv4o
      #cs ---------------------------------------------------------------------------- AutoIt Version: 3.2.4.3 Author: usmiv4o Script Function: AutoIt script to check if files in directory are changed. It is usefull for security contra-inteligense measures. Function Name: LoadTripwireDB() Description: Loads database (text file tripwire.txt) and compare files in /test folder for changes. compares Hash (MD5) checksums. If they are not the same starts Initial() Function Name: Initial() Description: Checks directory and makes index of files and their MD5 checksums in text file (tripwire.txt) Function Name: Hush() Description: Checks file and returns its MD5 checksum. Requirement(s): Windows XP Return Value(s): On Success - Returns true. Files are the same as before. On Failure - return false. Example: LoadTripwireDB() #ce ---------------------------------------------------------------------------- #include <Crypt.au3> #include <File.au3> #include <Array.au3> $sDir = @ScriptDir & "\Test" $sFilePath = @ScriptDir & "\tripwire.txt" Func Hush(ByRef $sFile) $sRead = FileOpen( $sFile) $dHash = _Crypt_HashData($sRead, $CALG_MD5) ; Create a hash of the text entered. ConsoleWrite("Hash of file " & $sFile & " is " & $dHash & @CRLF) EndFunc ;ConsoleWrite("Files in Dir are " & $aScriptDir[0] & @CRLF) ;$sFilePath = @ScriptDir & "\Examples.txt" ;_FileWriteFromArray($sFilePath, $aScriptDir, 1) ;_ArrayDisplay($aScriptDir, "1D display") Func Initial() $aScriptDir = _FileListToArray($sDir) for $i = 1 To UBound($aScriptDir) - 1 $dHash = _Crypt_HashData($i, $CALG_MD5) ;ConsoleWrite("File " & $aScriptDir[$i] & " is " & $dHash & @CRLF) ConsoleWrite($aScriptDir[$i] & ":" & $dHash & @CRLF) ;Hush($aScriptDir[$i]) ;FileWrite $hFileOpen = FileOpen($sFilePath, $FO_APPEND) If $hFileOpen = -1 Then MsgBox($MB_SYSTEMMODAL, "", "An error occurred when reading the file.") EndIf FileWrite($hFileOpen, $aScriptDir[$i] & ":" & $dHash & @CRLF) Next EndFunc Func Monitor() $aScriptDir = _FileListToArray($sDir) for $i = 1 To UBound($aScriptDir) - 1 Next EndFunc Func LoadTripwireDB() $comparison_ok = false $dArray = _FileListToArray($sDir) ;directory $dArray0 = UBound($dArray) - 1 $fArray = FileReadToArray($sFilePath) ;file $fArray0 = UBound($fArray) ;_ArrayDisplay($dArray, "files array") if $dArray0 = $fArray0 Then ; are file same as recorded in txt file? ;ConsoleWrite("files in monitoring dir: " & $dArray[0] & " = file recorded: " & $fArray0 & @CRLF & $fArray[0]& @CRLF) for $i = 1 To UBound($dArray) - 1 ;ConsoleWrite("i = " & $i & @CRLF) $dHash = _Crypt_HashData($i, $CALG_MD5) ;binary ;$dHash = BinaryToString($dHash) $ffhash = StringSplit( $fArray[$i-1],":") $fhash = $ffhash[2] ;ConsoleWrite("IsBinary $dHash " & IsBinary($dHash) & @CRLF) if $dHash = $fhash Then ;if compared hashes are equal ;ConsoleWrite($fhash & ":" & $dHash & " equal" & @CRLF) ;ConsoleWrite("File: " & $fhash & @CRLF & "Directory: " & $dHash & @CRLF & "equal: yes " & @CRLF) Else ;if compared hashes are not equal ;ConsoleWrite("File: " & $fhash & @CRLF & "Directory: " & $dHash & @CRLF & "equal: not " & @CRLF) ;MsgBox(0,"hash md5",$fhash & ":" & $dHash & " not equal") EndIf Next ;ConsoleWrite("hashes are equal" & @CRLF) $comparison_ok = true Else ConsoleWrite("number of files in monitoring dir are not same as recorded" & @CRLF) ConsoleWrite("directory: " & $dArray[0] &":"& "files: " & UBound($fArray) - 1 & @CRLF) EndIf Return $comparison_ok EndFunc #main if LoadTripwireDB() = true Then ConsoleWrite(" hashes are equal " & @CRLF) ElseIf LoadTripwireDB() <> true Then ConsoleWrite(" hashes are not equal " & @CRLF) ConsoleWrite(" hashes are not equal " & @CRLF) Initial() EndIf  
      tripwire.au3
      tripwire.txt
    • AlecSadler
      By AlecSadler
      Hello all, I would like to present my proof of concept work to the autoit forum and community. (I saw this as a concept in a few sci-fi shows and thought I would bring it into real life)
      What is it?: DARTIS (Dimensions And Relative Time Information System)© is a 4 dimensional holographic encryption algorithm which uses the current timestamp(measured down to femto seconds) to encrypt data under several layers of calculations. One large keyfile is used and multiple keys are extracted from it, and overlaid on each other to create 1,000,000,000,000,000  unique keys per second. Special thanks to the creator of the matrix maths udf (if this is you please let me know and I will put your name here.) Also special thanks to trancexx for her LZNT compression code.
      Please see the following link for the full set of functions and an example debugging application, which shows usage of all the functions.
      https://pdglobal.net/?pid=SIM#SIM (DARTIS is packed with SIM)
       
      DARTIS is an encryption scheme that extracts a timestamp from the current system time, then splits it up into an array of strings each 4 digits long.

      Then those strings are plugged into the 16mb keyfile blueprint, where each 4 digit value represents a 2D array.

      Then each 2D array is layered on top of the one that came before it, compressing the data underneath several layers of encryption.

      It's 4D because the key is derived from the system time(so the same key will never be used twice)

      And it's holographic because the data is buried underneath several layers of data.

      The full 16mb keyfile blueprint is required to re-extract the data that has been injected into the holographic keyfile blueprint. (as the values all have to be the same AND be in the same order)

      The only downside to this encryption scheme is that the only safe way to distribute keys is by snail mail or in person. (because if you transmit it via the internet, you're limiting the security of your keyfile blueprint to whatever lesser encryption algorithm you;re using to transmit the keyfile blueprint)

      Hope I explained it in a way that's easy to understand! If you have any further questions about it feel free to ask! (and/or look around the DARTIS.au3 file to see how this is done, and run DEBUG.au3 to see under the hood)
       
    • ADMPV
      By ADMPV
      https://sourceforge.net/projects/rhash/
      librhash.dll - supports CRC32, MD4, MD5, SHA1, SHA256, SHA512, SHA3, Tiger, TTH, Torrent BTIH, AICH, ED2K, GOST R 34.11-94, RIPEMD-160, HAS-160, EDON-R 256/512, WHIRLPOOL and SNEFRU hash sums.
      faster than _Crypt_HashFile about 2 times
      librhash.au3, librhash.dll in archive
      Changelog:
              2017-07-11 Added: rhash_timer_start, rhash_timer_stop
                         Changed: DLL - rhash_run_benchmark_mod - passing file as HANDLE
              2017-07-07 Changed: rhash_ex()
                         Added: DLL - rhash_run_benchmark_mod
              2017-07-04 Changed rhash_ex()
       
      librhash_134.zip