acceder au document
#!/bin/bash
function testFile(){
if [ ! -r $1 ] ; then
echo "file $1 isn't readable..."
exit 2
fi
}
echo "This is a script witch perform a dictionnary attac on crypted"
echo "it uses the following tools:"
echo
ccrypt --version
echo
if [ -z $2 ] ; then
echo "usage: $0 dictionnaryFile cipherText"
echo " you may use absolute pathname, current pathname is:"
echo " "`pwd`
exit 1;
fi
################################################################################
# verify if files exist
testFile $1
testFile $2
tmp1file=".$1.tmp1.words"
tmp2file=".$1.tmp2.words"
echo "create $tmp1file and $tmp2file as tempory files"
echo
#for next step, word separators may be \n and not space as human do
sed -e 'y/\t /\n\n/' $1 > $tmp1file
#useless to test a word twice
sort -u $tmp1file > $tmp2file
################################################################################
echo "please wait while trying the dictionnary.."
echo
i=0;
while read lineWitchIsAWord
do
ccrypt --tmpfiles -d --key $lineWitchIsAWord $2 &> /dev/null
if [ $? -eq 0 ];then
rm -v $tmp1file $tmp2file
echo
echo "found ! ($i before), cypher is now removed"
echo $lineWitchIsAWord
exit 0;
fi
i=$(($i+1))
done < $tmp2file
rm -v $tmp1file $tmp2file
echo
echo "not found, sorry"
exit 1