mirror of
https://github.com/engineer-man/piston.git
synced 2025-04-21 20:46:26 +02:00
new docs, better executors, better expansion for languages
This commit is contained in:
parent
7bc9b5b63a
commit
3233db5c1f
24 changed files with 131 additions and 59 deletions
126
readme.md
126
readme.md
|
@ -1,6 +1,7 @@
|
|||
## Piston
|
||||
Piston is the underlying engine for running untrusted and possibly malicious code that originates from EMKC contests and challenges. It's also used in the Engineer Man Discord server via
|
||||
[felix bot](https://github.com/engineer-man/felix).
|
||||
Piston is the underlying engine for running untrusted and possibly malicious
|
||||
code that originates from EMKC contests and challenges. It's also used in the
|
||||
Engineer Man Discord server via [felix bot](https://github.com/engineer-man/felix).
|
||||
|
||||
#### Installation
|
||||
```
|
||||
|
@ -29,25 +30,111 @@ lxc-create -t download -n piston -- --dist ubuntu --release bionic --arch amd64
|
|||
./shell
|
||||
|
||||
# install all necessary piston dependencies
|
||||
echo 'source /opt/.profile' >> /opt/.bashrc
|
||||
echo 'export HOME=/opt' >> /opt/.profile
|
||||
echo 'export TERM=linux' >> /opt/.profile
|
||||
export HOME=/opt
|
||||
echo 'export PATH=/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin' >> /root/.bashrc
|
||||
echo 'export PATH=$PATH:/root/.cargo/bin' >> /root/.bashrc
|
||||
export TERM=linux
|
||||
sed -i 's/\/root/\/opt/' /etc/passwd
|
||||
sed -i \
|
||||
's/http:\/\/archive.ubuntu.com\/ubuntu/http:\/\/mirror.math.princeton.edu\/pub\/ubuntu/' \
|
||||
/etc/apt/sources.list
|
||||
apt-get update
|
||||
apt-get -y install git tzdata nano \
|
||||
dpkg-dev build-essential python python3 \
|
||||
ruby nodejs npm golang php7.2 r-base mono-complete \
|
||||
nasm openjdk-8-jdk ubuntu-make bf
|
||||
npm install -g typescript
|
||||
umake swift
|
||||
ln -s /opt/.local/share/umake/swift/swift-lang/usr/bin/swift /usr/bin/swift
|
||||
curl https://sh.rustup.rs > rust.sh
|
||||
sh rust.sh -y
|
||||
ln -s /opt/.cargo/bin/rustc /usr/bin/rustc
|
||||
rm -rf /home/ubuntu
|
||||
chmod 777 /tmp
|
||||
apt-get install -y \
|
||||
nano wget build-essential pkg-config libxml2-dev \
|
||||
libsqlite3-dev mono-complete curl cmake libpython2.7-dev \
|
||||
ruby
|
||||
|
||||
# install python2
|
||||
# final binary: /opt/python2/Python-2.7.17/python -V
|
||||
cd /opt && mkdir python2 && cd python2
|
||||
wget https://www.python.org/ftp/python/2.7.17/Python-2.7.17.tar.xz
|
||||
unxz Python-2.7.17.tar.xz
|
||||
tar -xf Python-2.7.17.tar
|
||||
cd Python-2.7.17
|
||||
./configure
|
||||
# open Modules/Setup and uncomment zlib line
|
||||
make -j16
|
||||
echo 'export PATH=$PATH:/opt/python2/Python-2.7.17' >> /opt/.profile
|
||||
source /opt/.profile
|
||||
|
||||
# install python3
|
||||
# final binary: /opt/python3/Python-3.8.2/python -V
|
||||
cd /opt && mkdir python3 && cd python3
|
||||
wget https://www.python.org/ftp/python/3.8.2/Python-3.8.2.tar.xz
|
||||
unxz Python-3.8.2.tar.xz
|
||||
tar -xf Python-3.8.2.tar
|
||||
cd Python-3.8.2
|
||||
./configure
|
||||
make -j16
|
||||
echo 'export PATH=$PATH:/opt/python3/Python-3.8.2' >> /opt/.profile
|
||||
source /opt/.profile
|
||||
|
||||
# install node.js
|
||||
# final binary: /opt/nodejs/node-v12.16.1-linux-x64/bin/node -v
|
||||
cd /opt && mkdir nodejs && cd nodejs
|
||||
wget https://nodejs.org/dist/v12.16.1/node-v12.16.1-linux-x64.tar.xz
|
||||
unxz node-v12.16.1-linux-x64.tar.xz
|
||||
tar -xf node-v12.16.1-linux-x64.tar
|
||||
echo 'export PATH=$PATH:/opt/nodejs/node-v12.16.1-linux-x64/bin' >> /opt/.profile
|
||||
source /opt/.profile
|
||||
|
||||
# install typescript
|
||||
# final binary: /opt/nodejs/node-v12.16.1-linux-x64/bin/tsc -v
|
||||
/opt/nodejs/node-v12.16.1-linux-x64/bin/npm i -g typescript
|
||||
|
||||
# install golang
|
||||
# final binary: /opt/go/go/bin/go version
|
||||
cd /opt && mkdir go && cd go
|
||||
wget https://dl.google.com/go/go1.14.1.linux-amd64.tar.gz
|
||||
tar -xzf go1.14.1.linux-amd64.tar.gz
|
||||
echo 'export PATH=$PATH:/opt/go/go/bin' >> /opt/.profile
|
||||
echo 'export GOROOT=/opt/go/go' >> /opt/.profile
|
||||
echo 'export GOCACHE=/tmp' >> /opt/.profile
|
||||
source /opt/.profile
|
||||
|
||||
# install php
|
||||
# final binary: /usr/local/bin/php -v
|
||||
cd /opt && mkdir php && cd php
|
||||
wget https://www.php.net/distributions/php-7.4.4.tar.gz
|
||||
tar -xzf php-7.4.4.tar.gz
|
||||
cd php-7.4.4
|
||||
./configure
|
||||
make -j16
|
||||
make install
|
||||
|
||||
# install rust
|
||||
# final binary: /opt/.cargo/bin/rustc --version
|
||||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
|
||||
echo 'export PATH=$PATH:/opt/.cargo/bin' >> /opt/.profile
|
||||
source /opt/.profile
|
||||
|
||||
# install swift
|
||||
# final binary: /opt/swift/swift-5.1.5-RELEASE-ubuntu18.04/usr/bin/swift --version
|
||||
cd /opt && mkdir swift && cd swift
|
||||
wget https://swift.org/builds/swift-5.1.5-release/ubuntu1804/swift-5.1.5-RELEASE/swift-5.1.5-RELEASE-ubuntu18.04.tar.gz
|
||||
tar -xzf swift-5.1.5-RELEASE-ubuntu18.04.tar.gz
|
||||
echo 'export PATH=$PATH:/opt/swift/swift-5.1.5-RELEASE-ubuntu18.04/usr/bin' >> /opt/.profile
|
||||
source /opt/.profile
|
||||
|
||||
# install nasm
|
||||
# final binary: /opt/nasm/nasm-2.14.02/nasm -v
|
||||
cd /opt && mkdir nasm && cd nasm
|
||||
wget https://www.nasm.us/pub/nasm/releasebuilds/2.14.02/nasm-2.14.02.tar.gz
|
||||
tar -xzf nasm-2.14.02.tar.gz
|
||||
cd nasm-2.14.02
|
||||
./configure
|
||||
make -j16
|
||||
echo 'export PATH=$PATH:/opt/nasm/nasm-2.14.02' >> /opt/.profile
|
||||
source /opt/.profile
|
||||
|
||||
# install java
|
||||
# final binary: /opt/java/jdk-14/bin/java -version
|
||||
cd /opt && mkdir java && cd java
|
||||
wget https://download.java.net/java/GA/jdk14/076bab302c7b4508975440c56f6cc26a/36/GPL/openjdk-14_linux-x64_bin.tar.gz
|
||||
tar -xzf openjdk-14_linux-x64_bin.tar.gz
|
||||
echo 'export PATH=$PATH:/opt/java/jdk-14/bin' >> /opt/.profile
|
||||
source /opt/.profile
|
||||
|
||||
# create runnable users and apply limits
|
||||
for i in {1..150}; do
|
||||
|
@ -59,6 +146,10 @@ for i in {1..150}; do
|
|||
echo "runner$i hard nofile 2048" >> /etc/security/limits.conf
|
||||
done
|
||||
|
||||
# cleanup
|
||||
rm -rf /home/ubuntu
|
||||
chmod 777 /tmp
|
||||
|
||||
# leave container
|
||||
exit
|
||||
|
||||
|
@ -106,7 +197,8 @@ If an invalid language is supplied, a typical response will look like the follow
|
|||
```
|
||||
|
||||
#### Supported Languages
|
||||
Currently python2, python3, c, c++, go, node, ruby, r, c#, nasm, php, java, swift, brainfuck, rust, bash, and typescript is supported.
|
||||
Currently python2, python3, c, c++, go, node, ruby, r, c#, nasm, php, java,
|
||||
swift, brainfuck, rust, bash, and typescript is supported.
|
||||
|
||||
#### Principle of Operation
|
||||
Piston utilizes LXC as the primary mechanism for sandboxing. There is a small API written in Go which takes
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue