As part of the recent BSides Vancouver CTF, we were using ZeroTier as our VPN provider to enable access to the challenges.
We created a private
ZeroTier network and were manually authorizing player machines that were joining the CTF.
Discord ZeroTier Bot automates ZeroTier node authorization and allows users of your Discord server request their node authorization, and will also reference ZeroTier node to the Discord user that requested the authorization.
Create the .env
file to use as config:
cp template.env .env
- You need a Discord user account, and admin access to t he Discord server where you want to use the Bot.
- Head to Discord Developer Portal, login, and create a new app. I'd suggest you name it
ZeroTier Bot
(this will be the username for your Bot in Discord). - Create a Bot for your application by clicking Bot in the application settings, then select
Add Bot
. - Copy the Bot token and save it in the
.env
asDISCORD_TOKEN
- In the application settings, select
OAuth2
, then selectbot
underScopes
. - Under
Bot Permissions
selectSend Messages
andUse Slash Commands
. - Open the displayed URL and authorize the Bot in your Discord server.
- Login to ZeroTier.
- Go to your
Account
settings and create a new API token. - Save the token in the
.env
file asZT_TOKEN
. - Save the network ID in the
.env
asZT_NETWORK
(create a new network if you haven't yet).
Build the Docker image:
docker build -t discord-zerotier-bot .
Start the Bot:
docker run --rm -it --env-file .env discord-zerotier-bot
Note: once the bot is started, it may take up to an hour for the slash commands to register on your server. If the bot isn't showing any errors, have a bit of patience.
The following slash commands will now be available in your server:
/zerotier-bot help
- show help message/zerotier-bot register
- request node authorization
The bot will add Discord username of the requesting user as the name
for the nodes that it authorizes. The bot also checks if string ban
is present in the node description and will not authorize those nodes, this allows node banning in ZeroTier. Users have to join the network first before requesting ZeroTier authorization through the Bot.
- Add a restricted
/zerotier ban
command to ban nodes. - Automate image build and push to Docker Hub.