Skip to content

Commit b3bace3

Browse files
committed
Add kctf config for buffer
1 parent 1420f41 commit b3bace3

File tree

3 files changed

+83
-0
lines changed

3 files changed

+83
-0
lines changed

buffer_overflow/Dockerfile

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Copyright 2020 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
FROM ubuntu:20.04 as chroot
15+
16+
RUN /usr/sbin/useradd --no-create-home -u 1000 user
17+
18+
COPY flag /
19+
COPY buffer_overflow /home/user/
20+
21+
FROM gcr.io/kctf-docker/challenge@sha256:d884e54146b71baf91603d5b73e563eaffc5a42d494b1e32341a5f76363060fb
22+
23+
COPY --from=chroot / /chroot
24+
25+
COPY nsjail.cfg /home/user/
26+
27+
CMD kctf_setup && \
28+
kctf_drop_privs \
29+
socat \
30+
TCP-LISTEN:1337,reuseaddr,fork \
31+
EXEC:"kctf_pow nsjail --config /home/user/nsjail.cfg -- /home/user/chal"

buffer_overflow/flag

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
wctf{buffer_overflow_example}

buffer_overflow/nsjail.cfg

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Copyright 2020 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
# See options available at https://github.com/google/nsjail/blob/master/config.proto
16+
17+
name: "default-nsjail-configuration"
18+
description: "Default nsjail configuration for pwnable-style CTF task."
19+
20+
mode: ONCE
21+
uidmap {inside_id: "1000"}
22+
gidmap {inside_id: "1000"}
23+
rlimit_as_type: HARD
24+
rlimit_cpu_type: HARD
25+
rlimit_nofile_type: HARD
26+
rlimit_nproc_type: HARD
27+
28+
cwd: "/home/user"
29+
30+
mount: [
31+
{
32+
src: "/chroot"
33+
dst: "/"
34+
is_bind: true
35+
},
36+
{
37+
dst: "/tmp"
38+
fstype: "tmpfs"
39+
rw: true
40+
},
41+
{
42+
dst: "/proc"
43+
fstype: "proc"
44+
rw: true
45+
},
46+
{
47+
src: "/etc/resolv.conf"
48+
dst: "/etc/resolv.conf"
49+
is_bind: true
50+
}
51+
]

0 commit comments

Comments
 (0)