gpt4 book ai didi

c - openssl 解密有时有效

转载 作者:行者123 更新时间:2023-11-30 15:38:01 24 4
gpt4 key购买 nike

我致力于此problem 。如果我尝试解密一个我加密的小短语(如“你好”),我的代码可以工作,但它不适用于给定的密文。我是 openssl 的新手,我找不到问题所在。

int main ()
{
int i, j, k, ret, m;
char pwd[4];
char lower_alphabet[26] = "abcdefghijklmnopqrstuvwxyz";
for (i=0; i<26; i++)
{
for(j=0; j<26; j++)
{
for(k=0; k<26; k++)
{
char cmd[70] = "openssl enc -aes128 -base64 -d -in cipher.enc -pass pass:";
snprintf(pwd, sizeof(pwd), "%c%c%c", lower_alphabet[i], lower_alphabet[j], lower_alphabet[k]);
strncat (cmd, pwd, 3);
if ((ret = system(cmd)) == 0)
{
printf("\n%s\n",pwd);
scanf ("%d", &m);
}
}
}
}

}

所以我的代码尝试所有可能的密码值,每次 openssl 成功退出时,它都会停止以供用户输入。

最佳答案

正确的密码是"is":

$ openssl enc -aes128 -base64 -d -in cipher.enc -pass pass:yes
http://www.youtube.com/watch?v=EzBIH8Frq-8&feature=player_embedded
<小时/>

我通过蛮力找到了它:

  1. 尝试通过以下脚本使用三个小写字母的所有可能组合来解码 cipher.enc 消息:

    #!/bin/bash

    for a in {a..z}; do
    for b in {a..z}; do
    for c in {a..z}; do
    echo -e "\n"
    openssl enc -aes128 -base64 -d -in cipher.enc -pass pass:$a$b$c
    echo -e "\nPASSWD: $a$b$c\n"
    done
    done
    done
  2. 运行此脚本并通过以下命令找出所有足够长的类似单词的字符串

    $ egrep -an --color '.*[[:alpha:]]{8,}' all.txt 
    6401:??l$?? f?T^0?@fJ8)?f?℗???uuEb??KFrVw????߁?LHtsQyfe?
    C5y
    56180:?RCpWmnuWЇ_?y???\߱???cg???V?ߥŕ??{?GyD_?ڼZ???JN+;#?
    85793:http://www.youtube.com/watch?v=EzBIH8Frq-8&feature=player_embedded
  3. 宾果游戏,看来我找到了 secret 消息。我可以通过使用密码“yes”对其进行编码并将结果与​​ cipher.enc 进行比较来检查这一点,有相同的结果。问题解决了!

<小时/>

顺便说一句,看起来 openssl 返回零并不是找出正确密码的充分条件,因为密码“anw”也使 openssl 返回零。

关于c - openssl 解密有时有效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21964593/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com