kaz Posted June 14, 2019 Posted June 14, 2019 (edited) Hello from france, I want to do with autoit the c++ routine you can find here : https://github.com/riverar/hashlnk/blob/master/hashlnk.cpp I started with hashdata function. I want to test to hash the path to control.exe. By debugging the c++ program, i saw that the path is : {1ac14e77-02e7-4e5d-b744-2eb1ae5198b7}\control.exe I wrote this. #include <WinAPIConv.au3> Local $bData = Binary(StringLower('{1ac14e77-02e7-4e5d-b744-2eb1ae5198b7}\control.exe' & "do not prehash links. this should only be done by the user.")) ConsoleWrite($bData & @CR) Local $iSize = BinaryLen($bData) Local $tData = DllStructCreate('byte['& $iSize & ']') Local $pData = DllStructGetPtr($tData) DllStructSetData($tData, 1, $bData) ConsoleWrite( _WinAPI_HashData($pData, $iSize, 4) & @CRLF) ConsoleWrite('GOOD VALUE : 0x850DD6C5' & @CR) I obtain with this autoit script : 0x6FEB513F This is not the good value, it should be : 0x850DD6C5 I didn't find my mistake. Could comeone help me? Edited June 15, 2019 by kaz
water Posted June 14, 2019 Posted June 14, 2019 Did you have a look at the Crypt UDF that comes with AutoIt? My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
kaz Posted June 14, 2019 Author Posted June 14, 2019 Yes, here is : Func _WinAPI_HashData($pMemory, $iSize, $iLength = 32) If ($iLength <= 0) Or ($iLength > 256) Then Return SetError(11, 0, 0) Local $tData = DllStructCreate('byte[' & $iLength & ']') Local $aRet = DllCall('shlwapi.dll', 'uint', 'HashData', 'struct*', $pMemory, 'dword', $iSize, 'struct*', $tData, 'dword', $iLength) If @error Then Return SetError(@error, @extended, 0) If $aRet[0] Then Return SetError(10, $aRet[0], 0) Return DllStructGetData($tData, 1) EndFunc ;==>_WinAPI_HashData I just see there is a _WinAPI_HashString function, i will try.
kaz Posted June 14, 2019 Author Posted June 14, 2019 When i use _WinAPI_HashString, the result is revert, but it's ok. You help me by making me searching into WinApiConv.au3 Thank you.
spudw2k Posted June 17, 2019 Posted June 17, 2019 On 6/15/2019 at 1:13 AM, kaz said: Yes, here is The function(s) @water was referring to is not the WinAPI one you listed. I believe he was referring to the _Crypt_HashData and _Crypt_HashFile functions. These can run hashing algos (i.e. message digest or secure hashing algorithms) to produce a hash...which may need be what you are looking for anyways. I also wanted to make clear (as I understand it to be), the usage/purpose of the _WinAPI_HashData function to make sure it is doing what you think. The WinAPI function creates a hash of binary data. Using it the way you are in your example, you are hashing the binary representation of your concatenated string [{1ac14e77-02e7-4e5d-b744-2eb1ae5198b7}\control.exedo not prehash links. this should only be done by the user]. If you are intending on hashing the file, you will need to read the file as binary and use that binary data for the function call. Just want to try and make sure you are using it the way you intend to. Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF
kaz Posted June 17, 2019 Author Posted June 17, 2019 Hello, i really wanted to hash the string with hasdata from shlwapi.dll. Thanks.
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