Skip to content

Instantly share code, notes, and snippets.

@singe
Created April 17, 2023 11:16
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save singe/008f0174d2496149dbc5d4412f8cc536 to your computer and use it in GitHub Desktop.
Save singe/008f0174d2496149dbc5d4412f8cc536 to your computer and use it in GitHub Desktop.
Generate a list of hashcat masks from a wordlist
#!/bin/bash
# hashcat mask generator
# by @singe
infile="$1"
outfile="$1.freq.masks"
outfile2="$1.length.masks"
tmp=$(mktemp)
cp $infile $outfile
sed -i .bak "s/[[:punct:]]/##SS##/g" $outfile # prevent the lowercase replace changing from ?s to ??l
sed -i .bak "s/[a-z]/?l/g" $outfile
sed -i .bak "s/##SS##/?s/g" $outfile # put the ?s back after the lowecase replace
sed -i .bak "s/[A-Z]/?u/g" $outfile
sed -i .bak "s/[0-9]/?d/g" $outfile
rm $outfile.bak
# Reduce masks to uniques sorted by frequency (i.e. most common at the top)
sort $outfile | uniq -c | sort -rn | sed "s/^[\ 0-9]* //" > $tmp
mv $tmp $outfile
# Reduce masks to uniques sorted by length (i.e. shortest/fastest at the top)
cat $outfile | awk '{ print length, $0 }' | sort -ns | cut -d" " -f2- > $outfile2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment