wdb2018_guess

看了pwnki师傅的博客,才明白这个题怎么写的,所以先只说下思路

前置知识

在程序加了 carry 保护后,如果我们的输入覆盖了 carry ,程序就会报错,而报错代码如下:

void __attribute__ ((noreturn)) __stack_chk_fail (void)
{
  __fortify_fail ("stack smashing detected");
}
void __attribute__ ((noreturn)) internal_function __fortify_fail (const char *msg)
{
  /* The loop is added only to keep gcc happy.  */
  while (1)
    __libc_message (2, "*** %s ***: %s terminated
",
                    msg, __libc_argv[0] ?: "<unknown>");
}

思路

1、首先通过覆盖栈上的__libc_argv[0]的偏移,将某个libc函数的地址写进去,从而泄露libc的基址

2、通过libc地址计算enviorn地址(当前进程的环境变量,有栈的基址),泄露栈的基址

3、在通过计算flag在栈上的偏移来泄露flag

原文地址:https://www.cnblogs.com/pppyyyzzz/p/14224651.html