Created
November 1, 2012 12:30
-
-
Save melissaboiko/3993379 to your computer and use it in GitHub Desktop.
script to generate hexadecimal "words". warning: this makes your identifiers more vulnerable to discover.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -e | |
sources='/usr/share/dict/american-english /usr/share/dict/brazilian' | |
function usage() | |
{ | |
echo "Script to find words that can be spelled in hexa. | |
Notice that this can make identifiers more vulnerable to discovery. | |
By default, this uses English and Brazilian wordlists; edit the script | |
header if this is undesirable. Works better if uni2ascii is installed. | |
tl;dr: apt-get install wamerican wbrazilian uni2ascii | |
Usage: $0 <OPTIONS> | |
Options: | |
-l: enable l33t | |
-s: match size in regex format (default: 4) | |
-u: include words in the wordlist that use uppercase (often proper names) | |
Examples: | |
$0 -s 4,8 -> find hexawords between 4 and 8 digits | |
$0 -l -s 8, -> find hexawords 8 digits or longer, with l33t | |
" | |
exit | |
} | |
temp=$(tempfile) | |
function cleanup() | |
{ | |
rm -f $temp | |
} | |
trap cleanup EXIT | |
unset leet | |
unset uppercase | |
size=4 | |
while getopts "ls:uh" option; do | |
case $option in | |
l) leet=y;; | |
s) size=$OPTARG;; | |
u) uppercase=y;; | |
h) usage;; | |
*) usage;; | |
esac | |
done | |
for f in $sources; do | |
if ! [ -f "$f" ]; then | |
echo "Can't find file "$f"." >&2 | |
echo "Do you need to install a wordlist package (wamerican, wbrazilian...)?" >&2 | |
exit 1 | |
elif file -i "$f" | grep -q -i iso-8859-1; then | |
iconv -f iso-8859-1 -t utf-8 < "$f" >> $temp | |
else | |
cat "$f" >> $temp | |
fi | |
done | |
chars="0-9a-f" | |
if [ $leet ]; then | |
chars="${chars}oisl" | |
fi | |
if [ $uppercase ]; then | |
grepopts='-i' | |
fi | |
if which uni2ascii >/dev/null; then | |
filter='uni2ascii -B -q' | |
else | |
echo "Warning: missing uni2ascii(1), will ignore non-ascii characters." >&2 | |
filter='cat' | |
fi | |
$filter < $temp | egrep $grepopts "^[$chars]{$size}$" | tr oisl 0157 | tr '[:upper:]' '[:lower:]' | sort -u |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment