Quantcast
Channel: User Kamil Maciorowski - Super User
Viewing all articles
Browse latest Browse all 664

Answer by Kamil Maciorowski for Using pattern and charset together in crunch

$
0
0

Where man 1 crunch says "lower case characters", "upper case characters", "numbers", and "symbols", it could say "set 1", "set 2", "set 3" and "set 4". The default sets correspond to the terms the manual uses, respectively, but aside from this "lower case characters" is just an abstract "set 1". In this context @ refers to "set 1" and , refers to "set 2".

You can re-define the sets by giving the tool up to four "charset strings" in the command line (example with two strings), or by using -f /path/to/charset.lst and giving up to four names (aliases) defined in charset.lst. The first string/name will re-define "set 1", the second will re-define "set 2" and so on.

Your command

crunch 4 4 -f /usr/share/crunch/charset.lst mixalpha -t ,@@@ -d 2@ -o /mnt/hgfs/ZZZ/LIST/out.txt

gave just one name (mixalpha), so only "set 1" was re-defined; other sets kept their default values, in particular "set 2" was still "upper case characters".

Your pattern was ,@@@ (in terms of our numbered sets: 2111) and you got strings where the first character was always "upper" (because "set 2" was "upper case characters") but three others were "mixed" (i.e. might be "upper" or "lower", because you re-defined it as such). The pattern was respected.

To get what you describe as "upper-lower-lower-lower", you don't need to re-define anything. "Set 1" is by default "lower case characters" and "set 2" is by default "upper case characters"; so -t ,@@@without strings/names should just work.

If you want "upper-lower-lower-lower-custom-custom" then the easiest way is to re-define "set 3" to your custom values, while keeping "set 1" and "set 2" at their defaults. The special string + denotes the default value. Here:

crunch 6 6 ++'!?' -t ,@@@%%

If you add foo = [!?] to the content of /usr/share/crunch/charset.lst then you will be able to get the same result by using -f:

cat /usr/share/crunch/charset.lst - >/tmp/mycharset <<'EOF'foo = [!?]EOFcrunch 6 6 -f /tmp/mycharset lalpha ualpha foo -t ,@@@%%

In my tests crunch 3.6 does not work reliably with a non-seekable charset file, so something like { cat …; echo 'foo = [!?]'; } | crunch … -f /dev/stdin … does not work well.


Viewing all articles
Browse latest Browse all 664

Trending Articles