bkerler / opencl_brute

MD5,SHA1,SHA256,SHA512,HMAC,PBKDF2,SCrypt Bruteforcing tools using OpenCL (GPU, yay!) and Python
MIT License
163 stars 44 forks source link

Why GPU is slower than CPU? #24

Open weizier opened 9 months ago

weizier commented 9 months ago

My PC is Mac M2 pro, hashlib.sha256 is 2x~10x faster than opencl sha256 with GPU, am I wrong somewhere?

Marek2k17 commented 9 months ago

i was looking into the code and i am not 100% sure about this but for me it looks like the sha256 kernel will just do the sha256 calculation and pass the result back to the host device. The host device will then handle the result, if this is realy the case i am not sure why this was implemented in OpenCL if you don't make use of the kernel to crack hashes?

You can check yourself in the opencl.py line 364 following... or use this link to check yourself https://github.com/bkerler/opencl_brute/blob/e2027b3842fab18f379925699171f4020cd664ab/Library/opencl.py#L364C58-L364C58

i don't see any logic in the sha256.cl kernel that would update the input or check for the target hash. https://github.com/bkerler/opencl_brute/blob/e2027b3842fab18f379925699171f4020cd664ab/Library/worker/generic/sha256.cl#L332

the output struct can be found here https://github.com/bkerler/opencl_brute/blob/e2027b3842fab18f379925699171f4020cd664ab/Library/worker/generic/buffer_structs_template.cl#L79

You should check hashcat for your usecase :)