Skip to content

A simple Discord bot aimed at arbitrary code execution.

License

Notifications You must be signed in to change notification settings

Kurolox/ArcoexBot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

74 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Arcoex Bot

This is Arcoex! A Discord bot aimed at arbitrary code execution.

Features

  • Easy to expand. Adding new languages is extremely simple!
  • All languages work, even compiled ones. It doesn't matter how unknown is your language, this bot will be able to run it!
  • It reacts to everything you throw at him:
    • There's a typo in your code or something goes wrong? The bot will give you the compiler output or the traceback.
    • Did you make an infinite loop? The bot will take care of it, kill the process and give you the last lines of output.
    • The language you're trying to use isn't supported? The bot will tell you.
    • The output is too long for Discord? The bot will upload it to hastebin.com and give you the link.
  • The sandboxed environment will protect the bot from malicious code! Say goodbye to fork bombs or trying to run rm -rf --no-preserve-root /.

Get the bot

If you want to use this bot in your server without running it manually, you can invite it to your server clicking here.

You can also check it out by joining this Discord server.

Usage

Using the bot is really simple! If you want instructions, just mention the bot and he'll send you a PM with the full instructions. However, using this bot is as simple as mentioning him with the block of code you want to run, and mentioning the language the code is written in (either between the mention and the code block, or as a markdown language inside the code block, or even both if you feel like so!)

For more detailed instructions and example, just mention the bot.

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

In order to use this bot, among using Python 3.4+, you'll need the following software installed and working on your machine.

Discord modules

You'll need to have discord.py and hastebin.py installed. You can either use a virtualenv:

virtualenv .
cd bin
source activate
pip install discord.py && pip install hastebin.py

Or you can install them as user.

pip install --user discord.py && pip install --user hastebin.py

UMLBox

In order to have the arbitrary code properly sandboxed, this bot uses UMLBox. Here are instructions about how to set up UMLBox.

This is an example using the linux kernel 4.12.9.

hg clone https://bitbucket.org/GregorR/umlbox
cd umlbox
wget https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.12.9.tar.xz
tar -xf linux-4.12.9.tar.xz
sed -i '6s/.*/LINUX=linux-4.12.9/' Makefile
make all && make install

If you have an issue when building UMLBox that looks like this:

gcc -g -O3 -c tcp4.c
tcp4.c: In function 'newTCP4C':
tcp4.c:182:21: error: storage size of 'hints' isn't known
     struct addrinfo hints, *ai;
                     ^~~~~
tcp4.c:199:12: warning: implicit declaration of function 'getaddrinfo' [-Wimplicit-function-declaration]
     tmpi = getaddrinfo(hosts, ports, &hints, &ai);
            ^~~~~~~~~~~
tcp4.c:202:19: error: dereferencing pointer to incomplete type 'struct addrinfo'
     ret->addr = ai->ai_addr;
                   ^~
Makefile:18: recipe for target 'tcp4.o' failed
make[1]: *** [tcp4.o] Error 1
make[1]: Leaving directory '/root/fichiers/autres/umlbox/mudem'
Makefile:26: recipe for target 'mudem/umlbox-mudem' failed
make: *** [mudem/umlbox-mudem] Error 2

You have to apply the following fix manually, then try to build again:

In the file mudem/tcp4.c, add the following line:   
#define _POSIX_C_SOURCE 201112L /* for getaddrinfo */   

after this existing line:
#define _POSIX_SOURCE /* for strtok_r */

in order to test umlbox, run the following command in your machine. If it outputs "It works", then everything should be set up correctly.

umlbox -B echo "It works"

Build tools

You'll also need to have the tools to run code in your local machine. This tools are different depending on the language that will be run. If you want more info regarding which tools you'll need, You can check this.

Installing

If you've installed the prerequisites and checked if they work properly, you are almost good to go. First of all, clone this repository.

git clone https://github.com/Kurolox/ArcoexBot

After that, modify auth.py with your text editor of choice, and add your Discord bot token. It should look like this:

bot_token = "MjA5MzE3MDM3MTgzNDY3NTIw.DIV9oA.UuTk8pA7WA6PFDvhJXVPnYUKX0I"

Once that's done, just run arcoex.py and everything should start to work.

python arcoex.py

Deployment

In order to run this in a server, I'd recommend you to install screen and make a systemd unit file that will launch the bot at startup.

This is an example on how to do this. Since installing screen depends on your distribution, you should already know how to install packages and software in your machine.

First, create a file in /etc/systemd/system, called arcoex-bot.service (you may need root privileges to do this.) and edit it with your text editor of choice so it looks like this:

[Unit]
Description= Arcoex Bot for Discord

[Service]
Type=forking
ExecStart=/usr/bin/screen -S arcoex -dm python /path/to/arcoex.py
ExecStop=/usr/bin/screen -S arcoex -X quit
User=INSERTUSERHERE

[Install]
WantedBy=multi-user.target

Replace INSERTUSERHERE with the user you want the bot to be ran under, and replace /path/to/arcoex.py with the absolute path to arcoex.py

If you are using a virtualenv, replace python for /path/to/virtualenv/bin/python, being that path the absolute path to your virtualenv.

As a warning, you should be sure that the user you choose does have write permissions in the bot folder.

In order to activate the bot so it launches with your system, execute this command.

systemctl enable arcoex-bot.service

If you want to start, stop or restart the bot manually, you can do so with the following commands.

systemctl start arcoex-bot
systemctl stop arcoex-bot
systemctl restart arcoex-bot

Contribute

If you want to contribute to this project, feel free to do so! Create an issue or fork the project and make a pull request, any help is appreciated and I'd be glad to know that someone out there wants to see this project grow.

Built With

  • Discord.py - Python discord API
  • UMLBox - User Mode Linux based sandboxing solution

License

This project is licensed under the MIT License - see the LICENSE.md file for details

About

A simple Discord bot aimed at arbitrary code execution.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages