Script to loop over list of hashes in a file stuck with variable from the first iteration

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP








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.










share|improve this question























  • 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










  • 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














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.










share|improve this question























  • 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










  • 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












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.










share|improve this question















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Feb 1 at 15:24









muru

131k19275472




131k19275472










asked Jan 31 at 21:18









frepie

3241424




3241424











  • 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










  • 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










  • 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






  • 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










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!






share|improve this answer


















  • 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











  • 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 via while IFS= read -r line; do...done < input.txt type of file.
    – Sergiy Kolodyazhnyy
    Feb 2 at 0:18

















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/






share|improve this answer






















    Your Answer







    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "89"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













     

    draft saved


    draft discarded


















    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






























    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!






    share|improve this answer


















    • 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











    • 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 via while IFS= read -r line; do...done < input.txt type of file.
      – Sergiy Kolodyazhnyy
      Feb 2 at 0:18














    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!






    share|improve this answer


















    • 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











    • 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 via while IFS= read -r line; do...done < input.txt type of file.
      – Sergiy Kolodyazhnyy
      Feb 2 at 0:18












    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!






    share|improve this answer














    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!







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Jan 31 at 22:22

























    answered Jan 31 at 21:45









    Terrance

    17.6k23885




    17.6k23885







    • 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











    • 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 via while IFS= read -r line; do...done < input.txt type of file.
      – Sergiy Kolodyazhnyy
      Feb 2 at 0:18












    • 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











    • 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 via while 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












    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/






    share|improve this answer


























      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/






      share|improve this answer
























        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/






        share|improve this answer














        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/







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Jan 31 at 22:01

























        answered Jan 31 at 21:45









        Ketzak

        1238




        1238



























             

            draft saved


            draft discarded















































             


            draft saved


            draft discarded














            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













































































            Popular posts from this blog

            pylint3 and pip3 broken

            Missing snmpget and snmpwalk

            How to enroll fingerprints to Ubuntu 17.10 with VFS491