Skip to content

Sherin-SEF-AI/CTF-Term

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

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

Repository files navigation

CTF Terminal 🚩

PyPI version Python 3.10+ License: MIT GitHub Stars

ctf-term - A production-ready, cross-platform terminal CTF engine with both CLI and TUI interfaces. Features local SQLite storage, importable challenge packs (YAML), salted-hash flag verification, hint penalties, and live leaderboards.

Created by: Sherin Joseph Roy β€’ Co-Founder & Head of Products at DeepMost AI

πŸ“¦ Install from PyPI

pip install ctf-term

PyPI Package: https://pypi.org/project/ctf-term/
GitHub Repository: https://github.com/Sherin-SEF-AI/CTF-Term
Documentation: See README.md

πŸ’‘ Install: pip install ctf-term β€’ PyPI: https://pypi.org/project/ctf-term/

Features

  • 🎯 Clean CLI with all essential CTF commands
  • πŸ–₯️ Beautiful TUI built with Textual for keyboard-first navigation
  • πŸ”’ Secure flag verification using SHA256 salted hashes
  • πŸ“¦ Pack System - import challenges from YAML files
  • πŸ† Advanced Leaderboard with hint penalties and first blood bonuses
  • 🩸 First Blood - 10% bonus points for being the first solver
  • πŸ’Ύ Local Storage - SQLite database with proper indexes
  • 🎨 Rich Output - beautiful terminal tables and formatting
  • πŸŒ— Themes - dark and light modes (TUI)
  • ⚑ Fast - optimized for low-end machines
  • πŸ§ͺ Tested - comprehensive test suite
  • πŸ“Š Challenge Stats - tracking solves, hints, and performance

Quick Start

Installation

Recommended - Using pipx (isolated environment):

pipx install ctf-term

Alternative - Using pip:

pip install ctf-term

From source:

git clone https://github.com/Sherin-SEF-AI/CTF-Term.git
cd CTF-Term
pip install -e .

CLI Usage

# Initialize the app
ctf init

# Import a challenge pack
ctf import-pack ~/.ctf/packs/sample.yml

# List challenges
ctf list
ctf list --category crypto

# Show challenge details
ctf show rot13-hello

# Get a hint (view-only, no penalty yet)
ctf hint alice rot13-hello

# Submit a flag
ctf submit alice rot13-hello flag{flap}

# View leaderboard
ctf scoreboard

# Generate flag hash for pack authors
ctf make-flag-hash "flag{example}" "salt"

TUI Usage

# Launch the interactive TUI
ctf tui

Keyboard Shortcuts:

  • ? / F1 - Help
  • / - Search challenges
  • c - Filter by category
  • u - Switch/create user
  • Enter - Open challenge
  • s - Submit flag
  • h - Show hint
  • g - Go to scoreboard
  • t - Toggle theme
  • Esc - Go back / Close dialogs
  • q - Quit

Pack Authoring

YAML Schema

pack: My CTF Pack
version: 1
challenges:
  - id: unique-challenge-id
    title: Challenge Title
    category: crypto  # crypto, pwn, web, forensics, misc
    description: |
      This is the challenge description.
      Can be multi-line markdown.
    points: 100
    salt: "unique-salt-per-challenge"
    flag_hash: "sha256(salt:flag)"
    hint: "Optional hint text"
    hint_penalty: 20

Creating Flag Hashes

# Method 1: Use the CLI tool
ctf make-flag-hash "flag{my_flag}" "my_salt"

# Method 2: Manual calculation
python3 -c "import hashlib; print(hashlib.sha256(b'my_salt:flag{my_flag}').hexdigest())"

Development Mode

For local testing, you can use flag_plain which will be automatically hashed:

challenges:
  - id: test-challenge
    title: Test Challenge
    category: misc
    description: "Test description"
    points: 50
    salt: "s1"
    flag_plain: "flag{test}"  # Dev only - never commit this!
    hint: "This is a hint"
    hint_penalty: 10

⚠️ Warning: Never commit packs with flag_plain to version control!

Project Structure

ctf-term/
β”œβ”€β”€ src/ctfterm/
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ cli.py              # CLI commands
β”‚   β”œβ”€β”€ db.py               # Database operations
β”‚   β”œβ”€β”€ model.py            # Data models
β”‚   β”œβ”€β”€ packs.py            # Pack import/export
β”‚   β”œβ”€β”€ security.py         # Flag verification
β”‚   β”œβ”€β”€ paths.py            # Path resolution
β”‚   β”œβ”€β”€ settings.py         # Settings management
β”‚   β”œβ”€β”€ __main__.py         # Python module entrypoint
β”‚   β”œβ”€β”€ tui/                # TUI implementation
β”‚   β”‚   β”œβ”€β”€ app.py
β”‚   β”‚   β”œβ”€β”€ router.py
β”‚   β”‚   β”œβ”€β”€ styles.tcss
β”‚   β”‚   β”œβ”€β”€ views/
β”‚   β”‚   └── widgets/
β”‚   └── services/           # Business logic
β”‚       β”œβ”€β”€ challenges.py
β”‚       β”œβ”€β”€ users.py
β”‚       β”œβ”€β”€ scoreboard.py
β”‚       └── flags.py
β”œβ”€β”€ tests/                  # Test suite
β”œβ”€β”€ examples/               # Sample packs
└── pyproject.toml

Security

  • Flags are never stored in plaintext
  • Verification uses SHA256(salt:flag) only
  • Database stores salt and flag_hash
  • No network calls - completely offline
  • No dynamic code execution

Development

Setup

git clone <repo>
cd ctf-term
python -m venv venv
source venv/bin/activate  # Windows: venv\Scripts\activate
pip install -e ".[dev]"

Running Tests

pytest
pytest --cov=src/ctfterm --cov-report=html

Code Formatting

ruff check src/ tests/
black src/ tests/

Author & Credits

Sherin Joseph Roy

Co-Founder & Head of Products at DeepMost AI

Sherin is an AI entrepreneur and product leader specializing in enterprise AI systems that connect data, automation, and intelligence. With expertise in scalable, human-centered AI solutions, he focuses on bridging research and application to solve real-world challenges.

Connect & Learn More

About DeepMost AI

DeepMost AI builds enterprise AI systems that help organizations think, decide, and grow through intelligent automation and data-driven solutions.

License

MIT License - see LICENSE file

Contributing

Contributions welcome! Please:

  1. Fork the repository
  2. Create a feature branch
  3. Add tests for new features
  4. Ensure all tests pass
  5. Submit a pull request

Acknowledgments

Built with:

Available on PyPI: https://pypi.org/project/ctf-term/

About

cross-platform terminal CTF engine with both CLI and TUI interfaces. Features local SQLite storage, importable challenge packs (YAML), salted-hash flag verification, hint penalties, and live leaderboards.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors