> 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/cheat-sheets/authentication-sessions/password-recovery.md). Agents can also search and read this documentation through its [MCP server](https://hacking-notes.jord4n.pro/~gitbook/mcp).

# Password Recovery Cheat Sheet: Hashes, Keys and Encrypted Files

Password recovery commands for hash identification, John the Ripper, SSH and GPG keys, KeePass databases, PFX certificates and PuTTY conversion.

## Password Recovery — Cheat Sheet

{% hint style="info" %}
Replace `WORDLIST`, `HASH_FILE`, `FORMAT` and file paths. Use John Jumbo with its conversion scripts available in `PATH`; keep extracted records intact.
{% endhint %}

<details open>

<summary>Hash Identification</summary>

Treat matches as candidates; confirm the format against its source.

{% code title="Identify candidate formats from a hash file" overflow="wrap" %}

```bash
hashid HASH_FILE
```

{% endcode %}

</details>

<details open>

<summary>John the Ripper</summary>

Use `ssh.hash`, `keepass.hash` or `gpg.hash` as `HASH_FILE`. If forcing a format, also pass `--format=FORMAT` to `--show`.

{% code title="Dictionary attack" overflow="wrap" %}

```bash
john --wordlist=WORDLIST HASH_FILE
```

{% endcode %}

{% code title="Force a known format" overflow="wrap" %}

```bash
john --format=FORMAT --wordlist=WORDLIST HASH_FILE
```

{% endcode %}

{% code title="Show recovered passwords" overflow="wrap" %}

```bash
john --show HASH_FILE
```

{% endcode %}

</details>

<details open>

<summary>Protected Keys &#x26; Databases</summary>

{% code title="SSH private key to John format" overflow="wrap" %}

```bash
ssh2john PRIVATE_KEY > ssh.hash
```

{% endcode %}

{% code title="KeePass database to John format" overflow="wrap" %}

```bash
keepass2john DATABASE.kdbx > keepass.hash
```

{% endcode %}

{% code title="Protected OpenPGP private key to John format" overflow="wrap" %}

```bash
gpg2john GPG_PRIVATE_KEY > gpg.hash
```

{% endcode %}

</details>

<details open>

<summary>PFX Certificates</summary>

OpenSSL prompts for the recovered PFX password. `-noenc` writes the private key without encryption.

{% code title="Recover the PFX password with a dictionary" overflow="wrap" %}

```bash
crackpkcs12 -d WORDLIST CERTIFICATE.pfx
```

{% endcode %}

{% code title="Export the unencrypted private key (OpenSSL 3)" overflow="wrap" %}

```bash
openssl pkcs12 -in CERTIFICATE.pfx -nocerts -out private-key.pem -noenc
```

{% endcode %}

{% code title="Export certificates" overflow="wrap" %}

```bash
openssl pkcs12 -in CERTIFICATE.pfx -nokeys -out certificates.pem
```

{% endcode %}

</details>

References: [John](https://www.openwall.com/john/doc/OPTIONS.shtml), [hashID](https://github.com/psypanda/hashID), [crackpkcs12](https://github.com/crackpkcs12/crackpkcs12), [OpenSSL](https://docs.openssl.org/3.3/man1/openssl-pkcs12/).

<details open>

<summary>PuTTY Key Conversion</summary>

Convert a PPK private key with the Unix PuTTYgen CLI. Enter its passphrase if requested; conversion does not recover a forgotten passphrase.

{% code title="Convert PPK to OpenSSH and restrict file permissions" overflow="wrap" %}

```bash
puttygen PRIVATE_KEY.ppk -O private-openssh -o openssh-key
chmod 600 openssh-key
```

{% endcode %}

Source: [PuTTYgen manual](https://manpages.debian.org/bookworm/putty-tools/puttygen.1.en.html).

</details>


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://hacking-notes.jord4n.pro/cheat-sheets/authentication-sessions/password-recovery.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
