Skip to content

Commit c1af87d

Browse files
authored
Web Task Sample (google#37)
* Add web task sample * delete backup file * make a single run statement * fix healtcheck
1 parent 60cc58c commit c1af87d

File tree

27 files changed

+255
-0
lines changed

27 files changed

+255
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# this directory is for Makefile generated outputs
2+
*
3+
!.gitignore
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../kctf-conf/base/Makefile
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# this file will be sourced by the deployment scripts
2+
DEPLOY=true
3+
PUBLIC=false
4+
HEALTHCHECK=false
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
FROM kctf-nsjail
2+
3+
RUN apt-get -y update
4+
RUN apt-get -y upgrade
5+
6+
RUN ln -s /secrets/flag /chroot/flag
7+
8+
VOLUME /tmp
9+
VOLUME /var/log/apache2
10+
VOLUME /var/run/apache2
11+
12+
RUN apt-get install -y apache2
13+
RUN chroot /chroot apt-get install -y php-cgi
14+
15+
RUN service apache2 start
16+
17+
RUN ln -s /etc/apache2/mods-available/cgi.load /etc/apache2/mods-enabled/cgi.load
18+
RUN ln -s /etc/apache2/mods-available/actions.load /etc/apache2/mods-enabled/actions.load
19+
20+
RUN ln -s /config/apache2-nsjail-php.conf /etc/apache2/conf-enabled/nsjail-php.conf
21+
22+
RUN rm -rf /var/www
23+
RUN ln -s /chroot/var/www /var/www
24+
25+
COPY files/html/ /chroot/var/www/html/
26+
COPY files/cgi-bin/ /usr/lib/cgi-bin/
27+
COPY files/root/ /root/
28+
29+
RUN chmod 0755 /chroot/var/www/html /usr/lib/cgi-bin/nsjail-php-cgi /root/launch-apache
30+
31+
CMD /root/launch-apache
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
ServerName kctf-nsjail-php
2+
Listen 1337
3+
4+
<Directory "/var/www/html">
5+
Options +ExecCGI
6+
Action application/x-nsjail-httpd-php /cgi-bin/nsjail-php-cgi
7+
AddHandler application/x-nsjail-httpd-php php
8+
Order allow,deny
9+
Allow from all
10+
</Directory>
11+
12+
<VirtualHost *:1337>
13+
DocumentRoot "/var/www/html"
14+
</VirtualHost>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
configMapGenerator:
2+
- name: apache-php-config
3+
files:
4+
- apache-nsjail-php.conf
5+
- nsjail-php.cfg
6+
generatorOptions:
7+
disableNameSuffixHash: true
8+
labels:
9+
type: generated
10+
annotations:
11+
note: generated
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: "php-cgi-nsjail-configuration"
2+
description: "PHP CGI nsjail configuration for web RCE CTF task."
3+
4+
mode: ONCE
5+
chroot_dir: "/chroot"
6+
log_level: ERROR
7+
uidmap {inside_id: "1000"}
8+
gidmap {inside_id: "1000"}
9+
mount_proc: true
10+
keep_env: true
11+
rlimit_as_type: HARD
12+
rlimit_cpu_type: HARD
13+
rlimit_nofile_type: HARD
14+
rlimit_nproc_type: HARD
15+
16+
mount: [
17+
{
18+
src: "/secrets"
19+
dst: "/secrets"
20+
is_bind: true
21+
},
22+
{
23+
src: "/config"
24+
dst: "/config"
25+
is_bind: true
26+
},
27+
{
28+
dst: "/tmp"
29+
fstype: "tmpfs"
30+
rw: true
31+
}
32+
]
33+
34+
exec_bin {
35+
path: "/usr/lib/cgi-bin/php"
36+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/bash
2+
/usr/bin/nsjail --config /config/nsjail-php.cfg -- /usr/lib/cgi-bin/php $@
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<form method=POST><textarea autofocus name=eval style=height:90%;width:100%;display:block><?php echo htmlentities($_REQUEST["eval"])?></textarea><input type=submit><hr><plaintext><?php echo(eval($_REQUEST["eval"])); ?>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<?php phpinfo(); ?>

0 commit comments

Comments
 (0)