Reports - Sharing within a team is no longer reported: owner and submitter are compared by account (the team in teams mode), not by user. - Admins (e.g. testing in preview mode) are never reported. - A personal flag without a valid owner no longer crashes the submission (int() of its data raised a 500); empty flags never match. - One report per cheater, challenge and flag (unique constraint plus a check before inserting): "all" logic re-checks every earlier submission on each attempt, which created duplicates. Migration 5b1e0c7d9a24 drops existing duplicates and adds the constraint. - Every new report is logged. Matching uses hmac.compare_digest. Flags and helpers - The admin flag forms sent the owner as "user id", which CTFd's flag API ignores: personal flags created by admins had no owner. They now send "data", with labels bound to their inputs. - create_flag_if_missing only considers personal flags, deterministically. Plugin - Migrations run under the plugin's real directory (was "cheaters"); asset paths follow the directory instead of hardcoding it. - Model renamed CheatReport (owner instead of helper); table and column names unchanged. Dates stored in UTC. - Admin page: newest first, paginated, related rows loaded with the page, real report ids, url_for links, team columns in teams mode, local-time dates, and a Dismiss action. - README (install as ctfd_cheaters, "any" logic, API for other plugins); pyrightconfig without an absolute path. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
51 lines
1.6 KiB
Markdown
51 lines
1.6 KiB
Markdown
# ctfd-cheaters
|
|
|
|
A CTFd plugin that detects flag sharing through **personal flags**: flags
|
|
generated for one user (for example by [ctfd-whale](https://github.com/frankli0324/ctfd-whale)
|
|
for each user's instance).
|
|
|
|
- Adds the `personal` flag type. Its data is the id of the user the flag
|
|
belongs to.
|
|
- Any user's personal flag is accepted, so a shared flag still solves the
|
|
challenge. When an account submits a personal flag that belongs to
|
|
another account, the cheat is recorded once and logged.
|
|
- In teams mode, sharing a flag within a team is not reported. Admins
|
|
(e.g. testing challenges in preview mode) are never reported.
|
|
- **Cheaters** in the admin menu lists the reports, with their challenge,
|
|
users, teams, flag and date; reports can be dismissed.
|
|
|
|
## Requirements
|
|
|
|
- CTFd 3.8.9 (the version this plugin targets).
|
|
- Challenges with personal flags must use the **any** flag logic: "all"
|
|
would require every user's flag.
|
|
|
|
## Installation
|
|
|
|
Install it as `CTFd/plugins/ctfd_cheaters` (with an underscore): other
|
|
plugins import it as `CTFd.plugins.ctfd_cheaters`, and its assets are
|
|
served from that directory.
|
|
|
|
```bash
|
|
git clone <this repository> CTFd/CTFd/plugins/ctfd_cheaters
|
|
```
|
|
|
|
## For other plugins
|
|
|
|
```python
|
|
from CTFd.plugins.ctfd_cheaters import create_flag_if_missing
|
|
|
|
flag_id = create_flag_if_missing(challenge_id=..., user_id=..., flag_content="flag{...}")
|
|
```
|
|
|
|
returns the id of the user's personal flag for the challenge, creating it
|
|
with `flag_content` if the user has none yet.
|
|
|
|
## Development
|
|
|
|
```bash
|
|
make venv # uv, Python 3.11 like CTFd's Docker image; CTFD_PATH=../CTFd
|
|
make lint
|
|
make test # runs inside CTFd's own test app
|
|
```
|