Script to loop over list of hashes in a file stuck with variable from the first iteration
![Creative The name of the picture](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgO9GURib1T8z7lCwjOGLQaGtrueEthgQ8LO42ZX8cOfTqDK4jvDDpKkLFwf2J49kYCMNW7d4ABih_XCb_2UXdq5fPJDkoyg7-8g_YfRUot-XnaXkNYycsNp7lA5_TW9td0FFpLQ2APzKcZ/s1600/1.jpg)
![Creative The name of the picture](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYQ0N5W1qAOxLP7t7iOM6O6AzbZnkXUy16s7P_CWfOb5UbTQY_aDsc727chyphenhyphen5W4IppVNernMMQeaUFTB_rFzAd95_CDt-tnwN-nBx6JyUp2duGjPaL5-VgNO41AVsA_vu30EJcipdDG409/s400/Clash+Royale+CLAN+TAG%2523URR8PPP.png)
up vote
0
down vote
favorite
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.
command-line bash scripts
 |Â
show 2 more comments
up vote
0
down vote
favorite
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.
command-line bash scripts
hashcat.net/hashcat
â dessert
Jan 31 at 21:33
I can't recreate your problem with justecho
in the loop â I supposeecho
also prints only the first value for you?
â dessert
Jan 31 at 21:42
Yes it does: echo print 900 once and never again
â frepie
Jan 31 at 21:51
1
you will get better traction if you update your question with a better title
â Scott Stensland
Jan 31 at 21:53
Hmmmm, I ran through your script again, and it should work fine. I am not 100% sure why your's is not looping properly. Maybe it is the space in the shebang line#! /bin/bash
should be#!/bin/bash
.
â Terrance
Jan 31 at 22:20
 |Â
show 2 more comments
up vote
0
down vote
favorite
up vote
0
down vote
favorite
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.
command-line bash scripts
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.
command-line bash scripts
command-line bash scripts
edited Feb 1 at 15:24
muru
131k19275472
131k19275472
asked Jan 31 at 21:18
![](https://i.stack.imgur.com/kb8we.png?s=32&g=1)
![](https://i.stack.imgur.com/kb8we.png?s=32&g=1)
frepie
3241424
3241424
hashcat.net/hashcat
â dessert
Jan 31 at 21:33
I can't recreate your problem with justecho
in the loop â I supposeecho
also prints only the first value for you?
â dessert
Jan 31 at 21:42
Yes it does: echo print 900 once and never again
â frepie
Jan 31 at 21:51
1
you will get better traction if you update your question with a better title
â Scott Stensland
Jan 31 at 21:53
Hmmmm, I ran through your script again, and it should work fine. I am not 100% sure why your's is not looping properly. Maybe it is the space in the shebang line#! /bin/bash
should be#!/bin/bash
.
â Terrance
Jan 31 at 22:20
 |Â
show 2 more comments
hashcat.net/hashcat
â dessert
Jan 31 at 21:33
I can't recreate your problem with justecho
in the loop â I supposeecho
also prints only the first value for you?
â dessert
Jan 31 at 21:42
Yes it does: echo print 900 once and never again
â frepie
Jan 31 at 21:51
1
you will get better traction if you update your question with a better title
â Scott Stensland
Jan 31 at 21:53
Hmmmm, I ran through your script again, and it should work fine. I am not 100% sure why your's is not looping properly. Maybe it is the space in the shebang line#! /bin/bash
should be#!/bin/bash
.
â Terrance
Jan 31 at 22:20
hashcat.net/hashcat
â dessert
Jan 31 at 21:33
hashcat.net/hashcat
â dessert
Jan 31 at 21:33
I can't recreate your problem with just
echo
in the loop â I suppose echo
also prints only the first value for you?â dessert
Jan 31 at 21:42
I can't recreate your problem with just
echo
in the loop â I suppose echo
also prints only the first value for you?â dessert
Jan 31 at 21:42
Yes it does: echo print 900 once and never again
â frepie
Jan 31 at 21:51
Yes it does: echo print 900 once and never again
â frepie
Jan 31 at 21:51
1
1
you will get better traction if you update your question with a better title
â Scott Stensland
Jan 31 at 21:53
you will get better traction if you update your question with a better title
â Scott Stensland
Jan 31 at 21:53
Hmmmm, I ran through your script again, and it should work fine. I am not 100% sure why your's is not looping properly. Maybe it is the space in the shebang line
#! /bin/bash
should be #!/bin/bash
.â Terrance
Jan 31 at 22:20
Hmmmm, I ran through your script again, and it should work fine. I am not 100% sure why your's is not looping properly. Maybe it is the space in the shebang line
#! /bin/bash
should be #!/bin/bash
.â Terrance
Jan 31 at 22:20
 |Â
show 2 more comments
2 Answers
2
active
oldest
votes
up vote
1
down vote
accepted
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
for file
.
#!/bin/bash
listhsh="hashlist.txt"
for hash in $(cat $listhsh); do
echo $hash
hashcat -a 0 -m $hash -O ~/devoir_PIII_Alice.txt /usr/lib/rockyou.txt
done
As a test, I ran the line as an echo line to see if it would work:
~$ ./hashcat_test
900
hashcat -a 0 -m 900 -O ~/devoir_PIII_Alice.txt /usr/lib/rockyou.txt
0
hashcat -a 0 -m 0 -O ~/devoir_PIII_Alice.txt /usr/lib/rockyou.txt
5100
hashcat -a 0 -m 5100 -O ~/devoir_PIII_Alice.txt /usr/lib/rockyou.txt
100
hashcat -a 0 -m 100 -O ~/devoir_PIII_Alice.txt /usr/lib/rockyou.txt
1300
hashcat -a 0 -m 1300 -O ~/devoir_PIII_Alice.txt /usr/lib/rockyou.txt
1400
hashcat -a 0 -m 1400 -O ~/devoir_PIII_Alice.txt /usr/lib/rockyou.txt
10800
hashcat -a 0 -m 10800 -O ~/devoir_PIII_Alice.txt /usr/lib/rockyou.txt
1700
hashcat -a 0 -m 1700 -O ~/devoir_PIII_Alice.txt /usr/lib/rockyou.txt
5000
hashcat -a 0 -m 5000 -O ~/devoir_PIII_Alice.txt /usr/lib/rockyou.txt
600
hashcat -a 0 -m 600 -O ~/devoir_PIII_Alice.txt /usr/lib/rockyou.txt
Hope this helps!
1
$file is defined on each run as whatread
receives from the < operator. It' a fairly common syntax: cyberciti.biz/faq/unix-howto-read-line-by-line-from-file Glad to see your version works though. I don't have hashcat available to test mine :P
â Ketzak
Jan 31 at 21:48
By Jove, you're right. I missed a real obvious one there.
â Ketzak
Jan 31 at 21:52
1
@Ketzak Well, the file is actually defined, but I think there is an issue with the while loop. I changed mine to a for loop instead.
â Terrance
Jan 31 at 21:53
I really like your solution, and I'm gonna tuck that one away for later!
â Ketzak
Jan 31 at 21:54
1
Note that this approach works only because there's no blank lines in the file as well as no multiple items per line. Proper way to read a file line by line is still viawhile IFS= read -r line; do...done < input.txt
type of file.
â Sergiy Kolodyazhnyy
Feb 2 at 0:18
 |Â
show 2 more comments
up vote
0
down vote
You're not quoting your expansions, so they're being evaluated by the shell, which could be problematic. Try this:
#! /bin/bash
listhsh="hashlist.txt"
while read file; do
echo "$file"
hashcat -a 0 -m "$file" -O ~/devoir_PIII_Alice.txt /usr/lib/rockyou.txt
done < $listhsh
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/
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
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
for file
.
#!/bin/bash
listhsh="hashlist.txt"
for hash in $(cat $listhsh); do
echo $hash
hashcat -a 0 -m $hash -O ~/devoir_PIII_Alice.txt /usr/lib/rockyou.txt
done
As a test, I ran the line as an echo line to see if it would work:
~$ ./hashcat_test
900
hashcat -a 0 -m 900 -O ~/devoir_PIII_Alice.txt /usr/lib/rockyou.txt
0
hashcat -a 0 -m 0 -O ~/devoir_PIII_Alice.txt /usr/lib/rockyou.txt
5100
hashcat -a 0 -m 5100 -O ~/devoir_PIII_Alice.txt /usr/lib/rockyou.txt
100
hashcat -a 0 -m 100 -O ~/devoir_PIII_Alice.txt /usr/lib/rockyou.txt
1300
hashcat -a 0 -m 1300 -O ~/devoir_PIII_Alice.txt /usr/lib/rockyou.txt
1400
hashcat -a 0 -m 1400 -O ~/devoir_PIII_Alice.txt /usr/lib/rockyou.txt
10800
hashcat -a 0 -m 10800 -O ~/devoir_PIII_Alice.txt /usr/lib/rockyou.txt
1700
hashcat -a 0 -m 1700 -O ~/devoir_PIII_Alice.txt /usr/lib/rockyou.txt
5000
hashcat -a 0 -m 5000 -O ~/devoir_PIII_Alice.txt /usr/lib/rockyou.txt
600
hashcat -a 0 -m 600 -O ~/devoir_PIII_Alice.txt /usr/lib/rockyou.txt
Hope this helps!
1
$file is defined on each run as whatread
receives from the < operator. It' a fairly common syntax: cyberciti.biz/faq/unix-howto-read-line-by-line-from-file Glad to see your version works though. I don't have hashcat available to test mine :P
â Ketzak
Jan 31 at 21:48
By Jove, you're right. I missed a real obvious one there.
â Ketzak
Jan 31 at 21:52
1
@Ketzak Well, the file is actually defined, but I think there is an issue with the while loop. I changed mine to a for loop instead.
â Terrance
Jan 31 at 21:53
I really like your solution, and I'm gonna tuck that one away for later!
â Ketzak
Jan 31 at 21:54
1
Note that this approach works only because there's no blank lines in the file as well as no multiple items per line. Proper way to read a file line by line is still viawhile IFS= read -r line; do...done < input.txt
type of file.
â Sergiy Kolodyazhnyy
Feb 2 at 0:18
 |Â
show 2 more comments
up vote
1
down vote
accepted
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
for file
.
#!/bin/bash
listhsh="hashlist.txt"
for hash in $(cat $listhsh); do
echo $hash
hashcat -a 0 -m $hash -O ~/devoir_PIII_Alice.txt /usr/lib/rockyou.txt
done
As a test, I ran the line as an echo line to see if it would work:
~$ ./hashcat_test
900
hashcat -a 0 -m 900 -O ~/devoir_PIII_Alice.txt /usr/lib/rockyou.txt
0
hashcat -a 0 -m 0 -O ~/devoir_PIII_Alice.txt /usr/lib/rockyou.txt
5100
hashcat -a 0 -m 5100 -O ~/devoir_PIII_Alice.txt /usr/lib/rockyou.txt
100
hashcat -a 0 -m 100 -O ~/devoir_PIII_Alice.txt /usr/lib/rockyou.txt
1300
hashcat -a 0 -m 1300 -O ~/devoir_PIII_Alice.txt /usr/lib/rockyou.txt
1400
hashcat -a 0 -m 1400 -O ~/devoir_PIII_Alice.txt /usr/lib/rockyou.txt
10800
hashcat -a 0 -m 10800 -O ~/devoir_PIII_Alice.txt /usr/lib/rockyou.txt
1700
hashcat -a 0 -m 1700 -O ~/devoir_PIII_Alice.txt /usr/lib/rockyou.txt
5000
hashcat -a 0 -m 5000 -O ~/devoir_PIII_Alice.txt /usr/lib/rockyou.txt
600
hashcat -a 0 -m 600 -O ~/devoir_PIII_Alice.txt /usr/lib/rockyou.txt
Hope this helps!
1
$file is defined on each run as whatread
receives from the < operator. It' a fairly common syntax: cyberciti.biz/faq/unix-howto-read-line-by-line-from-file Glad to see your version works though. I don't have hashcat available to test mine :P
â Ketzak
Jan 31 at 21:48
By Jove, you're right. I missed a real obvious one there.
â Ketzak
Jan 31 at 21:52
1
@Ketzak Well, the file is actually defined, but I think there is an issue with the while loop. I changed mine to a for loop instead.
â Terrance
Jan 31 at 21:53
I really like your solution, and I'm gonna tuck that one away for later!
â Ketzak
Jan 31 at 21:54
1
Note that this approach works only because there's no blank lines in the file as well as no multiple items per line. Proper way to read a file line by line is still viawhile IFS= read -r line; do...done < input.txt
type of file.
â Sergiy Kolodyazhnyy
Feb 2 at 0:18
 |Â
show 2 more comments
up vote
1
down vote
accepted
up vote
1
down vote
accepted
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
for file
.
#!/bin/bash
listhsh="hashlist.txt"
for hash in $(cat $listhsh); do
echo $hash
hashcat -a 0 -m $hash -O ~/devoir_PIII_Alice.txt /usr/lib/rockyou.txt
done
As a test, I ran the line as an echo line to see if it would work:
~$ ./hashcat_test
900
hashcat -a 0 -m 900 -O ~/devoir_PIII_Alice.txt /usr/lib/rockyou.txt
0
hashcat -a 0 -m 0 -O ~/devoir_PIII_Alice.txt /usr/lib/rockyou.txt
5100
hashcat -a 0 -m 5100 -O ~/devoir_PIII_Alice.txt /usr/lib/rockyou.txt
100
hashcat -a 0 -m 100 -O ~/devoir_PIII_Alice.txt /usr/lib/rockyou.txt
1300
hashcat -a 0 -m 1300 -O ~/devoir_PIII_Alice.txt /usr/lib/rockyou.txt
1400
hashcat -a 0 -m 1400 -O ~/devoir_PIII_Alice.txt /usr/lib/rockyou.txt
10800
hashcat -a 0 -m 10800 -O ~/devoir_PIII_Alice.txt /usr/lib/rockyou.txt
1700
hashcat -a 0 -m 1700 -O ~/devoir_PIII_Alice.txt /usr/lib/rockyou.txt
5000
hashcat -a 0 -m 5000 -O ~/devoir_PIII_Alice.txt /usr/lib/rockyou.txt
600
hashcat -a 0 -m 600 -O ~/devoir_PIII_Alice.txt /usr/lib/rockyou.txt
Hope this helps!
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
for file
.
#!/bin/bash
listhsh="hashlist.txt"
for hash in $(cat $listhsh); do
echo $hash
hashcat -a 0 -m $hash -O ~/devoir_PIII_Alice.txt /usr/lib/rockyou.txt
done
As a test, I ran the line as an echo line to see if it would work:
~$ ./hashcat_test
900
hashcat -a 0 -m 900 -O ~/devoir_PIII_Alice.txt /usr/lib/rockyou.txt
0
hashcat -a 0 -m 0 -O ~/devoir_PIII_Alice.txt /usr/lib/rockyou.txt
5100
hashcat -a 0 -m 5100 -O ~/devoir_PIII_Alice.txt /usr/lib/rockyou.txt
100
hashcat -a 0 -m 100 -O ~/devoir_PIII_Alice.txt /usr/lib/rockyou.txt
1300
hashcat -a 0 -m 1300 -O ~/devoir_PIII_Alice.txt /usr/lib/rockyou.txt
1400
hashcat -a 0 -m 1400 -O ~/devoir_PIII_Alice.txt /usr/lib/rockyou.txt
10800
hashcat -a 0 -m 10800 -O ~/devoir_PIII_Alice.txt /usr/lib/rockyou.txt
1700
hashcat -a 0 -m 1700 -O ~/devoir_PIII_Alice.txt /usr/lib/rockyou.txt
5000
hashcat -a 0 -m 5000 -O ~/devoir_PIII_Alice.txt /usr/lib/rockyou.txt
600
hashcat -a 0 -m 600 -O ~/devoir_PIII_Alice.txt /usr/lib/rockyou.txt
Hope this helps!
edited Jan 31 at 22:22
answered Jan 31 at 21:45
![](https://i.stack.imgur.com/1hPwN.jpg?s=32&g=1)
![](https://i.stack.imgur.com/1hPwN.jpg?s=32&g=1)
Terrance
17.6k23885
17.6k23885
1
$file is defined on each run as whatread
receives from the < operator. It' a fairly common syntax: cyberciti.biz/faq/unix-howto-read-line-by-line-from-file Glad to see your version works though. I don't have hashcat available to test mine :P
â Ketzak
Jan 31 at 21:48
By Jove, you're right. I missed a real obvious one there.
â Ketzak
Jan 31 at 21:52
1
@Ketzak Well, the file is actually defined, but I think there is an issue with the while loop. I changed mine to a for loop instead.
â Terrance
Jan 31 at 21:53
I really like your solution, and I'm gonna tuck that one away for later!
â Ketzak
Jan 31 at 21:54
1
Note that this approach works only because there's no blank lines in the file as well as no multiple items per line. Proper way to read a file line by line is still viawhile IFS= read -r line; do...done < input.txt
type of file.
â Sergiy Kolodyazhnyy
Feb 2 at 0:18
 |Â
show 2 more comments
1
$file is defined on each run as whatread
receives from the < operator. It' a fairly common syntax: cyberciti.biz/faq/unix-howto-read-line-by-line-from-file Glad to see your version works though. I don't have hashcat available to test mine :P
â Ketzak
Jan 31 at 21:48
By Jove, you're right. I missed a real obvious one there.
â Ketzak
Jan 31 at 21:52
1
@Ketzak Well, the file is actually defined, but I think there is an issue with the while loop. I changed mine to a for loop instead.
â Terrance
Jan 31 at 21:53
I really like your solution, and I'm gonna tuck that one away for later!
â Ketzak
Jan 31 at 21:54
1
Note that this approach works only because there's no blank lines in the file as well as no multiple items per line. Proper way to read a file line by line is still viawhile IFS= read -r line; do...done < input.txt
type of file.
â Sergiy Kolodyazhnyy
Feb 2 at 0:18
1
1
$file is defined on each run as what
read
receives from the < operator. It' a fairly common syntax: cyberciti.biz/faq/unix-howto-read-line-by-line-from-file Glad to see your version works though. I don't have hashcat available to test mine :Pâ Ketzak
Jan 31 at 21:48
$file is defined on each run as what
read
receives from the < operator. It' a fairly common syntax: cyberciti.biz/faq/unix-howto-read-line-by-line-from-file Glad to see your version works though. I don't have hashcat available to test mine :Pâ Ketzak
Jan 31 at 21:48
By Jove, you're right. I missed a real obvious one there.
â Ketzak
Jan 31 at 21:52
By Jove, you're right. I missed a real obvious one there.
â Ketzak
Jan 31 at 21:52
1
1
@Ketzak Well, the file is actually defined, but I think there is an issue with the while loop. I changed mine to a for loop instead.
â Terrance
Jan 31 at 21:53
@Ketzak Well, the file is actually defined, but I think there is an issue with the while loop. I changed mine to a for loop instead.
â Terrance
Jan 31 at 21:53
I really like your solution, and I'm gonna tuck that one away for later!
â Ketzak
Jan 31 at 21:54
I really like your solution, and I'm gonna tuck that one away for later!
â Ketzak
Jan 31 at 21:54
1
1
Note that this approach works only because there's no blank lines in the file as well as no multiple items per line. Proper way to read a file line by line is still via
while IFS= read -r line; do...done < input.txt
type of file.â Sergiy Kolodyazhnyy
Feb 2 at 0:18
Note that this approach works only because there's no blank lines in the file as well as no multiple items per line. Proper way to read a file line by line is still via
while IFS= read -r line; do...done < input.txt
type of file.â Sergiy Kolodyazhnyy
Feb 2 at 0:18
 |Â
show 2 more comments
up vote
0
down vote
You're not quoting your expansions, so they're being evaluated by the shell, which could be problematic. Try this:
#! /bin/bash
listhsh="hashlist.txt"
while read file; do
echo "$file"
hashcat -a 0 -m "$file" -O ~/devoir_PIII_Alice.txt /usr/lib/rockyou.txt
done < $listhsh
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/
add a comment |Â
up vote
0
down vote
You're not quoting your expansions, so they're being evaluated by the shell, which could be problematic. Try this:
#! /bin/bash
listhsh="hashlist.txt"
while read file; do
echo "$file"
hashcat -a 0 -m "$file" -O ~/devoir_PIII_Alice.txt /usr/lib/rockyou.txt
done < $listhsh
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/
add a comment |Â
up vote
0
down vote
up vote
0
down vote
You're not quoting your expansions, so they're being evaluated by the shell, which could be problematic. Try this:
#! /bin/bash
listhsh="hashlist.txt"
while read file; do
echo "$file"
hashcat -a 0 -m "$file" -O ~/devoir_PIII_Alice.txt /usr/lib/rockyou.txt
done < $listhsh
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/
You're not quoting your expansions, so they're being evaluated by the shell, which could be problematic. Try this:
#! /bin/bash
listhsh="hashlist.txt"
while read file; do
echo "$file"
hashcat -a 0 -m "$file" -O ~/devoir_PIII_Alice.txt /usr/lib/rockyou.txt
done < $listhsh
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/
edited Jan 31 at 22:01
answered Jan 31 at 21:45
Ketzak
1238
1238
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1001860%2fscript-to-loop-over-list-of-hashes-in-a-file-stuck-with-variable-from-the-first%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
hashcat.net/hashcat
â dessert
Jan 31 at 21:33
I can't recreate your problem with just
echo
in the loop â I supposeecho
also prints only the first value for you?â dessert
Jan 31 at 21:42
Yes it does: echo print 900 once and never again
â frepie
Jan 31 at 21:51
1
you will get better traction if you update your question with a better title
â Scott Stensland
Jan 31 at 21:53
Hmmmm, I ran through your script again, and it should work fine. I am not 100% sure why your's is not looping properly. Maybe it is the space in the shebang line
#! /bin/bash
should be#!/bin/bash
.â Terrance
Jan 31 at 22:20