Creating masks from dictionary files
#1
Has anyone here found a reliable way to convert a dictionary file to a mask file?

In other words, suppose I want to perform the following replacements for characters found in a dictionary file:

abcdefghijklmnopqrstuvwxyz = ?l
ABCDEFGHIJKLMNOPQRSTUVWXYZ = ?u
0123456789 = ?d
 !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~ = ?s

For example, for all lowercase letters found in a dictionary file, I want to replace those with '?l' in place of lowercase letters.

I have been trying this with sed, but have been encountering some challenges that I haven't worked through yet.


This comes close, but doesn't get all the way there since sed isn't capable of handling the opening and closing bracket symbols well:
cat file.txt | while read maskline; do echo ${maskline} | sed -e 's/l/?l/;s/s/?l/;s/\x3F/?s/;s/a/?l/;s/b/?l/;s/c/?l/;s/d/?l/;s/e/?l/;s/f/?l/;s/g/?l/;s/h/?l/;s/i/?l/;s/j/?l/;s/k/?l/;s/m/?l/;s/n/?l/;s/o/?l/;s/p/?l/;s/q/?l/;s/r/?l/;s/t/?l/;s/u/?l/;s/v/?l/;s/w/?l/;s/x/?l/;s/y/?l/;s/z/?l/;s/1/?d/;s/2/?d/;s/3/?d/;s/4/?d/;s/5/?d/;s/6/?d/;s/7/?d/;s/8/?d/;s/9/?d/;s/0/?d/;s/A/?u/;s/B/?u/;s/C/?u/;s/D/?u/;s/E/?u/;s/F/?u/;s/G/?u/;s/H/?u/;s/I/?u/;s/J/?u/;s/K/?u/;s/L/u?/;s/M/u?/;s/N/?u/;s/O/?u/;s/P/?u/;s/Q/?u/;s/R/?u/;s/S/?u/;s/T/?u/;s/U/?u/;s/V/?u/;s/W/?u/;s/X/?u/;s/Y/?u/;s/Z/?u/;s/\x20/?s/;s/\x21/?s/;s/\x22/?s/;s/\x23/?s/;s/\$/?s/;s/\x25/?s/;s/\x26/?s/;s/\x27/?s/;s/\x28/?s/;s/\x29/?s/;s/\*/?s/;s/\x2B/?s/;s/\x2C/?s/;s/\x2D/?s/;s/\./?s/;s/\x2F/?s/;s/\x3A/?s/;s/\x3B/?s/;s/\x3C/?s/;s/\x3D/?s/;s/\x3E/?s/;s/\x40/?s/;s/[/?s/;s/\x5C/?s/;s/\]/?s/;s/\^/?s/;s/\x5F/?s/;s/\x60/?s/;s/\x7B/?s/;s/\x7C/?s/;s/\x7D/?s/;s/\x7E/?s/'; done

Perhaps a hashcat utility can be created that can do this?  That said, if there is a way to do it with shell commands, and there might be, I can do it with those.

After converting a dictionary file to a mask file, I intend on sorting the most frequently occurring masks at the top of the file so that those are used first when using the mask file.  I know the sort can be done with linux commands, but I need to work out a reliable way to replace lowercase letters, uppercase letters, digits, and special symbols with the mask symbols.

Any advice or guidance is appreciated.
#2
I think ULM (Unified List Manager) can do what you're looking for if you're on windows. When you run ULM look under 'Transform' button at the top then on the right-hand side under Mask Tools pick 'output as mask'
#3
maskgen from PACK (Password Analysis and Cracking Toolkit) is the tool for exactly this job (and can do even more).