Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/linq/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux bash脚本来运行各种openssl密码来解密文件_Linux_Bash_Loops - Fatal编程技术网

Linux bash脚本来运行各种openssl密码来解密文件

Linux bash脚本来运行各种openssl密码来解密文件,linux,bash,loops,Linux,Bash,Loops,我对Linux和脚本非常陌生,但我想创建一个运行openssl的脚本来测试各种密码。我知道密码,我知道它是用openssl加密的,但我不知道使用了哪种密码。我一直试图通过每次手动更改密码来实现这一点,但我认为了解脚本如何实现这一点可能值得一试。 我一直使用的命令是 openssl bf -d -in file.enc -out file.dcrypt 这会提示我输入密码。 我有一个保存了所有密码的文本文件,我希望在一行中使用每个密码 我想循环这个操作,检查每一个密码,看看哪一个有效。最好将变

我对Linux和脚本非常陌生,但我想创建一个运行
openssl
的脚本来测试各种密码。我知道密码,我知道它是用
openssl
加密的,但我不知道使用了哪种密码。我一直试图通过每次手动更改密码来实现这一点,但我认为了解脚本如何实现这一点可能值得一试。 我一直使用的命令是

openssl bf -d -in file.enc -out file.dcrypt 
这会提示我输入密码。 我有一个保存了所有密码的文本文件,我希望在一行中使用每个密码

我想循环这个操作,检查每一个密码,看看哪一个有效。最好将变量显示为dcrypt文件名的一部分。 这是伪代码

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

任何帮助都将不胜感激。

所以在玩了一个简单的循环之后,我想出了这个。它是有效的,我真的很惊讶这个解决方案是多么的直截了当。不确定这是否是最好的解决方案,但它确实有效!我可以更改运行的每个脚本的输出目录,这样结果就不会相互覆盖。Ciphers.txt每行包含一种密码格式

#!/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
#/bin/bash
#自动化openssl测试的脚本
读p;做
openssl$p-d-in encrypted.txt-out test1234/$p.jpg-pass-pass:1234

这样做将遍历文件中的每一行,即使第一行有效。您应该检查
openssl
(在命令运行后将存储在
$?
中)的退出状态,如果为0,则检查
exit
,这表示成功。