-Brute
#!/bin/bash # # brute # # $1 is intended to be a hash string provided externally # # output is plaintext:encryptedtext # if [ $# -lt 1 ]; then echo "USAGE: $0 HASHSTRING" exit 1 fi for x in {0..9} {A..Z} {a..z}; do for y in {0..9} {A..Z} {a..z}; do for z in {0..9} {A..Z} {a..z}; do # echo -n ${x}${y}: # ./genhash ${x}${y}${z} ./genhashfaster ${x}${y}${z} | ./match "${1}" "${x}${y}${z}" done done done exit 0
-genhash
/* * genhash.c - C program to generate encrypted hashes of strings * * TO COMPILE: gcc -o genhash genhash.c -lcrypt */ #define _XOPEN_SOURCE 700 #include <stdio.h> #include <stdlib.h> #include <unistd.h> int main(int argc, char **argv) { char *hashstring, salt[3]; if (argc < 1) { printf("usage: %s plaintextstring\n", argv[0]); exit(1); } salt[0] = 'A'; salt[1] = 'B'; salt[2] = '\0'; /* do the crypt */ hashstring = crypt(argv[1], salt); printf("%s\n", hashstring); return(0); }
-hashfile
bob:ABzjLK.dcaCYM jim:ABE/KhqRiDV0Y sue:AB/bF7lOzp.xk jon:AB.nqvyUgOrkw ned:ABZOmUPwFxwLI tom:ABBxq0DIdK7pw ann:ABXL.GHaVNqqw lin:ABTyuJeFosESc
-match
#!/bin/bash # # match - compare two strings for equality # # This script uses command-line arguments: # $1 is the string to compare against # $2 is another string, not compared (but will be printed on match) # read str if [ $# -lt 1 ]; then echo "Usage: $0 COMPARESTRING LABELSTRING" exit 1 fi if [ "${1}" = "${str}" ]; then echo "${2}:${1}" fi exit 0
-process
#!/bin/bash # # process - slice up colon-delimited text file into component parts # echo "==============================" for line in `cat hashfile`; do echo "I just read: $line" field1="`echo $line | cut -d':' -f1`" field2="`echo $line | cut -d':' -f2`" ./brute $field2 echo " Field 1 is: $field1" echo " Field 2 is: $field2" echo "==============================" done exit 0