hashcat Forum
modified-batchcrack.sh - Printable Version

+- hashcat Forum (https://hashcat.net/forum)
+-- Forum: Deprecated; Ancient Versions (https://hashcat.net/forum/forum-46.html)
+--- Forum: Very old oclHashcat Support (https://hashcat.net/forum/forum-21.html)
+--- Thread: modified-batchcrack.sh (/thread-277.html)



modified-batchcrack.sh - shopeonarope - 02-04-2011

Made some amiable changes to the batchcrack.sh script that I hope people find useful. It'll find if you need cuda or ocl automatically, also you can adjust most options when the script starts instead of having to edit the file.
Code:
#!/bin/bash

##
## conf
##

GPU_DEVICES=1,2
GPU_ACCEL=80
GPU_LOOPS=1024

echo -n "Output File [batchcrack.out]:"
read OUTPUT_FILE
OUTPUT_FILE=${OUTPUT_FILE:-batchcrack.out}

## Enter Hash Mode ##

echo -n "Hash Mode [0]:"
read HASH_MODE
HASH_MODE=${HASH_MODE:-0}

## Read in binary string to turn on or off attack mode ##

echo -n "Attack Mode (Mask, MaskRU, Combo, Hybrid, Brute) [10001]:"
read ATTACK_MODE
ATTACK_MODE=${ATTACK_MODE:-10001}
i=0
while [ $i -lt 6 ]
        do
                digit[${i}]=${ATTACK_MODE:${i}:1}
                ((i +=1))
        done

MASK=${digit[0]}
MASK_ROCKYOU=${digit[1]}
COMBINATOR=${digit[2]}
HYBRID=${digit[3]}
BRUTEFORCE=${digit[4]}

## Ask for dictionary only if needed ##

if [ $HYBRID -eq 1 -o $COMBINATOR -eq 1 ]
then
echo -n "Dictionary File [example.dict]:"
read DICT_FILE
DICT_FILE=${DICT_FILE:-example.dict}
fi

CYGPATH=/usr/bin/cygpath
GREP=grep
WC=wc
DATE=date
MV=mv
ECHO=echo
HEAD=head

##
## help
##

if [ $# -ne 1 ]
then
    echo "usage: $0 hashfile"

    exit -1
fi

##
## find some stuff...
##
function ocl_cuda()
{

    GPU=$($OCLHASHCAT 2>&1 >/dev/null)

}

if [ $OSTYPE == "cygwin" ]
then

    OCLHASHCAT="oclHashcat32.exe"

    ocl_cuda

    if [ -z "$GPU" ]
    then
            OCLHASHCAT="oclHashcat32.exe"
    else
            OCLHASHCAT="cudaHashcat32.exe"
    fi
    INPUT_FILE_OCLHC=$1

    INPUT_FILE=$($CYGPATH $1)
else
    IS_64_BIT=$($GREP ^flags /proc/cpuinfo | $GREP " lm " | $WC -c)

    if [ $IS_64_BIT -eq 0 ]
    then
        OCLHASHCAT="./oclHashcat32.bin"
        ocl_cuda
        if [ -z "$GPU" ]
        then
                OCLHASHCAT="./oclHashcat32.bin"
        else
                OCLHASHCAT="./cudaHashcat32.bin"
        fi
    else
        OCLHASHCAT="./oclHashcat64.bin"
        ocl_cuda
        if [ -z "$GPU" ]
        then
                OCLHASHCAT="./oclHashcat64.bin"
        else
                OCLHASHCAT="./cudaHashcat64.bin"
        fi
    fi

    INPUT_FILE_OCLHC=$1

    INPUT_FILE=$1
fi

##
## concat static
##

OCLFLAGS="\
--quiet \
--remove \
--output-file=$OUTPUT_FILE \
--hash-mode=$HASH_MODE \
--gpu-devices=$GPU_DEVICES \
--gpu-accel=$GPU_ACCEL \
--gpu-loops=$GPU_LOOPS"

##
## function
##

function run
{
    $ECHO -n '$' $OCLHASHCAT ... $@ ...

    START=$($DATE +%s)

    $OCLHASHCAT $OCLFLAGS $INPUT_FILE_OCLHC $@ || exit -1
#    $OCLHASHCAT $OCLFLAGS $INPUT_FILE_OCLHC $@ 2>/dev/null || exit -1

    STOP=$($DATE +%s)

    RUNTIME=$(($STOP - $START));

    LINES_INPUT_FILE=$(wc -l < $INPUT_FILE)

    LINES_OUTPUT_FILE=$(wc -l < $OUTPUT_FILE)

    $ECHO "" RT: $RUNTIME CR: $LINES_OUTPUT_FILE / $LINES_INPUT_FILE

    if [ $LINES_INPUT_FILE -eq 0 ]
    then
        $ECHO
        $ECHO All your hashes have been recovered, see $OUTPUT_FILE
        $ECHO

        $HEAD -10 $OUTPUT_FILE

        exit
    fi
}

##
## init output file
##

if [ -s $OUTPUT_FILE ]
then
    NOW=$($DATE +"%Y%m%d%H%M%S")

    $MV -f $OUTPUT_FILE $OUTPUT_FILE.$NOW
fi

$ECHO -n > $OUTPUT_FILE

##
## mask attacks
##

if [ $MASK -eq 1 ]
then
    $ECHO Running mask attacks

    run ?l?d?d?d ?d?d?d
    run ?l?l?d?d ?d?d?d
    run ?l?l?l?d ?d?d?d
    run ?l?l?l?l ?d?d?d
    run ?l?l?l?l ?l?d?d
    run ?d?l?l?l ?l?l?d
    run ?d?d?l?l ?l?l?l
    run ?d?d?d?l ?l?l?l
    run ?d?d?d?d ?l?l?l
    run ?d?d?d?d ?d?l?l
    run ?d?d?d?d ?d?d?l

    run ?l?d?d?d ?d?d?d?d
    run ?l?l?d?d ?d?d?d?d
    run ?l?l?l?d ?d?d?d?d
    run ?l?l?l?l ?d?d?d?d
    run ?d?d?l?l ?l?l?d?d
    run ?d?d?d?d ?l?l?l?l
    run ?d?d?d?d ?d?l?l?l
    run ?d?d?d?d ?d?d?l?l
    run ?d?d?d?d ?d?d?d?l

    run ?l?d?d?d ?d?d?d?d?d
    run ?l?l?d?d ?d?d?d?d?d
    run ?l?l?l?d ?d?d?d?d?d
    run ?d?d?d?d ?d?d?l?l?l
    run ?d?d?d?d ?d?d?d?l?l
    run ?d?d?d?d ?d?d?d?d?l

    run ?u?d?d?d ?d?d?d
    run ?u?l?d?d ?d?d?d
    run ?u?l?l?d ?d?d?d
    run ?u?l?l?l ?d?d?d
    run ?u?l?l?l ?l?d?d

    run ?u?d?d?d ?d?d?d?d
    run ?u?l?d?d ?d?d?d?d
    run ?u?l?l?d ?d?d?d?d
    run ?u?l?l?l ?d?d?d?d

    run ?u?d?d?d ?d?d?d?d?d
    run ?u?l?d?d ?d?d?d?d?d
    run ?u?l?l?d ?d?d?d?d?d

    $ECHO ""
fi

##
## mask_rockyou attacks
##

if [ $MASK_ROCKYOU -eq 1 ]
then
    $ECHO Running mask_rockyou attacks

    #run ?l?l?l?l   ?l?l?l?l
    run ?l?l?l?l   ?l?l
    run ?l?l?l?l   ?l?l?l
    #run ?l?l?l?l   ?l?l?l?l?l
    run ?d?d?d?d   ?d?d?d
    run ?d?d?d?d   ?d?d?d?d?d?d
    run ?d?d?d?d   ?d?d?d?d
    #run ?l?l?l?l   ?l?l?l?l?l?l
    run ?d?d?d     ?d?d?d
    run ?d?d?d?d?d ?d?d?d?d
    run ?l?l?l?l   ?l?d?d
    #run ?l?l?l?l   ?l?l?l?d?d
    #run ?l?l?l?l   ?l?l?l?l?l?l?l
    run ?l?l?l?l   ?d?d?d?d
    run ?l?l?l     ?l?d?d
    #run ?l?l?l?l   ?l?l?l?l?d?d
    run ?l?l?l?l   ?l?l?d
    #run ?l?l?l?l   ?l?l?l?d
    run ?l?l?l?d   ?d?d?d
    run ?l?l?l?l   ?l?d?d?d?d
    run ?l?l?l?l   ?l?l?d?d?d?d
    #run ?l?l?l?l   ?l?l?l?l?d
    run ?l?l?l?l   ?l?d?d?d
    run ?l?l?l?l   ?l?l?d?d?d
    #run ?l?l?l?l   ?l?l?l?l?l?d
    run ?l?l?l     ?l?l
    run ?l?l?l?l   ?l?d
    run ?l?l?l?l   ?d?d?d
    run ?d?d?d?d?d ?d?d?d?d?d?d
    run ?l?l?d     ?d?d?d
    run ?l?l?l     ?d?d?d
    #run ?l?l?l?l   ?l?l?l?d?d?d
    #run ?l?l?l?l   ?l?l?l?l?l?d?d
    #run ?l?l?l?l   ?l?l?l?d?d?d?d
    run ?s?s?s?s   ?s?s
    run ?l?d?d?d   ?d?d?d
    run ?l?l?d?d   ?d?d?d?d
    run ?s?s?s?s   ?s?s?s
    run ?d?d?d     ?d?d
    run ?l?l?l?d   ?d?d?d?d?d
    run ?s?s?s?s   ?s?s?s?s
    #run ?l?l?l?l   ?l?l?l?l?d?d?d
    run ?d?d?d?d   ?d?d?l
    run ?l?l?l?d   ?d?d?d?d
    run ?l?l?l?l   ?d?d?d?d?d?d
    run ?l?l?d?d   ?d?d?d
    run ?s?s?s?s   ?s?s?d?d
    #run ?s?s?s?s   ?s?s?s?s?s
    run ?d?d?d?d   ?l?l
    run ?l?d?d?d   ?d?d?d?d
    run ?s?l?l?l   ?l?l?d?d
    run ?d?d?d?d   ?l?l?l?l
    run ?s?s?s?s   ?s?d?d
    run ?l?l?l?l   ?l?l?s
    #run ?s?s?s?s   ?s?s?s?s?s?s
    run ?d?d?d?d   ?d?d?l?l
    run ?d?d?d?d   ?l?l?l
    run ?s?s?s?s   ?d?d
    #run ?d?l?l?l   ?l?l?l?l
    run ?d?l?l?l   ?l?l?l
    run ?l?l?l?l   ?d?d?d?d?d
    run ?d?d?d?d   ?d?d?d?l
    run ?s?l?l?l   ?l?l
    run ?s?l?l?l   ?l?l?l
    #run ?l?l?l?l   ?l?l?l?s
    run ?l?l?l?l   ?l?d?d?d?d?d
    run ?d?d?l?l   ?l?l?l?l
    run ?s?s?s?s   ?s?s?d
    run ?s?s?s?s   ?s?s?s?d?d
    #run ?l?l?l?l   ?l?l?l?l?l?l?d
    run ?l?l?l?l   ?l?d?d?d?d?d?d
    #run ?s?l?l?l   ?l?l?l?l
    run ?l?d?d?d   ?d?d
    #run ?l?l?l?l   ?l?l?l?l?s
    run ?l?l?l     ?d?d
    run ?s?l?l?l   ?l?d?d
    #run ?d?l?l?l   ?l?l?l?l?l
    run ?d?d?d?d?l ?l?l?l?l
    #run ?s?l?l?l   ?l?l?l?d?d
    run ?s?s?s     ?s?s
    #run ?s?s?s?s   ?s?s?s?d
    run ?l?d?d?d?d ?d?d?d?d
    run ?d?d?l?l   ?l?l?l
    run ?l?l?l     ?l?d
    #run ?l?l?l?l?l ?l?l?l?l?s
    run ?d?l?l?l   ?l?l
    run ?d?d?l?l   ?l?l
    run ?s?l?l?l   ?l?l?l?d
    #run ?d?l?l?l   ?l?l?l?l?l?l
    run ?l?l?l?l   ?l?s
    #run ?s?s?s?s   ?s?s?s?s?s?s?s
    #run ?s?s?s?s   ?s?s?s?s?d?d
    run ?s?s?s?s   ?s?d
    #run ?d?d?d?d   ?d?d?l?l?l
    #run ?l?l?l?l   ?d?l?l?l?l
    run ?d?d?d?l   ?l?l
    run ?d?d?d?l?l ?l?l?l
    #run ?l?l?l?d   ?l?l?l?l
    run ?s?s?s?s   ?d?d?d?d

    $ECHO ""
fi

##
## combinator attacks
##

if [ $COMBINATOR -eq 1 ]
then
    $ECHO Running combinator attacks

    run $DICT_FILE $DICT_FILE
    run $DICT_FILE $DICT_FILE --rule-left='l$-'

    $ECHO ""
fi

##
## hybrid attacks
##

if [ $HYBRID -eq 1 ]
then
    $ECHO Running hybrid attacks

    run -1 ?l?d?s?u $DICT_FILE ?1
    run -1 ?l?d?s?u $DICT_FILE ?1?1
    run -1 ?l?d     $DICT_FILE ?1?1?1
    run -1 ?d       $DICT_FILE ?1?1?1?1

    run -1 ?l?d?s?u ?1       $DICT_FILE
    run -1 ?l?d?s?u ?1?1     $DICT_FILE
    run -1 ?l?d     ?1?1?1   $DICT_FILE
    run -1 ?d       ?1?1?1?1 $DICT_FILE

    $ECHO ""
fi

##
## bruteforce attacks
##

if [ $BRUTEFORCE -eq 1 ]
then
    $ECHO Running brute-force attacks

    run -1 ?l?d?u?s ?1       ?1
    run -1 ?l?d?u?s ?1?1     ?1
    run -1 ?l?d?u?s ?1?1     ?1?1
    run -1 ?l?d?u?s ?1?1?1   ?1?1
    run -1 ?l?d?u   ?1?1?1   ?1?1?1
    run -1 ?l?d?s   ?1?1?1   ?1?1?1

    run ?d?d?d?d ?d?d?d
    run ?d?d?d?d ?d?d?d?d
    run ?d?d?d?d ?d?d?d?d?d
    run ?d?d?d?d ?d?d?d?d?d?d

    run ?l?l?l?l ?l?l?l
    run ?l?l?l?l ?l?l?l?l

    $ECHO ""
fi



RE: modified-batchcrack.sh - atom - 02-05-2011

this is a very cool contribution. much thanks on that. have you tested it on cygwin?


RE: modified-batchcrack.sh - shopeonarope - 02-08-2011

Errr, no it doesn't work in cygwin. Cygwin doesn't throw the error that the script tests for. I'll have to look into another way of identifying the video card in that environment.