Skip to content

Commit 5c958fc

Browse files
committed
release v2
1 parent edaa62e commit 5c958fc

File tree

5 files changed

+31
-5
lines changed

5 files changed

+31
-5
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ The flag will be generated by the initialize.py and it store in flags.txt
3535

3636
The port information corresponding to the pwn program is also inside flags.txt.
3737

38+
## Update
39+
40+
2018.09.17 version v1
41+
2018.09.23 version v2:Use the catflag program instead of /bin/sh, which is more secure
42+
3843
## Reference
3944

4045
https://github.com/Eadom/ctf_xinetd

README_CN.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ docker-compose up --build -d
2929

3030
flag会由`initialize.py`生成,并写入flags.txt中,并且pwn程序对应的端口信息也在里面
3131

32+
## 更新
33+
34+
2018.09.17 version v1
35+
2018.09.23 version v2:使用catflag程序代替/bin/sh,这会更加安全
36+
3237
## 参考
3338

3439
https://github.com/Eadom/ctf_xinetd

catflag

891 KB
Binary file not shown.

catflag.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#include <stdio.h>
2+
3+
int main()
4+
{
5+
FILE *fp = NULL;
6+
char buff[255];
7+
fp = fopen("/flag.txt", "r");
8+
fgets(buff, 255, (FILE*)fp);
9+
printf("%s\n", buff);
10+
fclose(fp);
11+
}

initialize.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ def generateDockerfile(filelist, flags):
5757
# copy bin
5858
copybin = ""
5959
for filename in filelist:
60-
copybin += "COPY " + PWN_BIN_PATH + "/" + filename + " /home/" + filename + "/" + filename + "\n"
60+
copybin += "COPY " + PWN_BIN_PATH + "/" + filename + " /home/" + filename + "/" + filename + "\n"
61+
copybin += "COPY ./catflag" + " /home/" + filename + "/bin/sh\n"
6162
# print copybin
6263

6364
# chown & chmod
@@ -72,16 +73,20 @@ def generateDockerfile(filelist, flags):
7273
# print chown_chmod
7374

7475
# copy lib,/bin
75-
dev = '''mkdir /home/%s/dev && mknod /home/%s/dev/null c 1 3 && mknod /home/%s/dev/zero c 1 5 && mknod /home/%s/dev/random c 1 8 && mknod /home/%s/dev/urandom c 1 9 && chmod 666 /home/%s/dev/* && '''
76-
ness_bin = '''mkdir /home/%s/bin && cp /bin/sh /home/%s/bin && cp /bin/ls /home/%s/bin && cp /bin/cat /home/%s/bin'''
76+
# dev = '''mkdir /home/%s/dev && mknod /home/%s/dev/null c 1 3 && mknod /home/%s/dev/zero c 1 5 && mknod /home/%s/dev/random c 1 8 && mknod /home/%s/dev/urandom c 1 9 && chmod 666 /home/%s/dev/* && '''
77+
dev = '''mkdir /home/%s/dev && mknod /home/%s/dev/null c 1 3 && mknod /home/%s/dev/zero c 1 5 && mknod /home/%s/dev/random c 1 8 && mknod /home/%s/dev/urandom c 1 9 && chmod 666 /home/%s/dev/* '''
78+
# ness_bin = '''mkdir /home/%s/bin && cp /bin/sh /home/%s/bin && cp /bin/ls /home/%s/bin && cp /bin/cat /home/%s/bin'''
79+
# ness_bin = '''cp /bin/sh /home/%s/bin && cp /bin/ls /home/%s/bin && cp /bin/cat /home/%s/bin'''
7780
copy_lib_bin_dev = "RUN "
7881
for x in xrange(0, len(filelist)):
7982
copy_lib_bin_dev += "cp -R /lib* /home/" + filelist[x] + " && "
8083
copy_lib_bin_dev += dev % (filelist[x], filelist[x], filelist[x], filelist[x], filelist[x], filelist[x])
8184
if x == len(filelist) - 1:
82-
copy_lib_bin_dev += ness_bin % (filelist[x], filelist[x], filelist[x], filelist[x])
85+
# copy_lib_bin_dev += ness_bin % (filelist[x], filelist[x], filelist[x])
86+
pass
8387
else:
84-
copy_lib_bin_dev += ness_bin % (filelist[x], filelist[x], filelist[x], filelist[x]) + " && "
88+
# copy_lib_bin_dev += ness_bin % (filelist[x], filelist[x], filelist[x]) + " && "
89+
copy_lib_bin_dev += " && "
8590

8691
# print copy_lib_bin_dev
8792

0 commit comments

Comments
 (0)