Skip to content

Latest commit

 

History

History
138 lines (98 loc) · 3.38 KB

README.md

File metadata and controls

138 lines (98 loc) · 3.38 KB

CTFd-CLI

A Command Line Utility to perform actions with a CTFd Instance using the CTFd REST API.


In order to interact with the CTFd API, you need to have an API key and the IP/Hostname of the CTFd instance. These can be configured inside the .env file. For starters, you can copy the .env.example file and rename it to .env and fill in the values.

Usage

usage: ctfd-cli.py [-h] [--ctfd-instance CTFD_INSTANCE] [--ctfd-token CTFD_TOKEN] {user,team} ...

CTFd CLI

positional arguments:
  {user,team}
    user                User mode
    team                Team mode

options:
  -h, --help            show this help message and exit
  --ctfd-instance CTFD_INSTANCE
                        CTFd instance URL
  --ctfd-token CTFD_TOKEN
                        CTFd admin token

User mode

usage: ctfd-cli.py user [-h] {create,delete,update,get,list}

positional arguments:
  {create,delete,update,get,list}
    create              Create user
    delete              Delete user
    update              Update user
    get                 Get user
    list                List users

options:
  -h, --help            show this help message and exit
  • Create user:
usage: ctfd-cli.py user create [-h] --name NAME --password PASSWORD [--email EMAIL] [--team-id TEAM_ID] [--role ROLE]
                               [--verified VERIFIED] [--banned BANNED] [--hidden HIDDEN]

options:
  -h, --help           show this help message and exit
  --name NAME          Username [required]
  --password PASSWORD  Password [required]
  --email EMAIL        Email
  --team-id TEAM_ID    Team ID
  --role ROLE          Role
  --verified VERIFIED  Verified
  --banned BANNED      Banned
  --hidden HIDDEN      Hidden
  • Delete user:
usage: ctfd-cli.py user delete [-h] --user-id USER_ID

options:
  -h, --help         show this help message and exit
  --user-id USER_ID  User ID
  • Update user:
usage: ctfd-cli.py user update [-h] --user-id USER_ID [--attributes ATTRIBUTES] [--attributes-json ATTRIBUTES_JSON]

options:
  -h, --help            show this help message and exit
  --user-id USER_ID     User ID
  --attributes ATTRIBUTES
                        Attributes (passed as a json object)
  --attributes-json ATTRIBUTES_JSON
                        Attributes json file

The update attributes can be plain json object passed from the command-line as follows:

python3 ctfdcli.py user update --attributes '{"banned": true, "hidden": false}'

Or you can pass a json file containing the attributes:

{
    "banned": true,
    "hidden": false
}
python3 ctfdcli.py user update --attributes-json attributes.json
  • Get user:
usage: ctfd-cli.py user get [-h] --user-id USER_ID
  • List users:

Get a list of all users (Only those that have 'hidden=false' and 'banned=false')

usage: ctfd-cli.py user list

Team mode

I haven't written the documentation for this but it is complete.


Bulk Add

For bulk add, you need to run parse first, and then just validate. Then running bulk add will automatically add the users and teams to CTFd.

By design, I've allowed only 3 users per team. You can modify it in bulker.py:12


NOTE:

If someone can help me in writing a full documentation, please make a pull request, I'll review and merge, really busy these days to write a full documentation.