Jump to content

Recommended Posts

Posted (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 by kaz
Posted

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

 

Posted

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.

Posted

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.

Posted
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.

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
  • Recently Browsing   0 members

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