kurolox / arcoexbot Goto Github PK
View Code? Open in Web Editor NEWA simple Discord bot aimed at arbitrary code execution.
License: MIT License
A simple Discord bot aimed at arbitrary code execution.
License: MIT License
This happens due to using RemainAfterExec
in the unit, since it will never die and therefore it won't be able to restart.
Due to the discord message limit, if a program would create an output bigger than 2000 char long, it will cause a traceback.
Right now the code is not really well written and I'd like to make language addition easier without having to edit the main file by adding extra language as new files. I'd also like to make a new compile() function that will run the compiler for compiled languages and check if there's any error.
I need to rewrite the check_lang() function because it does have a few problems. The most important one is that the bot doesn't give priority to the optional language argument if there's also a syntax markdown language specified in the code block, so you can't use syntax markdown with some languages (ie: trying to use guile, which uses lisp markdown)
Right now if something fails in a compiled language (Rust, C++) there will be no output, so the user won't know what failed. Since the compilers go silent if there are no issues, adding their output to STDERR should fix the issue.
For instance, asking the bot to run a Haskell program will return "À" no matter what the code is, even if it's not a valid program. Similar behavior occurs for Rust, but not for Python.
My guess is that the bot saves input to the same file every time, but it's now failing to overwrite the old version for compiled languages, so we keep getting the output of an old program.
Right now it looks like this.
�[01m�[K/bot/code/cpp/exec/plaincode.cpp:2:1:�[m�[K �[01;31m�[Kerror: �[m�[K'�[01m�[Kajdajdkasjkd�[m�[K' does not name a type
�[01;31m�[Kajdajdkasjkd�[m�[K
�[01;31m�[K^~~~~~~~~~~~�[m�[K
Useful when a language might have different interpreters. It would need a complete bot rewrite though, since each interpreter could need different parameters.
The following:
@Arcoex Bot#4762 ```hs
main = putStrLn "À"
```
Outputs:
executable: <stdout>: commitBuffer: invalid argument (invalid character)
This isn't a big deal, but it would be nice to have.
As far as I know, this is caused because inside the sandbox the environment variables are different than the host, and R might need something that's causing it to show all the extra output. The language works, it's just that it shows some garbage. This is an example of output created by a hello world.
/usr/lib/R/bin/R: line 238: /usr/lib/R/etc/ldpaths: No such file or directory
cannot find system Renviron
Error : .onLoad failed in loadNamespace() for 'utils', details:
call: options(op.utils[toset])
error: invalid value for 'editor'
Error : .onLoad failed in loadNamespace() for 'utils', details:
call: options(op.utils[toset])
error: invalid value for 'editor'
In addition: Warning message:
package ‘utils’ in options("defaultPackages") was not found
During startup - Warning message:
package ‘stats’ in options("defaultPackages") was not found
[1] "Hello, World!"
While the .json system was an improvement over hardcoded languages, it still isn't good enough, since some programming languages can't adjust to the tight restrictions of what the bot expects to get from the .json files.
Writting a README.md both in the root and in the languages folder for the .json template are a few things that I still have to do.
While rewriting the bot in the future, it would be a good chance to learn how to automate tests.
I've added some languages, but I haven't updated the documentation for them, and some require a few workarounds and bash scripts that I should add to the documentation.
I'm completely lost on this one. It seems that if the bot is being launched by a systemd unit file or anything similar (cron jobs, for example) the bot misbehaves, making his output unpredictable. Sometimes he won't output anything, but sometimes it will work, and sometimes it will work partially.
Here are a few images explaining this misbehavior.
None of this behavior happens if the bot is launched manually (either from the computer itself, or through ssh), making this issue extremely hard to debug. I'll appreciate any hint about what could be happening, and I'm more than happy to provide any information that could be relevant.
Right now the language list is hardcoded and it can get spammy. Replacing the general message to a private PM and making the bot autodetect the supported languages would make it better.
When a language is specified via argument and there are more than 3 ` in the start of the code block, any extra will be passed as code, causing errors like in the following example.
/bot/code/bash/28-08-2017_17:25:40.984310.sh: line 1: unexpected EOF while looking for matching ``'
/bot/code/bash/28-08-2017_17:25:40.984310.sh: line 3: syntax error: unexpected end of file
If there's no argument, and the language is set via syntax markdown, the language won't be recognized.
Due to the nature of the manually added languages, all of the paths used for them must be manually created. Otherwise, the bot will complain about files not being found (because there's not a directory to put them), so forcing the bot to create the directories or check if they already exist should be straightforward.
It's not an issue, just redundant because you are already in a private chat with him.
There are a lot of files that should be ignore. Just to list a few:
Right now the bot depends only on the stdout and stderr to know if things went well (if there's any output while compiling, the bot will assume that there was a problem and it will return the compiler output without executing the binary, even if it was just a warning.)
Adding support for checking the exit code of the subprocess would improve the bot and make it more flexible.
Greetings to everyone who finds this project!
Last year hacktoberfest got me started in the world of open source, and I want to contribute by helping people to get their pull requests.
So, this task should be easy for the most part. The only thing you have to do is check the list of supported languages in the bot here, find a language that is not in the list and make a .json file following the instructions there.
Since getting the sandbox might be hard in order to set up the bot for testing purposes, I'd recommend to use the nosandbox
branch. Be careful with it though, because everyone who uses the bot would be getting access to your computer. As long as you use the bot in a private server where you are alone, there shouldn't be any problem.
Feel free to ask me any doubts, or even make new issues to improve the documentation if you feel like something would be missing. Any help is appreciated.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.