gpu pow¶
this library contains some efficient SHA256/SHA1 code in CUDA to help solve hash-based proof of work systems
in my tests it's very close to hashcat speeds (hashcat -b -m [1420/120])
it also works on wsl2!
prereqs¶
to install this you'll need:
- a nvidia gpu. sorry but it's the only thing supported on wsl and even on non-wsl it's not easy
- nvidia drivers. if you're on WSL all you need are the windows drivers installed (source)
- nvidia's cuda toolkit. download here.
- rust and maturin (
pip install maturinorapt install python3-maturin)
building¶
you can enable cuda support by reinstalling doglib_rs with:
# local
pip install src/doglib_rs --config-settings=build-args="--features cuda"
# remote
pip install "git+https://github.com/corgeman/doglib.git#subdirectory=src/doglib_rs" --config-settings=build-args="--features cuda"
warning: small wsl2 bug¶
if you get a warning about nvcc being unable to find your drivers, this is a wsl bug. you should add this to your .bashrc:
testing¶
everything should be set up! if you want to test your speeds, you can run
which should report your expected hashrate. if you wanna test sha256 setGPU_BENCH_ALGO=sha256.if you want to ensure you're gpu accelerated, the quickest way is:
using¶
now you should hopefully be able to use this through doglib_rs:
>>> from doglib_rs import pow_solver
>>> # find X such that the first 32 bits of sha1(b'wooting'+X) are 0
>>> pow_solver.hash_bruteforce(b"wooting", "sha1", 32, "leading", "numeric")
b'570502797'
>>>
>>> from hashlib import sha1
>>> sha1(b'wooting'+b'570502797').hexdigest()
>>> '00000000495200a10f8d2baca4148da60bcdcb22'
do_pow might be all you need:
corgo@dog-computer:~/pwn/.config/doglib/research/testpow$ python3 ./testpow.py DEBUG
[+] Opening connection to localhost on port 1089: Done
[DEBUG] Received 0x98 bytes:
b'Do Hashcash for 30 bits with resource "9wLIFMcmGci4"\n'
b'Result: '
[DEBUG] Sent 0x2f bytes:
b'1:30:260331:9wLIFMcmGci4::k-K0GHpmBSo:378f7f70\n'
[*] Switching to interactive mode
[DEBUG] Received 0x12 bytes:
b'Write your code > '
notes¶
since we are trying to go as fast as possible some very long prefixes (len(prefix)%64 >= 50) will not work with this kernel and you will be forced back to the CPU. you will be warned if this happens. if this is a problem you can try decreasing MAX_SUFFIX_LEN inside of constants.rs.
if you know some common POWs that do_pow doesn't cover, make an issue/pr. some i am aware of:
- 0ctf: doable in hashcat, so probably won't add (at least for GPU)