Giter Site home page Giter Site logo

discord-zerotier-bot's Introduction

Discord ZeroTier Bot

Intro

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.

Setup

Step 1 - .env file

Create the .env file to use as config:

cp template.env .env

Step 2 - Discord Bot

  1. You need a Discord user account, and admin access to t he Discord server where you want to use the Bot.
  2. 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). New Application
  3. Create a Bot for your application by clicking Bot in the application settings, then select Add Bot. Add Bot
  4. Copy the Bot token and save it in the .env as DISCORD_TOKEN

Step 3 - Authorize the Bot

  1. In the application settings, select OAuth2, then select bot under Scopes.
  2. Under Bot Permissions select Send Messages and Use Slash Commands. Authorize Bot
  3. Open the displayed URL and authorize the Bot in your Discord server.

Step 3 - ZeroTier

  1. Login to ZeroTier.
  2. Go to your Account settings and create a new API token. ZeroTier Token
  3. Save the token in the .env file as ZT_TOKEN.
  4. Save the network ID in the .env as ZT_NETWORK (create a new network if you haven't yet).

Step 4 - Start the Bot

Build the Docker image:

docker build -t discord-zerotier-bot .

Start the Bot:

docker run --rm -it --env-file .env discord-zerotier-bot

Usage

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.

TODO

  • Add a restricted /zerotier ban command to ban nodes.
  • Automate image build and push to Docker Hub.

discord-zerotier-bot's People

Contributors

airman604 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

discord-zerotier-bot's Issues

Commands not appearing in Discord

INFO:discord.client:logging in using static token
INFO:discord.gateway:Shard ID None has sent the IDENTIFY payload.
INFO:discord.gateway:Shard ID None has connected to Gateway: ["gateway-prd-main-t7ln",{"micros":74525,"calls":["discord-sessions-blue-prd-2-156",{"micros":73636,"calls":["start_session",{"micros":24761,"calls":["api-prd-main-289j",{"micros":22026,"calls":["get_user",{"micros":2278},"add_authorized_ip",{"micros":1173},"get_guilds",{"micros":3218},"coros_wait",{"micros":0}]}]},"guilds_connect",{"micros":2,"calls":[]},"presence_connect",{"micros":1,"calls":[]}]}]}] (Session ID: 5989559af0206882e3db2ff91b9d88d5).
INFO:discord_slash:Syncing commands...
INFO:root:Ready!
INFO:discord_slash:Syncing permissions...
INFO:discord_slash:Completed syncing all commands!

Script seems to execute fine, the bot is online, but no commands present in Discord hours after. Any idea?
EDIT: Forgot to mention; I'm running the bot directly, outside Docker, on Windows.

SEND HELP!

THIS IS URGENT!, PLEASE HELP!
i dont know how to make the bot work without docker on windows!
so please help!
and the import discord_slash doesn't work :(
as pip install discord_slash module is missing!

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.