I've found an old multibit.key
wallet but it is ciphered and I want to try to brute force it since I know the first 6 or 7 characters of the password. I'm generating words with a fixed begin and only vary in the end to try to find the password of this wallet. However, when I run the crunch program the bash script is waiting it to end to then start to read each line of the output and since it generates gigabytes of data the program ends up being killed. I want to do in such way that it iterates the loop at each word generated by crunch
wordlist generator, so far my code is the following. What must I change in order to do so?
#!/bin/bash
echo Usage: apply-guesses.sh [key file]
echo Key file: $1
for password in $(crunch 12 12 abcdefghjiklmnopqrstuvwxyz -t PASSWORD_BEGIN@@@@@); do
echo ------
echo Attempting: $password...
openssl enc -d -p -aes-256-cbc -md md5 -a -in $1 -out recovered.key -pass pass:$password
if [ $? -eq 0 ];
then
echo "Success!";
break;
else
echo "Failed";
fi
echo ------
done
I don't have any experience with crunch
but I'm assuming it starts generating output right away. For the sake of this exercise I'll simulate some outpuput with the following function:
$ generate() { printf "1\n2\n3\n"; sleep 3; }
Looks like some sort of buffering-until-the-end with the for
construct, eg:
for s in $(generate)
do
echo $s
done
# 3 second pause ...
1
2
3
But if we switch to a comparable while
construct we don't see the buffering/delays:
while read -r s
do
echo $s
done < <(generate) # output lines are generated right away ...
1
2
3
# 3 second pause ...