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.2.tar.gz (10.6 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.2-py3-none-any.whl (9.4 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for flagcapt-0.2.tar.gz
Algorithm Hash digest
SHA256 5fdbd7cd6ade98efca5cd466402ed116f9fbe59a3302a649774646e7be4953f5
MD5 b0387f22a9a942ae66e815383e5ea361
BLAKE2b-256 82a4cea8010ad1880c5506d90f9983a151ce8fb5f992d9bf0733c59c4c1d1fab

See more details on using hashes here.

File details

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

File metadata

  • Download URL: flagcapt-0.2-py3-none-any.whl
  • Upload date:
  • Size: 9.4 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a82fe913a20636e0bb3fd9c0fc08326a9855a91412c451065970b948f2bf47eb
MD5 828a345396a8e0ac5d8805f918dcad91
BLAKE2b-256 556c359287862216e1c3fa64873e532933fb5115339fd75e5709815f61711a00

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