Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

Search on Super User… Log in Sign up

Anybody can ask a question


Super User is a question and answer site for
computer enthusiasts and power users. It only
takes a minute to sign up. Anybody can answer

Sign up to join this community


The best answers are voted up and
rise to the top

Home
crunch -d option with simple aA charset Ask Question

Questions
Asked 1 year, 4 months ago Active 1 year, 4 months ago Viewed 642 times
Tags

Users Sorry if this is simple, but I can't find any answer to what should be an easy question.
The Overflow Blog

Unanswered I am simply passing the command to crunch:


0 Podcast 296: Adventures in
Jobs Javascriptlandia
$ crunch 3 3 aA -d 1@
The Loop: A community health indicator

I would expect crunch to generate strings with 3 characters while limiting the same number of lower Featured on Meta
Bycase
usingletter
our site, youaAA
to 1: acknowledge that, you
, AaA , AAa AAAhave read andmy
. However, understand our Cookie Policy, Privacy Policy, and our Terms of Service.
output is:
New Feature: Table Support

Crunch will now generate the following number of lines: 2 Swag is coming back!
aAa
AaA

I tried to set -d 1@ -d 3, to keep my upper case letters, but I get the same results. What am I
Linked
understanding wrong here?
0 Insert letter or number with crunch -t flag
Thanks a lot for your reply,
0 How to generate a Password Dictionary by
Regex?
linux bash kali-linux

Related
share improve this question follow asked Jul 29 '19 at 12:44
Léon André 16 Is there a US International keyboard layout
1
on Linux that mimics Windows' behavior?

add a comment 3 Why less -F option does not work with -S


option

1 Answer Active Oldest Votes 0 crunch - @%,^ appearing at most 3 times

2 Physical disk space consumed by a file and


its name
What am I understanding wrong here?
1 How to use crunch to generate a 8 char
0 uppercase alphanumeric wordlist
crunch doesn't work like this and the manual is somewhat misleading. Its logic makes sense once Crunch: using -d 1, -d 1% options with first
3
you get it; and to get it you need examples (available in the manual), trials and errors. two chars DD

0 Sending correct escape sequences in


Or this answer maybe. :)
terminal

From the manual: 0 Insert letter or number with crunch -t flag

Hot Network Questions


crunch <min-len> <max-len> [<charset string>] [options]
A mode to produce a document in one language or
the other
[…]
How can I prove that a utility function does (or
does not) satisfy diminishing MRS?
charset string
Has anyone seen God or not?
You may specify character sets for crunch to use on the command line or if you leave it
blank crunch will use the default character sets. The order MUST BE lower case How massive can a starship be without becoming
a danger to itself or the star system?
characters, upper case characters, numbers, and then symbols. If you don't follow this
Ken Iverson’s Favourite APL Expression?
order you will not get the results you want. You MUST specify either values for the
character type or a plus sign. […] Find the number of ways to climb a stairway

Does this photo show the "Little Dipper" and "Big


Dipper"?
Where the manual says "lower case characters", "upper case characters", "numbers", and
Is it correct to say "I am scoring my girlfriend/my
"symbols", it could say "set 1", "set 2", "set 3" and "set 4". The default sets correspond to the terms boss" when your girlfriend/boss acknowledge good
the manual uses, respectively, but aside from this "lower case characters" is just an abstract "set things you are doing for them?
1". In this context @ refers to "set 1" and % refers to "set 3". The tool doesn't check if "set 1" or Would this be considered racist?
"lower case characters" are indeed lower case characters!
Which loss function has less optimal answer for
w?
Consider this command:
Would a frozen Earth "brick" abandoned
datacenters?
crunch 1 1 aA bB cC dD Are drugs made bitter artificially to prevent being
# ^^ these are "lower case characters" mistaken for candy?
# ^^ there are "upper case characters"
How to prevent parallel running of SQL Agent jobs
# ^^ these are "numbers"
# ^^ these are "symbols" How can I avoid a clock glitch?

Apple cider clearing up after just a few days


The output is Why don't opaque objects reflect light?

The definition of 1 kelvin


a
A English word for someone who often and
unwarrantedly imposes on others

80's post apocalypse book, two biological


because crunch by default uses "lower case characters" only. If we explicitly tell it to use catastrophes at the end of the war
"numbers" Ampere's Law: Any surface? But what about
these? There must be some requirements right?

crunch 1 1 aA bB cC dD -t % Why did Peter the Great change his daughters'


title to Tsesarevna?

Largest set of words that don’t share letters


then it will use the third set of symbols:
Is it legal to put someone’s mail in their mailbox?

What did Luke know about his father?


c
C
Question feed

Your original command

crunch 3 3 aA -d 1@

specifies aA as "lower case characters" set. Yes, you did tell crunch that A was a "lower case
character". Now -d :

-d numbersymbol
Limits the number of duplicate characters. -d 2@ limits the lower case alphabet to output
like aab and aac . aaa would not be generated as that is 3 consecutive letters of a . The
format is number then symbol where number is the maximum number of consecutive
characters and symbol is the symbol of the the character set you want to limit i.e. @,%^
[…]

So you told crunch that any "lower case character" (from your set, i.e. a or A ) can appear at
most 1 time in a row. And indeed the output you got contains neither aa nor AA .

Sometimes it's useful to forget about "lower case characters" etc., to think in terms of "set N"
instead. The manual seems to be fixed on the premise that "lower case characters" should all be
lower case and so on. Still (at least in Ubuntu) there is a file /usr/share/crunch/charset.lst which
can be used with -f ; it defines various sets that mix the four basic sets or their fragments. This
strongly suggests any set acting as "lower case characters" (or "symbols", or …) is silently
supported.

So if you need to generate strings so the first character is a , 0 or ( and the second character is
a , 1 or ) , then this is the way to go:

crunch 2 2 'a0(' 'a1)' -t @,

Try it. Notice aa appears in the output, but it's neither " a from the first set twice", nor " a from the
second set twice". The pattern @, guarantees the first a is from the first set and the second a is
from the second set. However this distinction is not so strict when -d is involved. The command

crunch 2 2 'a0(' 'a1)' -t @, -d 1@

will not generate aa . This observation leads to the following trick:

crunch 3 3 aA a -d 1,

The output is:

aAa
aAA
AaA
AAa
AAA

which is almost what you wanted. The mechanism seems to be like this:

1. There is no -t , so the tool uses the first set only.


2. It generates all possible outputs (like crunch 3 3 aA ).
3. It discards lines that contradict -d 1, . This option says there cannot be aa in the output. It
doesn't matter the option refers to the second set and all the output comes from the first set.
No aa . Period.

You didn't anticipate aAa because you misinterpreted -d 1@ as "limiting the number of duplicates",
while it's "limiting the number of consecutive duplicates".

Finally note the answer is mostly based on observation rather than the documentation. In particular
the trick seems undocumented, it may be just an accidental result of how crunch works under the
hood. Future upgrades may make the tool behave differently in this matter without breaking
documented features.

share improve this answer follow answered Jul 29 '19 at 23:47


Kamil Maciorowski
47.9k 22 83 128

add a comment

Your Answer

Sign up or log in Post as a guest


Name
Sign up using Google

Sign up using Facebook Email


Required, but never shown

Sign up using Email and Password

Post Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged linux bash kali-linux or ask your
own question.

SUPER USER COMPANY STACK EXCHANGE Blog Facebook Twitter LinkedIn Instagram
NETWORK
Tour Stack Overflow
Technology
Help For Teams
Life / Arts
Chat Advertise With Us
Culture / Recreation
Contact Hire a Developer
Science
Feedback Developer Jobs
Other
Mobile About
Disable Responsiveness Press
Legal
site design / logo © 2020 Stack Exchange Inc; user contributions licensed
Privacy Policy under cc by-sa. rev 2020.12.18.38240

You might also like