hashcat / hashcat

World's fastest and most advanced password recovery utility
https://hashcat.net/hashcat/
20.51k stars 2.81k forks source link

Support for AMD Adrenalin 22.7.1 or later #3501

Open jsteube opened 1 year ago

jsteube commented 1 year ago

What is the problem?

Hashcat uses the HIP-RTC library (similar to CUDA/OpenCL/Metal RTC) which allows the user to compile kernels at runtime using the hiprtc* APIs. This allows Hashcat to use HIP RTC to optimize the kernel code at runtime, resulting in a doubling of performance under certain circumstances.

AMD Adrenalin 22.7.1 (driver version 31.0.12015.1008) no longer exposes hiprtc* symbols.

How does this optimization work?

Some of the hash modes supported by hashcat can be optimized if the problem (the hash) is known at compile time. A good example is a single DEScrypt hash, where the compiler can remove large chunks of kernel code if the SALT is known at compile time.

Example:

Start here: https://github.com/hashcat/hashcat/blob/v6.2.6/OpenCL/m01500_a3-pure.cl#L1535-L1550 In this section of the kernel, the variables s001-s800 depend solely on DESCRYPT_SALT. If it is known at compile time, the optimizer can precompute the values.

This has a big impact on the following section: https://github.com/hashcat/hashcat/blob/v6.2.6/OpenCL/m01500_a3-pure.cl#L1570-L1588 In this section (and all subsequent calls in this block) you will see the myselx() macro to decide what input value to use for the function calls. This macro #define myselx(a,b,c) ((c) ? (b) : (a)) depends on (c), and (c) are the precomputed values from above.

Essentially all of these branches can be removed entirely if the SALT is known at compile time. But this value is only known to the hashcat user at runtime. Therefore, the kernel compilation must be done on the user side using HIP/CUDA/OpenCL/Metal RTC.

This functionality was removed with AMD Adrenalin 22.7.1. However, we were told that it was just moved to a new library called "hiprtc.dll" which you can read from the official HIP RTC repository here: https://github.com/ROCm-Developer-Tools/HIP/blob/rocm-5.3.1/docs/markdown/hip_rtc.md

Currently HIPRTC APIs are separated from HIP APIs and HIPRTC is available as a separate library libhiprtc.so/libhiprtc.dll. 

But that's not the case (at the time of writing: Adrenaline 22.10.3 Optional). The question is where does this hiprtc.dll come from. For Linux it is part of the installation but for Windows the hiprtc.dll driver doesn't seem to install.

Some other project is struggling with the same problem:

https://github.com/GPUOpen-LibrariesAndSDKs/Orochi/issues/35

But they found a nice solution and implemented this with this PR:

https://github.com/GPUOpen-LibrariesAndSDKs/Orochi/pull/38

With commit https://github.com/hashcat/hashcat/commit/6d5d9a266ff37e460d4d3d16a50bd4614319dc98 I followed some of the logic used in their project to update the RTC loader part in hashcat to look for the DLL in the following order:

If AMD later decides to add hiprtc.dll to its driver, hashcat will find it automatically. As mentioned above, it is not present in the current Windows drivers.

Therefore hashcat fails to load the DLL and tries to load contrib/bin/win64/hiprtc0503.dll next. This library doesn't come with Hashcat, but you can download the folder here: https://github.com/GPUOpen-LibrariesAndSDKs/Orochi/tree/f401a29869bc4eae64b0d10f3ae35e284cb42bf7/contrib/bin/win64

I didn't want to include them directly in Hashcat as the authors said they don't know if they will be compatible with newer drivers. But currently it works fine on my test setup.

If you don't want to use the hiprtc0503.dll library, you need to stick to the latest WHQL AMD Adrenaline driver that supports HIP RTC. This is Adrenaline 22.5.1.

I will keep this issue open and update it when the situation changes in the driver.

mostwanted002 commented 1 year ago

I think AMD just re-introduced HIP RTC for supporting blender. Could this be checked?

Berto979 commented 8 months ago

Are there any news if AMD re-introduced HIP RTC for supporting blender? Adrenalin 22.5.1 is becoming old and made a downgrade from Adrenalin 23.10.2, i think isn't a good idea.

Redspe commented 8 months ago

I dont know if this helps anyone, but the site for downloading the HIP SDK was moved and they didn't fix the link, so here it is: https://www.amd.com/en/developer/resources/rocm-hub/eula/licenses.html?filename=AMD-Software-PRO-Edition-23.Q3-Win10-Win11-For-HIP.exe I simply removed the "\amd\languagemasters" from the start of the link

tcsabina commented 6 months ago

So where shall I put "hiprtc0503.dll" on my windows system to make this work?

misakillers commented 3 months ago

So where shall I put "hiprtc0503.dll" on my windows system to make this work? It's in the bin folder, but it doesn't seem to be useful.

mpc19 commented 2 months ago

any update on this because I cannot install 22.5.1 on a 7900XTX and the SDK (both 5.5 and 5.7) doesnt get detected by hashcat?

mostwanted002 commented 2 months ago

@mpc19 You can fork the branch I worked on for implementing HIP RTC and compile it.

Here: https://github.com/mostwanted002/hashcat/tree/hip_rtc_windows_env_implementation