我正在尝试解决 ctf 平台中的 pwn 问题。该程序仅用于scanf()
从标准输入中获取数字数组的索引和内容:
for ( i = 0; i <= 3; ++i )
{
puts("enter index:");
__isoc99_scanf("%d", &index);
if ( index > 3 )
{
puts("index is too big");
exit(0);
}
puts("enter value:");
__isoc99_scanf("%d", &num);
s[index] = num;
}
while ( j <= 3 )
printf("0x%08x\t", s[j++]);
return __readgsdword(0x14u) ^ canary;
但是,当我使用send()
函数向程序发送 4 字节整数时,scanf 函数似乎检测到 EOF(而不是 4 字节整数)并且 scanf 什么也没有。此外,由于EOF,以下scanf()
拒绝获取数字。我的send()
陈述和执行结果如下:
r.recv()
r.sendline(p32(0x1))
r.recv()
r.sendline(p32(0x1))
我的问题是:如何解释这个异常问题,以及如何正确使用向该程序send()
中的函数发送数字?__isoc99_scanf("%d", &number)