Code Monkey home page Code Monkey logo

ctf-manager's Introduction

CTF Manager

This bot is built to make it easier to manage a large CTF team on discord, it'll be able to remind you of CTFs and manage your team's participation.

drawing

Functionalities

Adding a new CTF

You can add CTFs that your team will be playing

This will create a channel under the category "CTF" with the title of the CTF in CTFtime and will send generated credentials for that CTF and pin it in the channel

Warning - THE CHANNEL WILL ONLY BE AVAILBLE TO ADMINS AT FIRST CREATION

This is intentional to keep track of who played a CTF with your team

The following image is from the view of a normal member / user before accepting their join request


Listing upcoming CTFs

This functionality will list CTFs that your team will participate in the future

Removing and Archiving CTFs

  • Archiving

  • Unarchiving

You can remove CTFs by id or in bulk with *

Warning - DO NOT archive or remove channel by yourself (by dragging to archived ctfs category or deleting by hand), this will cause issues with the db and you'll have to clean the deleted event row by hand in the database.db file

- Removing ctfs before archiving will delete the channels


Join request

Normal users can request to join a CTF by using the join command and admins can Accept or Deny these requests

Admins will be able to accept or deny join requests

Once an admin accepts a join request the user will be able to send message and check generated credentials for the CTF

Admins can also list all requests and check their status


Bot Reminder settings

Any user can choose if they want to be reminded of the starting CTF

The reminder will be able to remind users when the events starts as well as:

  • 8 hours before start
  • 4 hours before start
  • 1 hours before start
  • 30 minutes before start

Here an example of the reminder

Warning - PLEASE DO NOT ADD THE ROLE BY YOURSELF THAT'LL CREATE ISSUES WITH THE DB


Commands

Note - * as an argument is for bulk requests (Example: $ctf remove * => removes all events)

User commands

$ctf list # list all events added
$join <event_id>  # send a join request for an event
$reminder <on/off> # activate or desactive reminder for you
$ctf creds # get ctf creds of an event ( only works inside the CTF channel )
$cat # get a random cat image with a random word

Admin commands

$ctf add <ctftime_event_url> # add an event
$ctf remove <ctftime_event_id> # remove an event
$ctf remove * # remove all events
$ctf archive <ctftime_event_id> # archive an event
$ctf archive * # archive all events
$ctf unarchive <ctftime_event_id> # unarchive an event
$ctf unarchive * # unarchive all events
$join list # list all join requests
$join list <event_id> # list join request of a certain event
$join accept <username/user#id> <event_id> # accept join request
$join deny <username/user#id> <event_id> # deny join request

Configurations

1- Create a bot admin role such as "ctf-manager-admin"

2- Give the bot the admin role "ctf-manager-admin"

3- Create a public bot channel and give the admin permissions to send messages

4- Create a private channel exclusive for the bot admin role

(You can give the admin role to users who you want to add as admins)

5- Create a reminder channel visible to all members but only the admin role can send messages

6- Modify config.py

# bot constants
token = "token_here" # discord token
prefix = "$"  # put prefix here
link = "https://discord.com/api/oauth2/authorize?client_id=<your_client_id>&permissions=275146599504&scope=bot"  # put bot invite link here

# admin stuff
ownerid = "your_discord_id"  # put your id here
admin_role = "ctf-manager-admin"
admin_channel_id = "admin_channel_id"

# remind settings
reminder_role = "remind-me"
reminder_role_id = "reminder_role_id"
remind_me_channel_id ="reminder_channel_id"

# team
teamname="/bin/cat" # this will be used for generated credentials
member_role="member"  

To get the role id of a role you need to go to server roles

To get the channel id of a channel you need to right click and "Copy channel id"

6- Invite the bot with the permission id 275146599504

https://discord.com/api/oauth2/authorize?client_id=[YOUR CLIENT ID]&permissions=275146599504&scope=bot

Local setup:

1- Install dependencies

$ pip3 install -r requirements.txt

2- Run app.py

$ python3 app.py

Deployment via docker

sudo docker build . -t ctf-manager && sudo docker run --name ctf-manager --rm -it -d ctf-manager

Files ๐Ÿ“

  • app.py : run bot
  • db.py : SQLite database queries and setup
  • checks.py : includes check functions for some commands
  • utils.py : interactions with APIs / parsing / extra functions
  • config.py : bot constants configuration

Future fixes / additions ๐Ÿ› ๏ธ

  • Add seconds to time count
  • Better time parsing
  • Build the $ultimate command
  • Better styling response
  • Add * argument for join command to accept in bulk
  • Add option to auto archive ctfs (remove from db and archive channel) if ctf ended
  • Add remove from db when archiving
  • Add reminder settings per user ( each user choose when to be alerted )
  • Add Logger and save logs

Similar projects / Alternatives:

This bot is intentionally made simplistic with a few commands, I wanted to share it incase anyone was looking for a minimal bot that'll help manage their team.

Alternative discord bots:

https://github.com/NullPxl/NullCTF

https://github.com/sigpwny/pwnybot

Bugs ๐Ÿž

You can use github to submit a PR for suggestions or bugs, otherwise you can contact me via discord with the username j3seer or twitter @j3seer

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.