Skip to content

Ewin7/htb2epub

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HTB to EPUB Converter

A Python script that downloads Hack The Box (HTB) Academy modules and converts them into formatted EPUB books for offline reading.

Features

  • Extracts all sections and markdown content from a given HTB Academy module.
  • Automatically downloads and embeds images within the EPUB.
  • Preserves formatting, tables, and code blocks.
  • Generates a clean Table of Contents (ToC) for easy navigation.

Disclaimer

Important:
This tool is intended for personal, offline study use only.
You must have an active Hack The Box Academy account with access to the modules.
Do not share or distribute generated EPUB files, as HTB content is copyrighted.

Prerequisites

  • Python 3.8+
  • An active HTB Academy account

Installation

  1. Clone this repository:

    git clone https://github.com/Ewin7/htb2epub.git
    cd htb2epub
  2. Install the required dependencies:

    pip install -r requirements.txt
  3. Set up your environment variables:

    • Rename the provided env.template file to .env:
      mv env.template .env
    • Log in to HTB Academy in your browser, open the Developer Tools (F12), go to the "Storage" tab, and copy your cookie values (htb_academy_session & XSRF-TOKEN).
    • Paste into the .env file as SESSION and XSRF. Cookie Example

Warning

Never share your cookies or .env file. These grant access to your account.

Usage

Run the script by providing a module ID. You can find the Module ID in the URL of the HTB Academy module (e.g., https://academy.hackthebox.com/app/module/12345 -> the ID is 12345).

python main.py -i <MODULE_ID>

Example:

python main.py -i 12345

The script will fetch the module content, download the required images, and generate an EPUB file named <Module_Title>.epub in the current directory.

Dependencies

This project uses the following main libraries:

  • requests - For API interaction and downloading images
  • beautifulsoup4 - For HTML parsing and image tag manipulation
  • markdown - To convert HTB's markdown structure to HTML
  • ebooklib - For generating the EPUB file structure

License

MIT License

About

Export Hack The Box Academy modules to EPUB for offline reading.

Topics

Resources

License

Stars

2 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages