Hashcat: How to Change Device on a Session Restore

Hashcat restore was defaulting to a device ID that was no longer the correct one. I needed to update the device IDs. Specifically, I needed to add two new command line options...

Hashcat: How to Change Device on a Session Restore

I have been playing around with hashcat for a little while now. Hashcat is a powerful password recovery tool that supports a slew of algorithms. I've been teaching myself how to use it - working out how best to use the various attack modes.

Often these sessions take quite some time to run - days, weeks, months. One configuration I tried gave an estimate in light-years! Fortunately, the hashcat developers were kind enough to add the ability to checkpoint & restore sessions.

It has been very convenient to stop and then restart these sessions sometime later. Not that long ago I had to checkpoint a session to work on some other projects. A few weeks went by before I was able to return to hashcat. When I went to restore the session, I was greeted with the following errors.

hashcat (v6.1.1) starting in restore mode...

* Device #1: Unstable OpenCL driver detected!

This OpenCL driver has been marked as likely to fail kernel compilation or to produce false negatives. You can use --force to override this, but do not report related errors.

No devices found/left.

It turns that that in between the time I started the session and attempted to restore it, I made some hardware changes. I pulled the graphics card from my machine and enabled the integrated graphics. These changes prevented me from restoring the hashcat session. I believe hashcat simply indexes device IDs, so by changing hardware, the devices got re-ordered. Therefore, hashcat was defaulting to a device ID that was no longer the correct one. I needed to update the device IDs.

Specifically, I needed to add two new command line options -D 1 -d 2 in order to target the correct device.

A quick look at the docs told me there was no direct ability to change this from the restore command. However, the binary file format was well documented.

The two sections to update are the argv and argc. I made a backup copy of the {session-name}.restore file, then used a hex editor to open edit the file.

I appended the new command options at the end of the argv section. The most important step is to update the argc. It can be tricky to convert hex to u32 with little-endian byte order. I used this web site to check my conversion. Also remember that args are space separated, so pay attention that the value of argc matches the desired arg count.

After saving those changes, I was back in business!🚀