[GH-ISSUE #2007] MASK mode. add 'empty' character to range #1350

Open
opened 2026-10-14 03:45:19 +07:00 by bsakaguchi · 13 comments
Owner

Originally created by @jfoug on GitHub (Jan 25, 2016).
Original GitHub issue: https://github.com/openwall/john/issues/2007

Allow an escape or something to the range syntax, so that a range will output any listed character AND output nothing. Example (very useful for things like dates)

--mask=jan[\b0-2][0-9]19[7-9][0-9]

Here the \b is the escape (not sure that is the right thing, and this would give us these outputs:

jan11970
jan011970
jan111970
jan211970

The jan11970 is the example this issue requests (the empty).

Originally created by @jfoug on GitHub (Jan 25, 2016). Original GitHub issue: https://github.com/openwall/john/issues/2007 Allow an escape or something to the range syntax, so that a range will output any listed character AND output nothing. Example (very useful for things like dates) --mask=jan[\b0-2][0-9]19[7-9][0-9] Here the \b is the escape (not sure that is the right thing, and this would give us these outputs: jan11970 jan011970 jan111970 jan211970 The jan11970 is the example this issue requests (the empty).
Author
Owner

@magnumripper commented on GitHub (Jan 26, 2016):

This would also allow us to run eg. wordlist + mask and try the original word as well as with mask appended. I really like this idea but it has to work for GPU-side mask too, and this may be tricky. Assigning to @Sayantan2048 for now.

<!-- gh-comment-id:174862594 --> @magnumripper commented on GitHub (Jan 26, 2016): This would also allow us to run eg. wordlist + mask and try the original word as well as with mask appended. I really like this idea but it has to work for GPU-side mask too, and this may be tricky. Assigning to @Sayantan2048 for now.
Author
Owner

@jfoug commented on GitHub (Jan 26, 2016):

What esc for the empty? \b is frequently used as a space ' ' character (at least in C). I used it here in this example, but not sure it is the right escape we want to use.

<!-- gh-comment-id:175009366 --> @jfoug commented on GitHub (Jan 26, 2016): What esc for the empty? \b is frequently used as a space ' ' character (at least in C). I used it here in this example, but not sure it is the right escape we want to use.
Author
Owner

@magnumripper commented on GitHub (Jan 26, 2016):

I never heard of \b for space, but indeed for backspace. Anyway I think \0 would be a fair choice if it wasn't for it's different meaning in rules and yet another meaning in regex mode.

BTW we should consult Hashcat team before we make a final decision.

<!-- gh-comment-id:175128865 --> @magnumripper commented on GitHub (Jan 26, 2016): I never heard of \b for space, but indeed for backspace. Anyway I think \0 would be a fair choice if it wasn't for it's different meaning in rules and yet another meaning in regex mode. BTW we should consult Hashcat team before we make a final decision.
Author
Owner

@jfoug commented on GitHub (Jan 26, 2016):

You are right about the backspace. I just had a little brain fart with the space.

I wonder about \+ That is 'close' to the regex usage, for 0 or more (the context is slightly different). But here it would be 0 or 1 instance.

<!-- gh-comment-id:175131227 --> @jfoug commented on GitHub (Jan 26, 2016): You are right about the backspace. I just had a little brain fart with the space. I wonder about `\+` That is 'close' to the regex usage, for 0 or more (the context is slightly different). But here it would be 0 or 1 instance.
Author
Owner

@magnumripper commented on GitHub (Jan 26, 2016):

Yeah \+ might be usable. Anyhow I'm more concerned about whether this is doable at all without ruining GPU-side speed.

Hmmm maybe if GPU-side never picked that particular placeholder? Still, it would now be a variable length base word, which may or may not be tricky... but in hybrid mode they also vary! Let's wait for @Sayantan2048 to comment this.

<!-- gh-comment-id:175135875 --> @magnumripper commented on GitHub (Jan 26, 2016): Yeah `\+` might be usable. Anyhow I'm more concerned about whether this is doable at all without ruining GPU-side speed. Hmmm maybe if GPU-side never picked that particular placeholder? Still, it would now be a variable length base word, which may or may not be tricky... but in hybrid mode they also vary! Let's wait for @Sayantan2048 to comment this.
Author
Owner

@magnumripper commented on GitHub (Jan 26, 2016):

Oh, but mask stuff is ?l and ?u so it would be more like ?+, right? Or even ?? (which is now defined as meaning a single literal questionmark).

<!-- gh-comment-id:175136592 --> @magnumripper commented on GitHub (Jan 26, 2016): Oh, but mask stuff is ?l and ?u so it would be more like ?+, right? Or even ?? (which is now defined as meaning a single literal questionmark).
Author
Owner

@jfoug commented on GitHub (Jan 26, 2016):

I really like ?? but I think that is already defined as the ? literal ?+ still gives me a warm fuzzy about recognizing it's meaning from regex usage.

<!-- gh-comment-id:175168136 --> @jfoug commented on GitHub (Jan 26, 2016): I really like ?? but I think that is already defined as the ? literal ?+ still gives me a warm fuzzy about recognizing it's meaning from regex usage.
Author
Owner

@jfoug commented on GitHub (Jan 27, 2016):

Ok, how about this:

[range] Only outputs r a n g e
(range) Outputs r a n g e and nothing

?d alias for [0-9]
!d alias for (0-9)

<!-- gh-comment-id:175788187 --> @jfoug commented on GitHub (Jan 27, 2016): Ok, how about this: [range] Only outputs r a n g e (range) Outputs r a n g e and nothing ?d alias for [0-9] !d alias for (0-9)
Author
Owner

@ghost commented on GitHub (Jan 27, 2016):

Example: -mask=word(0-9)(a-c). This is not easy.

As it works now:

  • Plaintext length does not change after set_key() (inside GPU, I mean).
  • Mask replacement happens for each position (in word##):
    • w[4] = 0-9;
    • w[5] = a-c

From now on:

plaintext lenght obs
word 4 len=base_len
word0 5 len=base_len+1
word0a 6 ...
word0b 6 ...
worda 5 put (a-c) in w[4] not in w[5]
<!-- gh-comment-id:175847569 --> @ghost commented on GitHub (Jan 27, 2016): Example: -mask=word(0-9)(a-c). This is not easy. As it works now: - Plaintext length does not change after set_key() (inside GPU, I mean). - Mask replacement happens for each position (in word##): - w[4] = 0-9; - w[5] = a-c From now on: | plaintext | lenght | obs | | --- | --- | --- | | word | 4 | len=base_len | | word0 | 5 | len=base_len+1 | | word0a | 6 | ... | | word0b | 6 | ... | | worda | 5 | put (a-c) in w[4] not in w[5] |
Author
Owner

@jfoug commented on GitHub (Jan 27, 2016):

This may not be a viable request. I was just thinking it would be useful to issue only a single mask run and have it handle things such as optional characters.

<!-- gh-comment-id:175899862 --> @jfoug commented on GitHub (Jan 27, 2016): This may not be a viable request. I was just thinking it would be useful to issue only a single mask run and have it handle things such as optional characters.
Author
Owner

@ghost commented on GitHub (Jan 27, 2016):

This is a very useful request. So, if it is not viable on GPU mask mode (it probably hurts performance) this request and a few others have to be addressed somehow (e.g. --min-len=1 --max-len=7).

I guess mask mode has to (when GPU mask available):

  • warn it might be not efficient.
  • turn off GPU mask mode (mask_int_cand.num_int_cand = 1)
  • Or break the job further (e.g.: word# [0-9], word# [a-c], word## ('regular' run))
  • generate all plain candidates (for the subset is not proper for GPU), as it does for --stdout.
  • set_key() + crypt_all() calls.
  • turn on GPU mask mode.
  • go on.

A kind of pre-processor generating the proper inner calls

<!-- gh-comment-id:175917296 --> @ghost commented on GitHub (Jan 27, 2016): This is a very useful request. So, if it is not viable on GPU mask mode (it probably hurts performance) this request and a few others have to be addressed somehow (e.g. --min-len=1 --max-len=7). I guess mask mode has to (when GPU mask available): - warn it might be not efficient. - turn off GPU mask mode (mask_int_cand.num_int_cand = 1) - Or break the job further (e.g.: word# [0-9], word# [a-c], word## ('regular' run)) - generate all plain candidates (for the subset is not proper for GPU), as it does for --stdout. - set_key() + crypt_all() calls. - turn on GPU mask mode. - go on. --- A kind of pre-processor generating the proper inner calls
Author
Owner

@magnumripper commented on GitHub (Jan 28, 2016):

It shouldn't be necessary to turn GPU-side mask off completely. Just make sure any placeholder that includes "the empty" is always on CPU side.

These runs seem to work fine (although slower than optimal) despite not getting anywhere near the target value for GPU-side mask size, and despite the base word is variable length:

$ ../run/john scraped.sam -form:nt-opencl -w -mask:[a-c]?w
$ ../run/john scraped.sam -form:nt-opencl -w -mask:?w[a-c]

Note that due to ?w we do have variable length base words. In both cases, the multiplier ends up as 3 although it wants much more.

<!-- gh-comment-id:176041901 --> @magnumripper commented on GitHub (Jan 28, 2016): It shouldn't be necessary to turn GPU-side mask off completely. Just make sure any placeholder that includes "the empty" is always on CPU side. These runs seem to work fine (although slower than optimal) despite not getting anywhere near the target value for GPU-side mask size, and despite the base word is variable length: ``` $ ../run/john scraped.sam -form:nt-opencl -w -mask:[a-c]?w $ ../run/john scraped.sam -form:nt-opencl -w -mask:?w[a-c] ``` Note that due to ?w we do have variable length base words. In both cases, the multiplier ends up as 3 although it wants much more.
Author
Owner

@magnumripper commented on GitHub (Mar 6, 2018):

Bump. I'm currently doing a major overhaul on mask mode, and this should be reconsidered.

<!-- gh-comment-id:370957974 --> @magnumripper commented on GitHub (Mar 6, 2018): Bump. I'm currently doing a major overhaul on mask mode, and this should be reconsidered.
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#1350
No description provided.