> For the complete documentation index, see [llms.txt](https://hacking-notes.jord4n.pro/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hacking-notes.jord4n.pro/zh/password-attacks/brute-force-openssh-.enc.md).

# 加密 OpenSSH 密钥破解

> 该 **.enc** 扩展名通常表示一个 **加密文件** （加密的）文件。它用于表示文件内容受数据保护算法保护，使得在没有代码或正确密码的情况下数据不可读。这些文件可能包含不同类型的数据（文本、图像、视频等），并用于保护敏感信息。

该 `.enc` 文件使用一种 **AES-256-CBC** 算法并编码为 **Base64**.

<figure><img src="/files/df1544c24dc540b286df0d70021785d68da3237e" alt=""><figcaption></figcaption></figure>

**步骤 1：Base64 解码**

```bash
cat .drupal.txt.enc | base64 -d > file_decoded.enc
```

<figure><img src="/files/36469c567bb5f3bbd42fa748401af5859f6cbfaf" alt=""><figcaption></figcaption></figure>

**步骤 2：使用 OpenSSL 解密**

要解密该文件，我们需要一个密码。执行以下命令尝试手动解密：

```bash
openssl enc -aes-256-cbc -d -in .drupal.txt.enc -out .drupal.txt -base64
```

<figure><img src="/files/8718aca3315009748847fbe9b2c3e11b96a75bf3" alt=""><figcaption></figcaption></figure>

**步骤 3：暴力破解自动化脚本**

我们使用一个 Bash 脚本来测试一组密码（例如： `rockyou.txt`).

```bash
#!/bin/bash

function ctrl_c(){
    echo -e "/n/n[!] 正在退出.../n"
    tput cnorm; exit 1
}

# Ctrl+C
trap ctrl_c INT

tput civis
for password in $(cat /usr/share/wordlists/rockyou.txt); do
    openssl aes-256-cbc -d -in drupal.enc -out drupal.decrypted -pass pass:$password &>/dev/null

    if [ "$(echo $?)" == "0" ]; then
        echo -e "/n[+] 密码是：$password/n"
        exit 0
    fi
done; tput cnorm
```

**结果：**

找到的密码是： **friends**

<figure><img src="/files/680c5360cd569b3e218f719ecf63be57526e4734" alt=""><figcaption></figcaption></figure>

#### **解密后的消息**

解密后的文件包含一个新密码：

```bash
openssl enc -aes-256-cbc -d -in .drupal.txt.enc -out .drupal.txt -base64

friends
```

* **PencilKeyboardScanner123**

<figure><img src="/files/e6dba694b6f0a4c93771bf800f60a3c8416c2448" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://hacking-notes.jord4n.pro/zh/password-attacks/brute-force-openssh-.enc.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
