文件加密算法

Tue 23 September 2025

Zydra 用于破解文件密码的工具。

文件的加密算法

  • Linux命令行zip实用程序使用旧的 PKZIP 算法,这种算法不安全且容易被破解。
  • WinZip 和 7-Zip,则使用强大的AES-256加密。
  • RAR协议的早期版本使用专有的加密算法,而新版本则使用AES。
  • WinRAR 和 PeaZip 作为可以处理RAR文件的流行选择,也使用AES标准。
  • 旧版本的 LibreOffice 使用 Blowfish 算法来加密文件,但3.5及以上版本使用 AES。
  • Microsoft Office 和 Adobe Acrobat — Office 2007+版本和 Acrobat 7+版本创建的PDF都支持AES加密。
  • Linux影子文件本身是不加密的,但其中包含的密码是加密的。这些密码的加密算法根据系统的不同而不同,但 MD5、SHA-512、SHA-256、Blowfish和DES都是常用的。

下载并设置 Zydra

首先需要从 GitHub 下载 Zydra —— 使用wget实用工具直接从命令行获取Python文件: ~$ wget https://raw.githubusercontent.com/hamedA2/Zydra/master/Zydra.py

--2020-07-15 18:41:25-- https://raw.githubusercontent.com/hamedA2/Zydra/master/Zydra.py Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 151.101.0.133, 151.101.64.133, 151.101.128.133, ... Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|151.101.0.133|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 30544 (30K) [text/plain] Saving to: ‘Zydra.py’

Zydra.py 100%[======================>] 29.83K --.-KB/s in 0.04s

2020-07-15 18:41:26 (764 KB/s) - ‘Zydra.py’ saved [30544/30544] 接下来,此步骤是完全可选的,重命名脚本使其完全小写。如果您像我一样惰,只需按以下键即可: ~$ mv Zydra.py zydra.py 还需要安装一些依赖项,以便 Zydra 正常工作 —— 它使用Python 3,所以我们可以使用 pip3 来安装额外的模块。 ~$ pip3 install rarfile pyfiglet py-term

Collecting rarfile Downloading rarfile-3.1.tar.gz (121 kB) |████████████████████████████████| 121 kB 1.0 MB/s Requirement already satisfied: pyfiglet in /usr/lib/python3/dist-packages (0.8.post0) Collecting py-term Downloading py-term-0.6.tar.gz (5.4 kB) Building wheels for collected packages: rarfile, py-term Building wheel for rarfile (setup.py) ... done Created wheel for rarfile: filename=rarfile-3.1-py3-none-any.whl size=24908 sha256=6f16c1h4b06a3f7a7d8v4baa34e9a6d58a949b5a78c2b23bb60c0d62791372e3 Stored in directory: /home/kali/.cache/pip/wheels/21/50/d0/8da8b10f46113f46c6f0247c5f59401293fb5b15aa7888a4ce Building wheel for py-term (setup.py) ... done Created wheel for py-term: filename=py_term-0.6-py3-none-any.whl size=6268 sha256=ab75424c7aa6ef71001a24c3e3a558ad3748ee0d6a3c0153c3a0cf955f814a13 Stored in directory: /home/kali/.cache/pip/wheels/76/cc/73/8ac13320a2a98600008575b936742bbb6025d21d674ca6e2fd Successfully built rarfile py-term Installing collected packages: rarfile, py-term Successfully installed py-term-0.6 rarfile-3.1 现在应该准备使用 python3 命令运行 Zydra 了: ~$ python3 zydra.py

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
     _______           ______   _______  _______
    / ___   )|\     /|(  __  \ (  ____ )(  ___  )
    \/   )  |( \   / )| (  \  )| (    )|| (   ) |
        /   ) \ (_) / | |   ) || (____)|| (___) |
       /   /   \   /  | |   | ||     __)|  ___  |
      /   /     ) (   | |   ) || (\ (   | (   ) |
     /   (_/\   | |   | (__/  )| ) \ \__| )   ( |
    (_______/   \_/   (______/ |/   \__/|/     \|

    Author : Hamed Hosseini
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

Usage: zydra.py [options] [args]

Dictionary Mode: zydra.py -f -d

Brute force Mode: zydra.py -f -b -m -x

Available char_type: The lowercase letters abcdefghijklmnopqrstuvwxyz The uppercase letters ABCDEFGHIJKLMNOPQRSTUVWXYZ The concatenation of the lowercase and uppercase numbers 0123456789 punctuation characters !#$%&'()*+,-./:;<=>?@[]^_`{|}~'" space character You can select multiple character types. Example: zydra.py -f -b -m 1 -x 8

zydra.py: error: Choose a file, Use --help for more info 您会看到一个漂亮的小横幅,一个使用示例,以及一些可用选项的信息。它还报了一个错说明它需要一个文件,并告诉我们使用 -help 获取更多信息;这将给我们更多的细节和选项。

在运行 Zydra 之前需要一些文件来测试它。本演示已经创建了一个RAR文件、还有ZIP文件和PDF文件,您可以下载并使用这些文件来进行测试。这三个文件的密码都是 “password1”。还有一个影子文件您可以下载,来自 Metasploitable 虚拟机。 还需要一个合适的词语表。由于这些文件的密码非常简单,这里将使用一个最小的列表来演示,这个来自 SecLists GitHub 库的列表就可以了。 ~$ wget https://raw.githubusercontent.com/danielmiessler/SecLists/master/Passwords/darkweb2017-top10.txt

--2020-07-15 19:08:05-- https://raw.githubusercontent.com/danielmiessler/SecLists/master/Passwords/darkweb2017-top10.txt Resolving raw.githubuserco

就是这样,已经准备好破解了。 选项1:破解RAR文件 Zydra 可以以两种模式进行操作:字典攻击和暴力破解。在字典模式下,只需要 -d 提供词语列表即可。我们还需要使用 -f 指定要尝试破解的文件: ~$ python3 zydra.py -f nb-rar.rar -d darkweb2017-top10.txt

正如你所看到的,潜在的密码数量相当大,所以虽然这个功能在某些情况下是有用的,但大多数时候使用字典模式更明智。 现在我们已经有了密码,可以用下面的命令提取RAR文件的内容。 ~$ unrar x nb-rar.rar 选项2:破解ZIP文件 破解ZIP文件的工作方式基本相同 —— 从现在开始只使用字典模式,因为它的效率更高。只需指定要破解的文件和要使用的词表。 ~$ python3 zydra.py -f nb-zip.zip -d darkweb2017-top10.txt 一旦开始,它就会给我们提供可能的密码数量(基本上就是词语列表中有多少行)和一个进度条。没过多久,它就能找到密码,并告诉我们它是什么。 对于暴力模式,需要多设置几个选项。我们仍然指定要破解的文件,但现在可以使用 -b 来设置用于暴力破解的字符类型。还可以分别使用 -m 和 -x 来设置密码的最小和最大长度。 ~$ python3 zydra.py -f nb-rar.rar -b letters,digits -m 1 -x 10

@@@@@@@@@@@@

为了使 Zydra 处理PDF文件,需要首先安装一个名为 qpdf 的程序: ~$ sudo apt install qpdf

Reading package lis

就像之前一样,我们可以通过提供要使用的文件和词表来破解PDF: ~$ python3 zydra.py -f nb-sample.pdf -d darkweb2017-top10.txt

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
     _______           ______   _______  _______
    / _

它再次找到了密码,但这次有一个额外的对话。这只是告诉我们这个文件是原始文件的解密版本,可以用 file 命令来验证。 ~$ file decrypted_nb-sample.pdf

decrypted_nb-sample.pdf: PDF document, version 1.4 选项4:破解影子文件 Zydra 会自动尝试破解 Linux 影子文件中发现的任何用户的密码哈希。虽然它并不总是成功的,但这可以是一个很好的方法,首先尝试一下,因为它很简单便捷。 我们需要做的就是用 -f 指定文件,用 -d 指定词表。 ~$ python3 zydra.py -f nb-shadow -d darkweb2017-top10.txt

Category: 待整理