Scrapes the eCTF scoreboard for rank changes.
Create a file called auth.ts
that exports your Discord token, Slack bot info, express / bolt.js server ports, and channel / message IDs:
// auth.ts
export const DISCORD_TOKEN = 'very-real-discord-token';
export const SCOREBOARD_NOTIFY_CHANNEL_ID = '...';
export const STATUS_CHANNEL_ID = '...';
export const STATUS_MESSAGE_ID = '...';
export const FAILURE_CHANNEL_ID = '...';
export const SLACK_TOKEN = 'xoxp-very-real-slack-token';
export const SLACK_SIGNING_SECRET = '...';
export const ATTACK_CHANNEL_ID = 'C06D0SZDF5K';
export const ATTACK_NOTIFY_CHANNEL_ID = '...';
export const TARGETS_REPO_URL = 'https://username:[email protected]/Purdue-eCTF-2024/2024-Targets';
export const EXPRESS_PORT = 8080;
export const BOLT_PORT = 8081;
-
DISCORD_TOKEN
— the discord bot auth token. -
SCOREBOARD_NOTIFY_CHANNEL_ID
— the discord channel to send scoreboard reports in. -
STATUS_CHANNEL_ID
— the discord channel to send build status updates in. -
STATUS_MESSAGE_ID
— the message to update when the status of a build changes. The ID of this message can't really be obtained until a build status message is sent in the first place; leave this field blank at first, then force-send a status message and update the ID accordingly. -
FAILURE_CHANNEL_ID
— the discord channel to send "build failed" notifications in. -
SLACK_TOKEN
— the Slack auth token. -
SLACK_SIGNING_SECRET
— the Slack signing secret. -
ATTACK_CHANNEL_ID
— the Slack channel to listen for target drops in. -
ATTACK_NOTIFY_CHANNEL_ID
— the Discord channel to send "new target dropped" notifications in. -
TARGETS_REPO_URL
— the GitHub URL to the targets repository to push new targets to. If this is a private repository, make sure to include credentials with push access. -
EXPRESS_PORT
— the port to run the build-integration express server on. -
BOLT_PORT
— the port to run the Slack bot on.
See the Slack autodownload section for more on how to configure the required Slack secrets.
Then, install dependencies with npm install
and run npm start
to start the bot.
To run with docker,
docker-compose up -d --build
/modules/slack.ts
To set up the Slack integration, create a new Slack app in the Slack API portal.
After creating, you can copy your Slack token and signing secret into auth.ts
.
Then, add OAuth scopes in OAuth & Permissions
; you'll likely need, at minimum, channels:history
, chat:write
, and files:read
.
Finally, enable event subscriptions in Event Subscriptions
and set the request URL to your bolt-js
server URL i.e.
http://ctf.b01lers.com:8081/slack/events
Note that your server should be running at this point to respond to Slack's challenge
request.
/modules/scoreboard.ts
This bot periodically scrapes the eCTF scoreboard for updates, sending a report of changes each day. Alternatively, run
/report
to get a report of the day so far.
/modules/status.ts
This bot also integrates with the nix-shell
build server for automated
build status alerting during the dev phase.
Make sure the build server is configured to send POST requests to this bot's exposed express endpoint properly.
/modules/flags.ts
In case a Tufts situation occurs again, this bot contains a generator for a userscript to automatically scrape the flag submission page and submit a flag as soon as possible.