1
0
mirror of https://github.com/hashcat/hashcat.git synced 2024-11-30 03:48:17 +00:00

added example of how not to do printf

This commit is contained in:
Your Name 2020-08-26 22:35:00 +02:00
parent 91d2cbead7
commit 0c4c4d042e

View File

@ -537,17 +537,21 @@ Additionally there is a couple of command line parameters that you want to use:
* -d 1: In case you have multi compute devices in your system, limit it to a single compute device. This is to reduce startup and JiT compile time. * -d 1: In case you have multi compute devices in your system, limit it to a single compute device. This is to reduce startup and JiT compile time.
Typically a developer command line for hashcat looks the following: Typically a developer command line for hashcat looks the following:
``` ```
$ rm -rf kernels $HOME/.nv; ./hashcat -m XXXXX hash.txt word.txt --potfile-disable --self-test-disable -n 1 -u 1 -T 1 --quiet --backend-vector-width 1 -d 1 --force $ rm -rf kernels $HOME/.nv; ./hashcat -m XXXXX hash.txt word.txt --potfile-disable --self-test-disable -n 1 -u 1 -T 1 --quiet --backend-vector-width 1 -d 1 --force
``` ```
If you need to printf from without a _loop kernel, keep in mind that you need to add a branching manually for a specific loop position. If you need to printf from without a _loop kernel, keep in mind that you need to add a branching manually for a specific loop position.
``` ```
if ((loop_pos + i) == 0) printf ("%08x\n", a); if ((loop_pos + i) == 0) printf ("%08x\n", a);
``` ```
When using -n 1 -u 1 -T 1 you shouldn't add
```
if((gid==1) && (lid==1)) {
```
to your kernel, as there will be only one kernel thread, there's no gid==1 (only gid==0) so your code won't be executed.
Some last recommendations about printf() itself. Printing a string %s is not recommended. Missing zero bytes or big endian byte order can be very confusing. Instead try to use only the %08x template for everything. Especially for strings this makes a lot of sense, if for example you want to find unexpected non zero bytes. This can be done by calling printf() multiple times. Get used to this and it will simplify a lot of things for you. Some last recommendations about printf() itself. Printing a string %s is not recommended. Missing zero bytes or big endian byte order can be very confusing. Instead try to use only the %08x template for everything. Especially for strings this makes a lot of sense, if for example you want to find unexpected non zero bytes. This can be done by calling printf() multiple times. Get used to this and it will simplify a lot of things for you.
To decide which type of kernel you want to write (pure or optimized), here are some recommendations when to write an optimized kernel implementation: To decide which type of kernel you want to write (pure or optimized), here are some recommendations when to write an optimized kernel implementation: