I am currently attending a class on network security and we need to crack hashed passwords. To do so, we use hashcat. Since there are a lot of hashes, I am trying to write a script that would test the hashed password with all the hashes contained in the list. My script is as follows:
1 #! /bin/bash
2 listhsh="hashlist.txt"
3
4
5 while read file; do
6 echo $file
7 hashcat -a 0 -m $file -O ~/devoir_PIII_Alice.txt /usr/lib/rockyou.txt
8 done < $listhsh
the file contains the following values. These are codes defining the type of hash to be tested.
900
0
5100
100
1300
1400
10800
1700
5000
600
The problem I have is that the script opens the file, takes the first line that contains the code for hash type to be tested and runs hashcat with the value in $file=900
. However, once the test finishes with the first value, the script executes hashcat with the same value of $file=900
. So the end result is hashcat doing the same test with $file=900
as many times as there are values in the list.
One option could be a
for
loop. The-m
option is for the hashes to be ran. The file is supposed to feed in value and loop each hash type.The following changes should help your script. I substituted
hash
forfile
.As a test, I ran the line as an echo line to see if it would work:
Hope this helps!
You're not quoting your expansions, so they're being evaluated by the shell, which could be problematic. Try this:
These could be useful:
https://unix.stackexchange.com/questions/68694/when-is-double-quoting-necessary
https://www.cyberciti.biz/faq/unix-howto-read-line-by-line-from-file/