Skip to main content

A tool for solving cryptographic challenges in CTFs

Project description

๐Ÿ›ก๏ธ 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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

flagcapt-0.3.tar.gz (10.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

flagcapt-0.3-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

Details for the file flagcapt-0.3.tar.gz.

File metadata

  • Download URL: flagcapt-0.3.tar.gz
  • Upload date:
  • Size: 10.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for flagcapt-0.3.tar.gz
Algorithm Hash digest
SHA256 29a4a631dc78bbbdca8e7f73e091f146de19467821312c1e7c86306c61c678a0
MD5 8bcc8a6dd0255746adcc1d50fbca7158
BLAKE2b-256 af8540c0f37174d49582e17a67dff380c2c95f43789c5872cb5c19721645f04a

See more details on using hashes here.

File details

Details for the file flagcapt-0.3-py3-none-any.whl.

File metadata

  • Download URL: flagcapt-0.3-py3-none-any.whl
  • Upload date:
  • Size: 9.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for flagcapt-0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 43bde405b6b9885cdb3a1e40fd0d6ff49de61484d84d7996a5739298b16d3a66
MD5 36eed7e5e3ef2fb6ab4aded47a6551e1
BLAKE2b-256 848d246a7dd5acc20040301f6142131df67bea67b79d432eb6ad422a265e69ed

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page