Skip to main content

🛡️ Fl4gC4pt - CTF Crypto Solver & Decoder Tool

            ███████╗██╗      █████╗   ██████╗         ██████╗  █████    ██████╗ ████████╗
            ██╔════╝██║     ██╔══██╗ ██╔════╝        ██╔════╝ ██╔══██╗  ██╔══██╗╚══██╔══╝
            █████╗  ██║     ███████║ ██║  ███╗       ██║      ███████║  ██████╔╝   ██║
            ██╔══╝  ██║     ██╔══██║ ██║   ██║       ██║      ██╔══██║  ██╔═══╝    ██║   
            ██║     ███████╗██║  ██║ ╚██████╔╝       ╚██████╗ ██║  ██╔  ██║        ██║  
            ╚═╝     ══════╝╚═╝  ╚═╝   ╚═════╝         ╚═════╝  ═╝  ╚═╝  ╚═╝        ╚═╝     
            ・┆✦ʚ♡ɞ✦ ┆・ Fl4gC4pt by 1DH4M ・┆✦ʚ♡ɞ✦ ┆・

Fl4gC4pt is a powerful command-line tool written in Python to help you decrypt, decode, and solve various cryptographic challenges often encountered in Capture The Flag (CTF) competitions.


Features

  • RSA decryption (manual or automatic factorization via FactorDB)
  • AES decryption (CBC/ECB modes)
  • XOR bruteforce and known key decryption
  • Classical Ciphers: Caesar, ROT13, Vigenère
  • Base64 decoding
  • Binary, Hex, ASCII conversions
  • Reverse strings
  • Wiener Attack & Low Exponent RSA Attack

Installation from GitHub Repository

Clone the repository:

git clone https://github.com/El-Mehdi-Dridi/Flag-Capt.git

Navigate to the flagcapt directory:

cd FlagCapt

Install the required Python packages:

pip install -r requirements.txt

⚠️ Python 3.6+ is required.


Usage

Run the tool via CLI:

flagcapt <method> -[options]
flagcapt --help                         

            ███████╗██╗      █████╗   ██████╗         ██████╗  █████    ██████╗ ████████╗
            ██╔════╝██║     ██╔══██╗ ██╔════╝        ██╔════╝ ██╔══██╗  ██╔══██╗╚══██╔══╝
            █████╗  ██║     ███████║ ██║  ███╗       ██║      ███████║  ██████╔╝   ██║
            ██╔══╝  ██║     ██╔══██║ ██║   ██║       ██║      ██╔══██║  ██╔═══╝    ██║   
            ██║     ███████╗██║  ██║ ╚██████╔╝       ╚██████╗ ██║  ██╔  ██║        ██║  
            ╚═╝     ══════╝╚═╝  ╚═╝   ╚═════╝         ╚═════╝  ═╝  ╚═╝  ╚═╝        ╚═╝     
            ・┆✦ʚ♡ɞ✦ ┆・ Fl4gC4pt by 1DH4M ・┆✦ʚ♡ɞ✦ ┆・

[*] Just Wait H4CK3R ☆.𓋼𓍊 𓆏 𓍊𓋼𓍊.☆ : 100%|██████████████████████████████████ 100%
usage: flagcapt.py [-h] [-n NUMBER] [-e EXPONENT] [-c CIPHER] [-f FILE] [-p PRIME1] [-q PRIME2] [-s SHIFT] [-k KEY] [-i IV] [-m MODE] [--low-exponent-attack] [--wiener-attack] [--bruteforce] [--prefix PREFIX] method

positional arguments:
  method                Decryption method to use. Supported methods:
                          - rsa: RSA decryption
                          - factor: Factorize a number
                          - xor: XOR decryption
                          - cesar: Caesar cipher decryption
                          - rot13: ROT13 cipher decryption
                          - aes: AES decryption
                          - base64: Base64 decoding
                          - binary: Binary to string conversion
                          - hex: Hexadecimal to string conversion
                          - ascii: ASCII to string conversion
                          - vigenere: Vigenere cipher decryption
                          - reverse: Reverse string decryption

options:
  -h, --help            show this help message and exit
  -n, --number NUMBER   Modulus (n) for RSA decryption or factorization
  -e, --exponent EXPONENT
                        Exponent for RSA decryption
  -c, --cipher CIPHER   Cipher text to decrypt
  -f, --file FILE       File containing the cipher text or RSA parameters
  -p, --prime1 PRIME1   First prime for RSA decryption
  -q, --prime2 PRIME2   Second prime for RSA decryption
  -s, --shift SHIFT     Shift value for Caesar cipher
  -k, --key KEY         Key for AES or XOR decryption
  -i, --iv IV           Initialization vector for AES decryption
  -m, --mode MODE       Mode for AES decryption (e.g., CBC, ECB)
  --low-exponent-attack
                        Perform low exponent attack on RSA
  --wiener-attack       Perform Wiener's Attack on RSA
  --bruteforce          Perform XOR brute force decryption
  --prefix PREFIX       Known prefix of the flag for XOR decryption

Common Arguments

Option Description
-c, --cipher Cipher text or encoded input
-k, --key Key for AES, XOR, or Vigenère
-s, --shift Shift for Caesar cipher
-n, --number RSA modulus n
-e, --exponent RSA exponent e
-p, --prime1 Prime p (for RSA)
-q, --prime2 Prime q (for RSA)
-i, --iv Initialization vector for AES
-f, --file Read cipher text from file
--low-exponent-attack Low exponent RSA attack (e = 3)
--wiener-attack Wiener attack on RSA

Available Methods

Method Description
rsa Decrypt RSA using p, q, e, and cipher
factor Get p & q from n via FactorDB
xor XOR decryption (with key or bruteforce)
cesar Caesar cipher decryption
rot13 ROT13 decoder
aes AES CBC/ECB decryption
base64 Decode base64 strings
binary Binary to string
hex Hex to string
ascii ASCII values to string
vigenere Vigenère decryption
reverse Reverse the string

📌 Examples

RSA Decryption

Typical RSA

flagcapt rsa -e 65537 -c 15752613524540611205355101441647970957140019284625297899850 -n 37400945029259002357443060764390969896841289525047883637759
[*] Just Wait H4CK3R ☆.𓋼𓍊 𓆏 𓍊𓋼𓍊.☆ : 100%|██████████████████████████████████ 100%
[CALCULING P] 82350732498477128986705241687
[CALCULING q] 454166513090222231786915976857
[*] Flag Found [*]: Flag{Fl4g_C4pT_by_1DH4M} [*]

Wiener Attack

flagcapt rsa -n < modulus > -e <exponent> -c <cipher> --wiener-attack

Low Exponent Attack

flagcapt rsa -f rsa.txt --low-exponent-attack                                             

XOR Decryption

With known key

flagcapt xor -c "ciphertext_here" -k "key"

With known perfix

flagcapt xor -f flag.txt --prefix "prefix"

BruteForce

flagcapt  xor -f flag.txt --bruteforce 

AES Decryption

CBC mode

flagcapt  aes -c "cipher" -k "key" -i "iv" --mode CBC

ECB mode

flagcapt  aes -c "cipher" -k "key" -i "iv" --mode CBC

👨‍💻 Author

Created by 1DH4M on 04/2025

Metadata

Release files for flagcapt 0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for flagcapt 0.3
File Size Uploaded
flagcapt-0.3.tar.gz 10.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for flagcapt 0.3
File Interpreter ABI Platform
flagcapt-0.3-py3-none-any.whl Python 3 none any Details

Total release size: 20.3 kB

Release files / flagcapt-0.3.tar.gz

Download URL flagcapt-0.3.tar.gz
Size 10.8 kB
Tags Source
SHA-256 checksum
How to use checksums
29a4a631dc78bbbdca8e7f73e091f146de19467821312c1e7c86306c61c678a0
BLAKE2b-256 checksum
How to use checksums
af8540c0f37174d49582e17a67dff380c2c95f43789c5872cb5c19721645f04a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.2

Release files / flagcapt-0.3-py3-none-any.whl

Download URL flagcapt-0.3-py3-none-any.whl
Size 9.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
43bde405b6b9885cdb3a1e40fd0d6ff49de61484d84d7996a5739298b16d3a66
BLAKE2b-256 checksum
How to use checksums
848d246a7dd5acc20040301f6142131df67bea67b79d432eb6ad422a265e69ed
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.2

Release history Release notifications | RSS feed

This release

0.3 This release

2 release files

0.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page