# Kindle Key Finder — KA Edition

> **Android method for removing Kindle DRM**  
> Decrypt your Kindle books using the Android emulator and Frida instrumentation — no Windows Store app required.

[![Latest Release](https://img.shields.io/github/v/release/jadehawk/Kindle_Android_Key_Finder?label=latest)](https://github.com/jadehawk/Kindle_Android_Key_Finder/releases/latest)

---

## Table of Contents

- [Overview](#overview)
- [How It Works](#how-it-works)
- [Requirements](#requirements)
- [Installation & Setup](#installation--setup)
- [Running the Script](#running-the-script)
- [The Three Phases](#the-three-phases)
- [Configuration Options](#configuration-options)
- [History & Skip Logic](#history--skip-logic)
- [Auto-Update](#auto-update)
- [Troubleshooting](#troubleshooting)
- [Credits & Acknowledgements](#credits--acknowledgements)
- [Links](#links)

---

## Overview

**Kindle Key Finder — KA Edition** is a Windows automation script that decrypts Kindle `.kfx-zip` books by intercepting the decryption keys directly from the Kindle for Android app running inside the **LDPlayer 14** Android emulator, using the **Frida** dynamic instrumentation framework.

This is a completely separate approach from the Windows Store / MSIX method. It works on current Kindle app versions, requires no Windows Store Kindle installation, and produces clean, DRM-free output files that can be imported directly into Calibre.

---

## How It Works

The script automates three phases in sequence:

```
┌─────────────────────────────────────────────────────────────┐
│  PHASE 1 — DECRYPTION & EXTRACTION                         │
│  LDPlayer + Kindle for Android + Frida -> .kfx-zip files  │
├─────────────────────────────────────────────────────────────┤
│  PHASE 2 — CALIBRE AUTO-IMPORT                             │
│  .kfx-zip files -> Calibre library (via calibredb)        │
├─────────────────────────────────────────────────────────────┤
│  PHASE 3 — KFX TO EPUB CONVERSION (optional)              │
│  Calibre KFX books -> EPUB format                         │
└─────────────────────────────────────────────────────────────┘
```

**Phase 1 in detail:**
1. Pulls the Kindle app's book data from LDPlayer via ADB
2. Launches `kindleFridaDecrypt.py` (by Satsuoni), which uses the bundled `frida-server` to attach to the Kindle process
3. The compiled Frida agent (`compiled_agent.js`) hooks into the Kindle app at runtime and intercepts the decryption keys for each book
4. Books are decrypted and saved as `.kfx-zip` files in the `Extracted_Books` folder
5. History tracking prevents re-processing books already in Calibre

---

## Requirements

### Mandatory

| Requirement | Version | Notes |
|---|---|---|
| **Windows 10/11** (64-bit) | Any | Script is Windows-only |
| **Python** (python.org) | 3.9 or newer | **NOT** Microsoft Store Python |
| **LDPlayer** | **14.0.9.2** | Bundled stub installer included in `installers\` |
| **Kindle for Android** | Any current | Installed inside LDPlayer |
| **frida** (Python package) | **17.15.3** | Must match the bundled frida-server |
| **frida-tools** (Python package) | **14.10.4** | Auto-installed on first run if missing |
| **frida-server** (bundled) | **17.15.3** | Pre-bundled in `code\tools\frida-server\` — **must match frida version** |

> **Important — version matching:** The bundled `frida-server` binary and the `frida` Python package **must be the same version**. The bundled server is `17.15.3`. The `requirements.txt` pins `frida==17.15.3` and `frida-tools==14.10.4` to ensure this. If you manually upgrade frida via pip, you must also replace the bundled `frida-server` binary with the matching version from https://github.com/frida/frida/releases.

### Optional (for Auto-Import & Conversion)

| Requirement | Notes |
|---|---|
| **Calibre** | Required for Phase 2 (auto-import) and Phase 3 (conversion) |
| **KFX Input Plugin** | Bundled in `code\Calibre-Plugins\` — enables Calibre to read `.kfx-zip` |
| **DeDRM Plugin** | Bundled in `code\Calibre-Plugins\` — handles KF8/MOBI fallback books |

> **Note:** Phase 1 (decryption) works without Calibre. Decrypted books are always saved to the `Extracted_Books` folder regardless of whether Phases 2 & 3 run.

---

## Installation & Setup

### Step 1 — Install Python (python.org)

Download and install Python from **https://www.python.org/downloads/**

During installation:
- Check **"Add Python to PATH"**
- Check **"Install for all users"** (recommended)

> Do **not** use the Microsoft Store Python — it runs in a sandboxed environment that breaks Frida and file path handling. The script detects Store Python and warns you at startup.

### Step 2 — Install LDPlayer 14

A stub installer for **LDPlayer 14.0.9.2** is included in the `installers\` folder of the release ZIP. Run it and it will download and install the full LDPlayer from the internet.

Alternatively, download LDPlayer 14 directly from **https://www.ldplayer.net**

### Step 3 — Set Up Kindle for Android in LDPlayer

1. Open LDPlayer 14
2. Open the Google Play Store inside LDPlayer
3. Search for **"Kindle"** and install the Amazon Kindle app
4. Sign in to your Amazon account
5. Download the books you want to decrypt (tap each book cover to download)

> Wait for all books to fully download before running the script.

### Step 4 — Extract the Release ZIP

Extract the release ZIP to a local folder (e.g. `C:\KindleDecrypt\`).

> **Cloud drive warning:** If the folder is inside OneDrive, Google Drive, or Dropbox, the script automatically moves its working directory to `%LocalAppData%\KA_Kindle_Key_Finder\` to avoid cloud sync conflicts. Your decrypted books are still saved to whatever `Extracted_Books` path you configure.

### Step 5 — Install Python Dependencies

The script installs `frida-tools` automatically on first run. To install manually:

```
python -m pip install frida==17.15.3 frida-tools==14.10.4
```

Or using the bundled requirements file:

```
python -m pip install -r requirements.txt
```

### Step 6 — Install Calibre Plugins (optional)

If you want auto-import into Calibre:

1. Open Calibre → **Preferences → Plugins → Load plugin from file**
2. Install `code\Calibre-Plugins\DeDRM_plugin.zip`
3. Install `code\Calibre-Plugins\KFX Input.zip`
4. Restart Calibre

> The script can also auto-install these plugins for you during the startup validation step if `calibre-customize` is available on PATH.

---

## Running the Script

Double-click **`Run_keyfinder.bat`**

The launcher:
- Requests UAC elevation (admin rights) via PowerShell
- Enables ANSI colour output in the terminal
- Launches `key_finder.py`

For a persistent desktop shortcut with automatic elevation, run:
```
Create_Elevated_Shortcut.bat
```

### First Run

On the very first run, a **GUI setup wizard** launches automatically to configure:
- Where to save decrypted books (`Extracted_Books` path)
- Calibre library path (if using auto-import)
- Whether to convert to EPUB after import
- Other preferences

You can re-open the wizard at any time by pressing **R** at the "Use current config?" prompt.

---

## The Three Phases

### Phase 1 — Decryption & Extraction

**Before running Phase 1, ensure:**
- LDPlayer is fully booted (home screen visible)
- Kindle for Android is open inside LDPlayer
- All books are fully downloaded in the Kindle app

The script will:
1. Validate all dependencies (ADB, frida-server, Kindle app detection)
2. Pull book data from LDPlayer via ADB into a `kindle-files\` staging folder
3. Run `kindleFridaDecrypt.py` to decrypt each book using Frida instrumentation
4. Save decrypted `.kfx-zip` files to your `Extracted_Books` folder
5. Skip books already recorded in `History.txt`

**Output:** Decrypted `.kfx-zip` files in your configured `Extracted_Books` folder.

### Phase 2 — Calibre Auto-Import

Imports decrypted books into your Calibre library using `calibredb add`.

- Calibre **must be closed** before Phase 2 starts (the script waits for you to close it)
- Books already in Calibre are detected and skipped automatically
- `History.txt` is updated after each successful import

**Requires:** Calibre + KFX Input Plugin

### Phase 3 — KFX to EPUB Conversion

Converts newly imported KFX books to EPUB format using Calibre's built-in converter.

- Only converts books imported during the current session
- Comic/manga books can optionally also generate a PDF
- Configurable per-session via the setup wizard

**Requires:** Phase 2 to have completed successfully

---

## Configuration Options

| Setting | Description | Default |
|---|---|---|
| **Extracted Books Path** | Where decrypted `.kfx-zip` files are saved | `<script folder>\Extracted_Books` |
| **Calibre Library Path** | Path to your Calibre `metadata.db` folder | — |
| **Calibre Import** | Enable/disable Phase 2 auto-import | Disabled |
| **Convert to EPUB** | Enable/disable Phase 3 conversion | Disabled |
| **Always Use AppData** | Force working directory to `%LocalAppData%` | Off |
| **Phase Pause Mode** | `skip` (auto-advance), `countdown`, or `stop` (keypress) | `skip` |
| **Clear Screen Between Phases** | Clear terminal between phases | Off |
| **PDF for Comics** | Generate PDF alongside EPUB for comic books | Off |

Configuration is saved to `key_finder_config.json` in the script folder.

---

## History & Skip Logic

`History.txt` records every successfully imported book by ASIN. This prevents re-processing books on subsequent runs.

| Situation | Action |
|---|---|
| New books + some already done | Silently removes already-done books from staging, processes only new ones |
| All books already in History | Prompts to skip (auto-skips in 15 seconds) or re-process all |
| No History.txt yet | Processes all books normally |

History entries:
```
B0XXXXXXXXX
B0XXXXXXXXX - KF8/MOBI
B0XXXXXXXXX - LCP
```

A `Failed_Books.txt` file tracks decryption/import failures. Successfully re-processed books are automatically removed from `Failed_Books.txt` on the next run.

---

## Auto-Update

The script checks GitHub for new releases on every startup. When a newer version is detected:

```
======================================================
  NEW VERSION AVAILABLE: KA_DRM.2026.07.10.JH
  Current version      : KA_DRM.2026.07.06.JH
======================================================
  [U] Update now  - Download & install, then restart
  [S] Skip        - Continue with current version
  [Q] Quit
```

Selecting **U** downloads the release ZIP, extracts it over the script folder, and relaunches automatically. Selecting **S** (or waiting 15 seconds) continues with the current version.

---

## Troubleshooting

### "LDPlayer/emulator process not detected"
- Ensure LDPlayer 14 is fully booted (home screen visible, not still loading)
- If this is a new install, use the bundled stub installer in `installers\` to install LDPlayer 14.0.9.2
- After installing, launch LDPlayer and wait for it to fully boot before re-running the script

### "No connected Android device found via ADB"
- ADB connects automatically once LDPlayer is fully running — no manual steps needed
- If it still fails, restart LDPlayer, wait 30 seconds, then re-run the script

### "Python package frida not found"
- The script offers to auto-install on first run — press **Y** when prompted
- To install manually: `python -m pip install -r requirements.txt`
- **Critical:** Ensure `frida==17.15.3` is installed — other versions will not work with the bundled `frida-server`

### "Microsoft Store Python detected"
- Uninstall Python from **Settings → Apps**
- Download the official installer from https://www.python.org/downloads/
- Install with **"Add Python to PATH"** and **"Install for all users"** checked

### Frida attachment fails / "Failed to spawn" error
- Make sure the Kindle app is **open and on the library/home screen** in LDPlayer
- Do not interact with LDPlayer while Phase 1 is running
- Ensure `frida==17.15.3` matches the bundled `frida-server` — check with: `python -m pip show frida`

### Calibre import fails
- Make sure Calibre is **fully closed** before running the script
- Verify the KFX Input Plugin and DeDRM Plugin are installed and enabled in Calibre → Preferences → Plugins
- Re-run the script — it will detect missing plugins and offer to install them

### Where are the log files?

All logs are in the working directory:

```
History.txt                         Successfully imported books (ASIN)
Failed_Books.txt                    Books that failed decryption/import
Logs\startup.log                    Pre-flight validation (every run)
Logs\01_Extraction\                 Frida decryptor output logs
Logs\02_Import\                     Calibre import logs
Logs\03_Conversion\                 EPUB conversion logs
Extracted_Books\                    Decrypted .kfx-zip output files
```

Working directory locations:
- **Default:** The script folder (if writable and not cloud-synced)
- **Fallback:** `%LocalAppData%\KA_Kindle_Key_Finder\` (cloud drives, or always_use_appdata=True)

---

## Credits & Acknowledgements

This project would not exist without the following tools and their creators:

| Tool | Creator | Link |
|---|---|---|
| `kindleFridaDecrypt.py` & `compiled_agent.js` | **Satsuoni** | https://github.com/Satsuoni |
| DeDRM Tools (Calibre plugin) | **Satsuoni** | https://github.com/Satsuoni/DeDRM_tools |
| Frida dynamic instrumentation framework | **oleavr** and contributors | https://frida.re |
| KFX Input Plugin (Calibre) | **jhowell** | https://www.mobileread.com/forums/showpost.php?p=3594876 |
| LDPlayer Android Emulator | LDPlayer team | https://www.ldplayer.net |

**KA Edition script, automation, and UI** by **jadehawk** — https://techy-notes.com

---

## Links

| Resource | URL |
|---|---|
| **Script homepage & tutorials** | https://techy-notes.com |
| **GitHub repository** | https://github.com/jadehawk/Kindle_Android_Key_Finder |
| **Latest release download** | https://github.com/jadehawk/Kindle_Android_Key_Finder/releases/latest |
| **YouTube video tutorial** | https://youtu.be/Av28JmkKzoY |
| **Buy me a Beer** | https://buymeacoffee.com/jadehawk |

---

## Disclaimer

This tool is intended for **personal, fair-use backup purposes only**. Only decrypt books that you have legitimately purchased. The authors do not condone piracy or any illegal use of this software. Use at your own risk and in accordance with the laws of your jurisdiction.
