Installing Hashcat with AMD Radeon drivers on Ubuntu Linux

Summary

This post describes how I got the latest build of Hashcat working on a newly installed Ubuntu 20.04.4 LTS.

History

My previous password cracking rig was a 2009 Mac Pro with an AMD Radeon RX580 and this proved a fast and reliable platform for several years until I upgraded the MacOS version to 10.15 (Catalina) after which hashcat started throwing runtime errors like:

> hashcat -b -m 5600

hashcat (v6.2.5) starting in benchmark mode

OpenCL API (OpenCL 1.2 (Jun  8 2020 17:36:15)) - Platform #1 [Apple]
====================================================================
* Device #1: Intel(R) Xeon(R) CPU           X5550  @ 2.67GHz, 32736/65536 MB (8192 MB allocatable), 16MCU
* Device #2: AMD Radeon RX 580 Compute Engine, skipped

----------------------------
* Hash-Mode 5600 (NetNTLMv2)
----------------------------

clBuildProgram(): CL_BUILD_PROGRAM_FAILURE

<program source>:7:10: fatal error: 'inc_vendor.h' file not found
#include "inc_vendor.h"
         ^
* Device #1: Kernel /usr/local/Cellar/hashcat/6.2.5/share/hashcat/OpenCL/shared.cl build failed.

Investigations found that this error was not easy to fix and was due to some obscure changes in the compiler that Apple made for Catalina.

This led me to procure a new cracking rig which also had the advantage of keeping the Mac free for other tasks. Running hashcat while doing other tasks is not recommended and things get very sluggish when hashcat is allowed to run at full speed as well as producing lots of heat.

I used a spare custom-build PC with an Asrock Z87 Extreme6 motherboard and an Intel Core i7-4770 and 20GB ram. This motherboard lacked an M.2 socket so I purchased a new Samsung 870EVO 2.5IN SSD and installed it.

The first question was to decide on an O/S. I initially installed the latest Kali build (2022.2) which installed easily and looked great with the optional Gnome desktop. However, installing the OpenCL drivers proved problematic.

The starting point is https://www.amd.com/en/support where you can select your card series and exact model and then select a installer package according to your O/S:

  • Windows 11 - 64-Bit Edition
  • Windows 10 - 64-Bit Edition
  • Windows 7 - 64-Bit Edition
  • RHEL x86 64-Bit
  • CentOS
  • Ubuntu x86 64-Bit
  • SLED/SLES 15

Of course, there is no kali option but various posts I found suggested it was possible to use the Ubuntu package and manually edit the installer shell script to add kali next to the usual ubuntu and debian etc entries that it picks up from uname -a. However, this did not work and I got a stack of errors when trying to run the install script.

Unfortunately, I didn’t record the exact error, but I recall that it seemed impossible to solve, mainly due to different package names for dependencies.

I bit the bullet and downloaded the most recent Ubuntu dist that AMD support.

I downloaded the server version of Ubuntu 20.04.4 LTS (Focal Fossa) from https://www.releases.ubuntu.com/20.04/ubuntu-20.04.4-live-server-amd64.iso. I chose the server version since I will only be accessing this machine via SSH and its not necesary to include all the overheads for a GUI desktop.

I configured it with LVM partitions with encryption. This is because password hashes and any cracked passwords are highly sensitive and need to be protected at all times.

After installation, the system rebooted and I performed the following steps:

Upgrade all packages to the latest version:

sudo apt update
sudo apt upgrade

The version of hashcat available from Ubuntu’s package manager was years old so I wanted to install the latest version from source.

To do this, enable all src-deb packages in /etc/apt/sources.list and then run sudo apt update again. This allows us to run the apt build-dep command to easily install all the compilers and tools that we need to compile hashcat from source:

sudo apt build-dep hashcat
apt update

Then:

mkdir ~/src/
cd ~/src/
git clone https://github.com/hashcat/hashcat
cd hashcat
make
sudo make install
hashcat -I

After this we can run hashcat, but it does not yet recognize the GPU. To allow this, we must install AMD’s OpenCL drivers.

We started back at https://www.amd.com/en/support and selected my RX6600 card and selected the download link for Radeon Software for Linux installer version 22.10.2 for Ubuntu 20.04.4.

This downloaded a deb file from https://repo.radeon.com/amdgpu-install/22.10.2/ubuntu/focal/amdgpu-install_22.10.2.50102-1_all.deb.

We then use dpkg to install it:

sudo dpkg -i amdgpu-install_22.10.2.50102-1_all.deb

This threw an error about missing dependencies so we ran the following to get them installed, and then repeated the dpkg command:

sudo apt -f install
sudo dpkg -i amdgpu-install_22.10.2.50102-1_all.deb

This was successful and we now had a new command in our path amdgpu-install, so we tried:

sudo amdgpu-install --opencl=rocr

We used the rocr option as this was recommended for ‘recent’ cards, which the RX6600 certainly is.

This showed an error with a list of unmet dependancies all with 32 in their name. We noticed an option for the install script --no-32 so we tried that:

sudo amdgpu-install --opencl=rocr --no-32

This took some time to finish but it completed without error.

Just to be sure, I rebooted the server at this point and then tried the hashcat -I command again and was happy to see the RX6600 had been detected.

Hashcat can also use the CPU but this was showing a warning about pocl drivers. A quick Google suggested the following solution:

sudo apt-get remove --purge pocl-opencl-icd
sudo apt autoremove

This fixed the issue and hashcat -I now had a clean output. Don’t forget to add a sudo to the command or hashcat can’t see the GPU:

$ sudo hashcat -I
hashcat (v6.2.5-439-ged3b52185) starting in backend information mode

OpenCL Info:
============

OpenCL Platform ID #1
  Vendor..: Advanced Micro Devices, Inc.
  Name....: AMD Accelerated Parallel Processing
  Version.: OpenCL 2.1 AMD-APP (3423.0)

  Backend Device ID #1
    Type...........: GPU
    Vendor.ID......: 1
    Vendor.........: Advanced Micro Devices, Inc.
    Name...........: AMD Radeon RX 6600
    Version........: OpenCL 2.0
    Processor(s)...: 14
    Clock..........: 2750
    Memory.Total...: 8176 MB (limited to 6949 MB allocatable in one block)
    Memory.Free....: 8064 MB
    Local.Memory...: 64 KB
    OpenCL.Version.: OpenCL C 2.0
    Driver.Version.: 3423.0 (HSA1.1,LC)
    PCI.Addr.BDF...: 03:00.0

To test it was really working, we ran it in benchmark mode for NT Password hashes:

$ sudo hashcat -m 5600 -b
hashcat (v6.2.5-439-ged3b52185) starting in benchmark mode

OpenCL API (OpenCL 2.1 AMD-APP (3423.0)) - Platform #1 [Advanced Micro Devices, Inc.]
=====================================================================================
* Device #1: AMD Radeon RX 6600, 8064/8176 MB (6949 MB allocatable), 14MCU

----------------------------
* Hash-Mode 5600 (NetNTLMv2)
----------------------------

Speed.#1.........:  1362.8 MH/s (85.23ms) @ Accel:64 Loops:512 Thr:256 Vec:1

Started: Thu May 19 05:20:48 2022
Stopped: Thu May 19 05:20:55 2022