As much as I like Python, I have a weird obsession with coming up with bash solutions for wargames. I do not want to see each attempt, just the right answer. This has led to some good uses of constructors and grep inversions, improving my ability to Bash.

Today I discovered the true power of the Bash Brace Expansion. The expression ‘{0..9}’ will output the numbers zero through nine, and ‘{a-z}’ will give you all the letters. To get letters and numbers into one variables, nest them:


Armed with this knowledge, let’s generate all four-digit alphanumeric PIN combinations:

# Brute Force Four Character Alphanumeric Password
# Solution for Yrivnguna 6: Runs program ( ~/yrivnguna6) to determine result
# Constructor to generate four character alphanumeric combinations:
for i in {{a..z},{0..9}}{{a..z},{0..9}}{{a..z},{0..9}}{{a..z},{0..9}}
~/yrivnguna6 $i | if grep -q -v "Wrong"; then print 'Answer: $i'; fi