Jump to content

MD5 Hash Cracker


Skrip
 Share

Recommended Posts

Cracked MD5 hashes..but requires a wordlist.

;Special thanks to Siao for the MD5 function, and lod3n for the transparent PNG background.
FileInstall("C:\Program Files\AutoIt3\Images\Gui.png", @ScriptDir & "\Gui.png")
FileInstall("C:\Program Files\AutoIt3\grey.gif", @ScriptDir & "\grey.gif")
$text = ""
$1 = 1
$abort = 0
$line = 0
#NoTrayIcon
#include <GDIPlus.au3>
#include <WindowsConstants.au3>
#include <GuiConstantsEx.au3>
#include <File.au3>
Opt("MustDeclareVars", 0)

Global Const $AC_SRC_ALPHA = 1
Global $old_string = "", $runthis = ""
Global $launchDir = @DesktopDir

_GDIPlus_Startup()
$pngSrc = @ScriptDir & "\Gui.png"
$hImage = _GDIPlus_ImageLoadFromFile($pngSrc)

$width = _GDIPlus_ImageGetWidth($hImage)
$height = _GDIPlus_ImageGetHeight($hImage)

$GUI = GUICreate("Cracker", $width, $height, -1, -1, $WS_POPUP, $WS_EX_LAYERED)
SetBitmap($GUI, $hImage, 0)

GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST")
GUISetState()
WinSetOnTop($GUI, "", 1)

For $i = 0 To 255 Step 10
    SetBitmap($GUI, $hImage, $i)
Next


$controlGui = GUICreate("MD5 Encrypt", $width, $height, 0, 0, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $GUI)


GUICtrlCreatePic(@ScriptDir & "\grey.gif", 0, 0, $width, $height)
GUICtrlSetState(-1, $GUI_DISABLE)

$Button1 = GUICtrlCreateButton("Exit", 512, 40, 65, 25, 0)
$Edit1 = GUICtrlCreateEdit("", 88, 40, 417, 100)
$Label1 = GUICtrlCreateLabel("MD5 Hash:", 88, 149, 58, 17)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor(-1, 0xFFFFFF)
$Input1 = GUICtrlCreateInput("", 144, 146, 249, 21)
$Label2 = GUICtrlCreateLabel("Word List:", 88, 172, 52, 17)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor(-1, 0xFFFFFF)
$Input2 = GUICtrlCreateInput("", 144, 170, 249, 21)
$Progress1 = GUICtrlCreateProgress(80, 226, 490, 17)
$Button2 = GUICtrlCreateButton("Crack", 400, 145, 100)
GUISetState()

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $Button1
            ExitLoop
        Case $msg = $Button2
            $abort = 0
            $wordlist = GUICtrlRead($Input2)
            $chash = GUICtrlRead($Input1)
            If Not FileExists($wordlist) Then
                dis("Wordlist does not exist...Aborting...")
                $abort = 1
            EndIf
            If GUICtrlRead($Input1) = "" Then
                dis("Invalid MD5 hash...")
                $abort = 1
            EndIf
            If $abort = 0 Then
                dis2("Beginning...")
                ControlDisable($controlGui, "", $Input1)
                ControlDisable($controlGui, "", $Input2)
                dis("Scanning wordlist...")
                $ext = FileGetLongName($wordlist)
                $ext = StringRight($wordlist, 3)
                If Not $ext = "txt" Then
                    $abort = 1
                    dis("Wordlist must be a text file (.txt)...Aborting...")
                EndIf
                If $abort = 0 Then
                    $lines = _FileCountLines($wordlist)
                    $file = FileOpen($wordlist, 0)
                    dis("Preparing to crack...found " & $lines & " words...")
            ;begin cracking
                    Do
                        $line = $line + 1
                        $word = FileReadLine($file, $line)
                        $hash = _Crypt_HashData($word)
                        GUICtrlSetData($Progress1, ($line / $lines) * 100)
                        If $hash = $chash Then
                            dis("Testing: " & $word & " | Hash: " & $hash & " | Success!")
                            dis("=========================")
                            dis("=========================")
                            dis("=========================")
                            dis("Cracked. The word is: " & $word)
                            ControlEnable($controlGui, "", $Input1)
                            ControlEnable($controlGui, "", $Input2)
                            $line = $lines
                        Else
                            dis("Testing: " & $word & " | Hash: " & $hash & " | Fail.")
                        EndIf
                    Until $line = $lines
                EndIf
            EndIf
    EndSelect
WEnd

GUIDelete($controlGui)

For $i = 255 To 0 Step -10
    SetBitmap($GUI, $hImage, $i)
Next


_WinAPI_DeleteObject($hImage)
_GDIPlus_Shutdown()
FileDelete(@ScriptDir & "\Gui.png")
FileDelete(@ScriptDir & "\grey.gif")


Func WM_NCHITTEST($hWnd, $iMsg, $iwParam, $ilParam)
    If ($hWnd = $GUI) And ($iMsg = $WM_NCHITTEST) Then Return $HTCAPTION
EndFunc ;==>WM_NCHITTEST



Func SetBitmap($hGUI, $hImage, $iOpacity)
    Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend

    $hScrDC = _WinAPI_GetDC(0)
    $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC)
    $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage)
    $hOld = _WinAPI_SelectObject($hMemDC, $hBitmap)
    $tSize = DllStructCreate($tagSIZE)
    $pSize = DllStructGetPtr($tSize)
    DllStructSetData($tSize, "X", _GDIPlus_ImageGetWidth($hImage))
    DllStructSetData($tSize, "Y", _GDIPlus_ImageGetHeight($hImage))
    $tSource = DllStructCreate($tagPOINT)
    $pSource = DllStructGetPtr($tSource)
    $tBlend = DllStructCreate($tagBLENDFUNCTION)
    $pBlend = DllStructGetPtr($tBlend)
    DllStructSetData($tBlend, "Alpha", $iOpacity)
    DllStructSetData($tBlend, "Format", $AC_SRC_ALPHA)
    _WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA)
    _WinAPI_ReleaseDC(0, $hScrDC)
    _WinAPI_SelectObject($hMemDC, $hOld)
    _WinAPI_DeleteObject($hBitmap)
    _WinAPI_DeleteDC($hMemDC)
EndFunc ;==>SetBitmap

Func dis($text)
    GUICtrlSetData($Edit1, $text & @CRLF & GUICtrlRead($Edit1))
EndFunc

Func dis2($text)
    GUICtrlSetData($Edit1, $text)
EndFunc

;===============================================================================
; Function Name:    _Crypt_HashData()
; Description:    Calculate hash from data
; Syntax:
; Parameter(s):  $vData - data to hash, can be binary or a string
;              $iAlgID - hash algorithm identifier, can be one of the following:
;                 0x8001 = MD2
;                 0x8002 = MD4
;                 0x8003 = MD5 (default)
;                 0x8004 = SHA1
;                 also see http://msdn.microsoft.com/en-us/library/aa375549(VS.85).aspx
; Requirement(s):
; Return Value(s):  Success = Returns hash string
;              Failure = Returns empty string and sets error:
;                 @error -1 = error opening advapi32.dll
;                 @error 1 = failed CryptAcquireContext
;                 @error 2 = failed CryptCreateHash
;                 @error 3 = failed CryptHashData
; Author(s):   Siao
; Modification(s):
;===============================================================================
Func _Crypt_HashData($vData, $iAlgID = 0x8003)
    Local $hDll = DllOpen('advapi32.dll'), $iLen = BinaryLen($vData), $hContext, $hHash, $aRet, $sRet = "", $iErr = 0, $tDat = DllStructCreate("byte[" & $iLen+1 & "]"), $tBuf
    DllStructSetData($tDat, 1, $vData)
    If $hDll = -1 Then Return SetError($hDll,0,$sRet)
    $aRet = DllCall($hDll,'int','CryptAcquireContext', 'ptr*',0, 'ptr',0, 'ptr',0, 'dword',1, 'dword',0xF0000000);PROV_RSA_FULL = 1; CRYPT_VERIFYCONTEXT = 0xF0000000
    If Not @error And $aRet[0] Then
        $hContext = $aRet[1]
        $aRet = DllCall($hDll,'int','CryptCreateHash', 'ptr',$hContext, 'dword',$iAlgID, 'ptr',0, 'dword',0, 'ptr*',0)
        If $aRet[0] Then
            $hHash = $aRet[5]
            $aRet = DllCall($hDll,'int','CryptHashData', 'ptr',$hHash, 'ptr',DllStructGetPtr($tDat), 'dword',$iLen, 'dword',0)
            If $aRet[0] Then
                $aRet = DllCall($hDll,'int','CryptGetHashParam', 'ptr',$hHash, 'dword',2, 'ptr',0, 'int*',0, 'dword',0);HP_HASHVAL = 2
                $tBuf = DllStructCreate("byte[" & $aRet[4] & "]")
                DllCall($hDll,'int','CryptGetHashParam', 'ptr',$hHash, 'dword',2, 'ptr',DllStructGetPtr($tBuf), 'int*',$aRet[4], 'dword',0)
                $sRet = Hex(DllStructGetData($tBuf, 1))
            Else
                $iErr = 3
            EndIf
            DllCall($hDll,'int','CryptDestroyHash', 'ptr',$hHash)
        Else
            $iErr = 2
        EndIf
        DllCall($hDll,'int','CryptReleaseContext', 'ptr',$hContext, 'dword',0)
    Else
        $iErr = 1
    EndIf
    DllClose($hDll)
    Return SetError($iErr,0,$sRet)
EndFunc
Edited by Firestorm

[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

Link to comment
Share on other sites

Oh my god this could become VERY interesting including the whole ms Word word list using word.au3 ( I saw it in some part of the forum) :)

no such function in word.au3

NICE WORK!

Edited by torels

Some Projects:[list][*]ZIP UDF using no external files[*]iPod Music Transfer [*]iTunes UDF - fully integrate iTunes with au3[*]iTunes info (taskbar player hover)[*]Instant Run - run scripts without saving them before :)[*]Get Tube - YouTube Downloader[*]Lyric Finder 2 - Find Lyrics to any of your song[*]DeskBox - A Desktop Extension Tool[/list]indifference will ruin the world, but in the end... WHO CARES :P---------------http://torels.altervista.org

Link to comment
Share on other sites

Looks good Firestorm. Question; Why are you using the slowest possible method to read the file? Reading the file to an array and then parsing each element is faster than FileReadLine().

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...