Skip to content

A command-line tool for solving common cryptography challenges in CTFs.

License

Notifications You must be signed in to change notification settings

satellacodes/CTF-Crypto-Toolkit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

9 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

CTFlogos

πŸ” CTF Crypto Toolkit v2.0

Python Cryptography Version License

Advanced Swiss Army knife for solving cryptography challenges in CTFs and cybersecurity competitions

✨ New Features in v2.0

  • Auto-detection of encodings and ciphers
  • Intelligent scoring for English text detection
  • Extended cipher support (AES, DES, Vigenere with auto-key detection)
  • Enhanced RSA toolkit with automatic factoring
  • Hash cracking with wordlist support
  • Multiple encoding formats (URL, HTML, Binary, Morse)
  • Improved error handling and user feedback
  • Better performance with optimized algorithms

πŸ“¦ Installation

Quick Install

# Clone the repository
git clone https://github.com/satellacodes/CTF-Crypto-Toolkit.git
cd CTF-Crypto-Toolkit

# Install dependencies
pip3 install pycryptodome

# Make executable
chmod +x ctf_crypto_tool.py

Docker Support

# Build Docker image
docker build -t ctf-crypto-toolkit .

# Run in Docker
docker run -it ctf-crypto-toolkit caesar --auto --input "Khoor"

πŸš€ Quick Examples

Auto-detect Caesar Cipher

./ctf_crypto_tool.py caesar --auto --input "Khoor Zruog"
# Output: Best matches sorted by English probability

Crack XOR Encryption

./ctf_crypto_tool.py xor --auto --input "1a2b3c4d5e"
# Automatically finds the most likely XOR key

RSA Decryption with Auto-factoring

./ctf_crypto_tool.py rsa --n 3233 --e 17 --c 855 --auto-factor
# Attempts to factor n and decrypt automatically

Hash Cracking with Wordlist

./ctf_crypto_tool.py hash --alg md5 --crack --input "5d41402abc4b2a76b9719d911017c592" --wordlist rockyou.txt

Detect Encoding Type

./ctf_crypto_tool.py detect --input "SGVsbG8gd29ybGQ="
# Output: Detected encoding: base64

πŸ“‹ Complete Feature List

Encoding/Decoding

  • Base Family: Base64 (standard & URL-safe), Base32, Base16, Base85, ASCII85
  • Binary Encoding: Text ↔ Binary conversion
  • URL Encoding: Percent-encoding/decoding
  • HTML Entities: HTML special characters
  • Morse Code: International Morse code

Classical Ciphers

  • Caesar Cipher: With bruteforce and auto-detection
  • ROT Family: ROT-n transformations
  • VigenΓ¨re Cipher: With Kasiski examination for key detection
  • Affine Cipher: Automatic parameter solving
  • Substitution Cipher: Frequency analysis

Modern Cryptography

  • XOR Operations: Single-byte and multi-byte XOR
  • AES: ECB, CBC, CTR modes
  • DES: ECB, CBC modes
  • RSA Toolkit: Complete parameter handling

Hash Operations

  • Hash Generation: MD5, SHA1, SHA256, SHA512, SHA3, BLAKE2
  • Hash Cracking: Dictionary attacks with wordlists
  • Rainbow Tables: Built-in common hash lookup

Analysis Tools

  • Frequency Analysis: Character and bigram analysis
  • Entropy Calculation: Measure randomness
  • Pattern Detection: Identify cipher types
  • Encoding Detection: Auto-detect encoding formats

πŸ”§ Advanced Usage

Chain Operations

# Multiple operations in sequence
echo "Hello" | ./ctf_crypto_tool.py base --type b64 | ./ctf_crypto_tool.py caesar --shift 3

File Input Support

# Process files directly
./ctf_crypto_tool.py xor --bruteforce --input file:encrypted.bin

Output Formatting

# JSON output for programmatic use
./ctf_crypto_tool.py caesar --auto --input "Khoor" --json

🎯 CTF Challenge Examples

Challenge 1: "The Secret Message"

# Encoded message: V2VsY29tZSB0byBDVEY=
./ctf_crypto_tool.py detect --input "V2VsY29tZSB0byBDVEY="
./ctf_crypto_tool.py base --decode --type b64 --input "V2VsY29tZSB0byBDVEY="

Challenge 2: "XOR Mystery"

# Hex data: 1e3b2a4c5d6e
./ctf_crypto_tool.py xor --auto --input "1e3b2a4c5d6e"

Challenge 3: "RSA Challenge"

# Given: n=3233, e=17, c=855
./ctf_crypto_tool.py rsa --n 3233 --e 17 --c 855 --auto-factor

πŸ“Š Performance Features

  • Multi-threading for brute force operations
  • Caching of common computations
  • Progress indicators for long operations
  • Memory-efficient large file handling
  • Batch processing support

πŸ› οΈ Developer API

The toolkit can also be used as a Python library:

from ctf_crypto_tool import solve_caesar, solve_xor, english_score

# Use functions directly
results = solve_caesar("Khoor", auto=True)
best_result = max(results, key=lambda x: x[2])
print(f"Best match: Shift {best_result[0]}, Text: {best_result[1]}")

πŸ“ Project Structure

CTF-Crypto-Toolkit/
β”œβ”€β”€ ctf_crypto_tool.py          # Main tool
β”œβ”€β”€ README.md                   # Updated documentation
β”œβ”€β”€ CONTRIBUTING.md            # Contribution guidelines
β”œβ”€β”€ requirements.txt           # Dependencies
β”œβ”€β”€ setup.py                   # Installation script
β”œβ”€β”€ .gitignore                 # Git ignore file
β”œβ”€β”€ LICENSE                    # MIT License
β”œβ”€β”€ examples/                  # Challenge examples
β”‚   β”œβ”€β”€ caesar_challenge.txt
β”‚   β”œβ”€β”€ rsa_challenge.txt
β”‚   └── xor_challenge.txt
β”œβ”€β”€ wordlists/                 # Dictionary files
β”‚   β”œβ”€β”€ common_passwords.txt
β”‚   └── rockyou_sample.txt
└── tests/                     # Unit tests
    β”œβ”€β”€ test_caesar.py
    β”œβ”€β”€ test_xor.py
    └── test_integration.py

🀝 Contributing

See CONTRIBUTING.md for guidelines on contributing to this project.

⚠️ Security Disclaimer

This tool is for:

  • CTF competitions and challenges
  • Educational purposes
  • Security research with proper authorization

Not for:

  • Unauthorized access to systems
  • Illegal activities
  • Production cryptography

All cryptographic implementations are for educational purposes only. Use industry-standard libraries for production systems.

πŸ“„ License

MIT License - See LICENSE for details.

🌟 Star History

Star History Chart


πŸ”— Useful Resources

πŸ‘¨β€πŸ’» Author

Dimas Aris Pangestu - Cybersecurity researcher and CTF enthusiast

Tryhackme GitHub


Happy Hacking! May your flags be captured and your ciphers broken! πŸš©πŸ”“

If this tool helped you solve a challenge, consider giving it a star! ⭐