[GH-ISSUE #2034] Mask mode. Problems with empty groups. #1370

Closed
opened 2026-10-14 03:46:14 +07:00 by bsakaguchi · 7 comments
Owner

Originally created by @jfoug on GitHub (Feb 10, 2016).
Original GitHub issue: https://github.com/openwall/john/issues/2034

$ ../run/john -stdout -mask='a[]'
a
a
a
...  255 a's

Debug shows:

parse_hex([aeionrlstmcdyhubkgpjvfwzxq1023985467AEIOLRNSTMCDBYHUPKGJVFWZXQ])
parse_hex([aeionrlstmcdyhubkgpjvfwzxq1023985467])
parse_hex([aeionrlstmcdyhubkgpjvfwzxq1023985467*!$@_])
Custom masks expanded (this is 'mask' when passed to parse_braces()):
'a[]'
parse_braces('a[]')
parse_qtn('a[]')
qw 0 minlen -1 maxlen 0 fmt_len 125 mask_add_len 5
Custom masks expanded (this is 'mask' when passed to init_cpu_mask()):
'a[]'
init_cpu_mask('a[]')
mask_crk_init()
do_mask_crack((null))
generate_template_key('a[]') key (null) len 0 (max 125)
Mask ''pa#'' has no 8-bit
a
....
Originally created by @jfoug on GitHub (Feb 10, 2016). Original GitHub issue: https://github.com/openwall/john/issues/2034 ``` $ ../run/john -stdout -mask='a[]' a a a ... 255 a's ``` Debug shows: ``` parse_hex([aeionrlstmcdyhubkgpjvfwzxq1023985467AEIOLRNSTMCDBYHUPKGJVFWZXQ]) parse_hex([aeionrlstmcdyhubkgpjvfwzxq1023985467]) parse_hex([aeionrlstmcdyhubkgpjvfwzxq1023985467*!$@_]) Custom masks expanded (this is 'mask' when passed to parse_braces()): 'a[]' parse_braces('a[]') parse_qtn('a[]') qw 0 minlen -1 maxlen 0 fmt_len 125 mask_add_len 5 Custom masks expanded (this is 'mask' when passed to init_cpu_mask()): 'a[]' init_cpu_mask('a[]') mask_crk_init() do_mask_crack((null)) generate_template_key('a[]') key (null) len 0 (max 125) Mask ''pa#'' has no 8-bit a .... ```
Author
Owner

@magnumripper commented on GitHub (Feb 10, 2016):

I think we should bail with error both for empty groups (as in []) and undefined placeholders (as in ?9 in a default john.conf)

<!-- gh-comment-id:182581312 --> @magnumripper commented on GitHub (Feb 10, 2016): I think we should bail with error both for empty groups (as in `[]`) and undefined placeholders (as in `?9` in a default john.conf)
Author
Owner

@jfoug commented on GitHub (Feb 10, 2016):

We could do that. Actually, could this both be done in the replacement placeholder fix function?

<!-- gh-comment-id:182581603 --> @jfoug commented on GitHub (Feb 10, 2016): We could do that. Actually, could this both be done in the replacement placeholder fix function?
Author
Owner

@jfoug commented on GitHub (Feb 10, 2016):

What is the proper way to abort?

fprintf(stderr, "Mask error: empty group [] not valid\n");
exit(1);

?

What about pexit() ?

<!-- gh-comment-id:182582191 --> @jfoug commented on GitHub (Feb 10, 2016): What is the proper way to abort? ``` fprintf(stderr, "Mask error: empty group [] not valid\n"); exit(1); ``` ? What about pexit() ?
Author
Owner

@magnumripper commented on GitHub (Feb 10, 2016):

Always error();. pexit() is only for printing strerror(errno).

<!-- gh-comment-id:182591783 --> @magnumripper commented on GitHub (Feb 10, 2016): Always `error();`. pexit() is only for printing strerror(errno).
Author
Owner

@magnumripper commented on GitHub (Feb 10, 2016):

    fprintf(stderr, "Mask error: empty group [] not valid\n");
    error();
<!-- gh-comment-id:182592208 --> @magnumripper commented on GitHub (Feb 10, 2016): ``` fprintf(stderr, "Mask error: empty group [] not valid\n"); error(); ```
Author
Owner

@jfoug commented on GitHub (Feb 10, 2016):

Corrected, and yes, it has better output. So error() properly closes log, and does other 'cleanup' ?

<!-- gh-comment-id:182594582 --> @jfoug commented on GitHub (Feb 10, 2016): Corrected, and yes, it has better output. So error() properly closes log, and does other 'cleanup' ?
Author
Owner

@magnumripper commented on GitHub (Feb 10, 2016):

Yep, we must not use exit() because that breaks some debugging (and potentially some MPI stuff may be placed in error() but currently there isn't any). Using pexit() is technically OK because it will end up using error() in turn, but we should not use it for things that aren't really libc errno stuff.

<!-- gh-comment-id:182595781 --> @magnumripper commented on GitHub (Feb 10, 2016): Yep, we must not use `exit()` because that breaks some debugging (and potentially some MPI stuff may be placed in `error()` but currently there isn't any). Using `pexit()` is technically OK because it will end up using `error()` in turn, but we should not use it for things that aren't really libc errno stuff.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
openwall/john#1370
No description provided.