Introduction

Greetings folks, this is going to be a short but usefull one. For those in a hurry, skip to the Installation section.

Let’s start by setting context. What are we trying to solve here? We’re here because we want to “recover” some passwords using hashcat. We have been through the excellent Arch Linux Wiki documentation for installing hashcat, got everything installed, tried using it, and got an error that the currently installed OpenCL driver is unstable and cannot be used.

What is OpenCL anyway? It’s a framework that allows developers to write applications that can run on a variety of different processors without having to know much about the implementation details of each one of them. It’s out of scope for this article but more details about OpenCL can be found here.

The other question that comes to mind is why should we care about OpenCL and why does hashcat need it? Short answer is that computing hashes on the GPU is considerably faster than computing them on the CPU. We can run hashcat with the --force flag to force it to use the CPU to compute hashes for password recovery but it will take a lot more time to get the job done vs using the GPU.

The target machine used for this article is a Lenovo T495s laptop. It has an AMD Ryzen 5 PRO CPU and a Radeon Vega Mobile GPU. When going through the normal installation steps for AMD GPUs, we can naively go with the opencl-mesa runtime first since the package is in the official Arch Linux repository and it supports the open source amdgpu driver. This is the OpenCL runtime hashcat considers unstable and refuses to run on. What’s our open source alternative? the rocm-opencl-runtime from the AUR.

This is where everything got complicated real fast. Adding to the complexity is insisting on only using pacman as the package manager. For stubborn folks, there’s always a way and that’s what we’re going to prove here so let’s get to work.

Installation

Finding the Right Repositories

First and foremost, we’re going to checkout the ROCm Arch repository. It contains all the PKGBUILD files you will need for what is in the official ROCm repository. Had we been using yay as our package manager, we could have simply followed the instructions provided in the ROCm Arch repository read me and be done with it. But that would have been way too easy. Let’s keep our heads down and carry on.

After checking out the repository, we’re ready to start installing packages. The end goal here is to get the rocm-opencl-runtime installed.

Installation Order and Dependencies

One does not simply install the rocm-opencl-runtime package. We need to manually install its dependencies first.

Here’s a complete list of what we will need to install and in what specific order. There is a possibility that some may already be installed. It’s safe to skip those.

  1. Build and install hsakmt-roct.
  2. Build and install llvm-amdgpu.
  3. Build and install rocm-device-libs.
  4. Build and install hsa-rocr.
  5. Build and install rocm_cmake.
  6. Build and install comgr.
  7. Build and install rocclr.

When we’re done installing 1 through 7, we can finally build and install the rocm-opencl-runtime package.

Something to note, the llvm-amdgpu package takes a while to compile and install. We can also expect llvm-amdgpu to need extra dependencies not listed here. Install and carry on. In my specific case, z3 and ninja were missing.

Once rocm-opencl-runtime is installed, we can move on to testing.

Testing

We are now able to use clinfo to list information related to the OpenCL installation. It will look something like this:

$ clinfo
Number of platforms                               1
  Platform Name                                   AMD Accelerated Parallel Processing
  Platform Vendor                                 Advanced Micro Devices, Inc.
  Platform Version                                OpenCL 2.0 AMD-APP.dbg (3212.0)
  Platform Profile                                FULL_PROFILE
  Platform Extensions                             cl_khr_icd cl_amd_event_callback
  Platform Extensions function suffix             AMD

  Platform Name                                   AMD Accelerated Parallel Processing
Number of devices                                 1
  Device Name                                     gfx902+xnack
  Device Vendor                                   Advanced Micro Devices, Inc.
  Device Vendor ID                                0x1002
  Device Version                                  OpenCL 2.0
  Driver Version                                  3212.0 (HSA1.1,LC)
  Device OpenCL C Version                         OpenCL C 2.0
  Device Type                                     GPU
  Device Board Name (AMD)                         AMD Ryzen 5 PRO 3500U w/ Radeon Vega Mobile Gfx

...

Now that the installation is validated, let’s give hashcat a spin and see if it still complains about unstable drivers and implementations.

$ hashcat -mXXXX hashes.txt worldlist.txt
hashcat (v6.1.1) starting...

OpenCL API (OpenCL 2.0 AMD-APP.dbg (3212.0)) - Platform #1 [Advanced Micro Devices, Inc.]
=========================================================================================
* Device #1: gfx902+xnack, 3776/3888 MB (3305 MB allocatable), 11MCU

Minimum password length supported by kernel: 0
Maximum password length supported by kernel: 256

INFO: All hashes found in potfile! Use --show to display them.

Started: Sun Jan 31 18:35:36 2021
Stopped: Sun Jan 31 18:35:38 2021

Perfect, hashcat can now leverage the GPU through the OpenCL runtime we just installed.

Conclusion

There you have it, we were able to get the rocm-opencl-runtime package installed by using pacman only. Honestly, it would have been a lot simpler to just use yay but we demonstrated that it’s possible to do it with pacman with a little extra work. Bonus points, we were able to “recover” passwords by having hashcat use the newly installed OpenCL runtime.

Hopefully these instructions have provided enough guidance to get everything running on your own system.

Thanks for reading and I’ll see you next time!

  • redbay