使用脚本的Bruteforce GPG密码

时间:2010-12-25 18:49:49

标签: linux bash ubuntu gnupg brute-force

我在Linux上忘记了我的gpg密钥的密码。有人可以帮我写一个简单的脚本来使用暴力破解密钥吗?我记得密码中可能包含的一些词语,所以希望我的计算机不会花费很长时间来强制它。

如果我无法恢复密码,一切都不会丢失,这只是意味着我将无法在接下来的10天内处理我的项目,直到我重新开始工作以获取另一个文件副本,但是这个我将记住密码的新密钥的时间。

但是,能够在这10天内完成我的项目是很好的。

3 个答案:

答案 0 :(得分:7)

1)脚本不简单,至少你如何设想“简单”。

2)花费很长时间 - 这就是使用密码而不是简单密码。花时间写这样一个脚本,把你可能会或可能不会在短语中的单词加上一个迭代的刺,可能需要十天。

3)你可能也会忘记下一个密码短语。

4)哎呀!

对不起老兄,是时候开始一个新项目了(至少要在接下来的十天里离开 - 我建议使用密码短语作为理想的分心。)

圣诞快乐!

-Oisin

答案 1 :(得分:7)

可能是这样的:

#!/bin/bash
#

# try all word in words.txt
for word in $(cat words.txt); do 

  # try to decrypt with word
  echo "${word}" | gpg --passphrase-fd 0 --no-tty --decrypt somegpgfile.gpg --output somegpgfile;

  # if decrypt is successfull; stop
  if [ $? -eq 0 ]; then

    echo "GPG passphrase is: ${word}";
    exit 0;

  fi

done;

exit 1;

答案 2 :(得分:2)

Tersmitten的回答可能已经过时了。

echo "${word}" | gpg --passphrase-fd 0 -q --batch --allow-multiple-messages --no-tty  --output the_decrypted_file -d /some/input/file.gpg;

我使用上面的行与gpg 2.0.20和libcrypt 1.5.2来实现所需的结果。

相关问题