Funciona bien, pero no me gustó el código, así que lo rehice siguiendo la idea del autor.
Código
#!/bin/bash #=============================================================================== # # FILE: bruto.sh # # USAGE: ./bruto.sh # # DESCRIPTION: Found passwords in RAR files using a word list # Idea original de http://sourceforge.net/projects/rarbrute/ # OPTIONS: --- # REQUIREMENTS: rar, sed, wc, # BUGS: --- # NOTES: --- # AUTHOR: Leo Gutierrez Ramirez (), leorocko13@hotmail.com # VERSION: 1.0 # CREATED: 31/10/10 22:15:40 MST # REVISION: --- #=============================================================================== function usage() { cat <<EOF `basename $0` file.rar [-d word-list | -n number-limit | -h] -h : Help Author : Leo Gutiérrez R (leorocko13@hotmail.com), idea from aciddata: http://sourceforge.net/projects/rarbrute/files/ EOF exit 1 } function isRAR() { [[ -f "$1" ]] && { if [ "`file -b "$1" | awk '{print $1}'`" = "RAR" ] then return 1; else return 0; fi } || { echo -e "Can't find or read file - $1 -"; return 0; } } args=`getopt d:n:h $* 2> /dev/null` if test $? != 0 then usage; fi set -- $args for i do case "$i" in # -n ############################################################## -n) shift; RARFILE="$3"; NLIMIT="$1"; # Checar que -n sean números : n=`echo ${NLIMIT} | tr -d "[0-9]"` if [[ ! -z $n ]] then echo -e "`basename $0` -> ${NLIMIT} Number needed "; exit 1; fi isRAR ${RARFILE} if [ $? -ne 1 ] then echo -e "\n\t`basename ${RARFILE}` This is no RAR file\n"; exit 1; fi ((i = 0)); while((i <= $NLIMIT)) do test=`rar x -p"${i}" "${RARFILE}" 1>/dev/null 2>/dev/null` test2=$? if [ "$test2" = 0 ] then echo -e "\n file "${RARFILE}" is successfully broken the used key is: \"${i}\"\n\a" exit 0; fi ((i++)); done echo -e "\n\tKey not found\n"; shift; # Romper el ciclo : break; shift; ;; # -d ############################################################# -d) shift; WORDLIST="$1"; RARFILE="$3"; LINES=`wc -l "${WORDLIST}" | awk '{print $1}'` ((n = 1)); while [ "$LINES" -gt "$n" ] do line=`head -"$n" "${WORDLIST}" | tail -1` testing=`rar x -p"$line" "${RARFILE}" 1>/dev/null 2>/dev/null` testing2=`echo $?` if [ "$testing2" = 0 ] then echo -e "\n\tfile "${RARFILE}" is successfully broken"; echo -e "\tthe used keyword is: $line\n\a"; exit 0; fi ((n++)); done # Romper el ciclo : break; shift; ;; -h) usage; ;; *) echo -e "[Unknow Option\a]"; usage; ;; esac done
Para que funcione bien, el formato del diccionario debe ser totalmente UNIX, por lo que hay que remover los CR/LF.
Usen dos2unix:
Código
leo@leo-desktop:~/proyectos/brutorar$ dos2unix -a -d -vv -b -o dic.dic dos2unix: Converting dic.dic leo@leo-desktop:~/proyectos/brutorar$
Ahora sí:
Código
leo@leo-desktop:~/proyectos/brutorar$ bash my_bruto.sh a.rar -d dic.dic file a.rar is successfully broken the used keyword is: leito leo@leo-desktop:~/proyectos/brutorar$