Reputation: 63
I'm very new to Linux and scripting, but I would like to create a script that runs openssl
to test various ciphers. I know the password, and I know it was encrypted with openssl
, but I don't know which cipher was used. I have been attempting this by changing the cipher manually each time, but I thought understanding how a script could do this might be worth figuring out.
The command I have been using is
openssl bf -d -in file.enc -out file.dcrypt
this prompts me for the password. I have a text file saved with all the ciphers I wish to try with each on a single line.
I want to loop the operation and go through each of the ciphers to see which one works. It would be nice to show the variable as part of the dcrypt file name as well. is pseudo code
start loop n(first line in txt file to eof)
openssl 'n' -d -in file.enc -out file.dcrypt.n (a way to add the password?)
exit eof
Any help would be appreciated.
Upvotes: 3
Views: 2385
Reputation: 63
So after playing around with a simple loop I came up with this. It works and I am really amazed at how straight forward the solution was. Not sure if it's the best solution but it works! I can change the output directory for each script I run so my results don’t overwrite each other. Ciphers.txt contains a cipher format per line
#!/bin/bash
#script to automate openssl testing
while read p; do
openssl $p -d -in encrypted.txt -out test1234/$p.jpg -pass pass:1234
done <ciphers.txt
any comments or critique are appreciated.
Upvotes: 2