Skip to content

Commit 0dabdf5

Browse files
committedJul 10, 2021
Jail experiment
1 parent 90d0db7 commit 0dabdf5

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed
 

‎chroot/make_jail.sh

+14-7
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,22 @@ cp hello.c jail
88

99
cd jail
1010

11-
./simple-chroot.sh install busybox bash sh vim gcc as ld ls which rm find
11+
./simple-chroot.sh install bash vim gcc as ld ls which rm find sh
1212

13-
mkdir usr/libexec
14-
cp -r /usr/libexec/* usr/libexec
13+
mkdir tmp
14+
chmod 1777 tmp
15+
mkdir var
16+
mkdir var/tmp
17+
chmod 1777 var/tmp
18+
19+
mkdir usr/lib/gcc/
20+
mkdir usr/lib/gcc/x86_64-linux-gnu
21+
cp -r /usr/lib/gcc/x86_64-linux-gnu/* usr/lib/gcc/x86_64-linux-gnu
22+
cp -r /usr/lib/x86_64-linux-gnu/* usr/lib/x86_64-linux-gnu
1523

1624
mkdir usr/include
25+
mkdir usr/include/x86_64-linux-gnu
26+
cp -r /usr/include/x86_64-linux-gnu/* usr/include/x86_64-linux-gnu
1727
cp -r /usr/include/* usr/include
18-
19-
cp -r /usr/lib/* usr/lib
20-
21-
cp -r /lib/* lib
28+
cp -r /lib/x86_64-linux-gnu/* lib/x86_64-linux-gnu/
2229

‎docker/apache/compile.php

+3
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
'PATH' => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
4545
);
4646

47+
// $command = 'chroot /var/www/html/jail; mkdir '.$folder.'; gcc -ansi -x c -o a.out -';
4748
$command = 'gcc -ansi -x c -o a.out -';
4849
$process = proc_open($command, $descriptorspec, $pipes, $cwd, $env);
4950

@@ -69,6 +70,7 @@
6970

7071
if ( $retval->compile_status === 0 ) {
7172

73+
$command = 'chroot /var/www/html/jail; cd '.$folder.'; ./a.out -';
7274
$command = './a.out';
7375
$process = proc_open($command, $descriptorspec, $pipes, $cwd, $env);
7476

@@ -91,6 +93,7 @@
9193
$retval->run_status = proc_close($process);
9294

9395
}
96+
}
9497

9598
header("Content-type: application/json; charset=utf-8");
9699
echo(json_encode($retval, JSON_PRETTY_PRINT));

0 commit comments

Comments
 (0)
Please sign in to comment.