代码:
void doit()
{
system("/bin/sh");
exit(0);
}
int main(int argc, char **argv)
{
static int the_var;
char buf[512];
the_var = 20;
strncpy (buf, argv[1], sizeof(buf) - 1);
printf (buf);
if (the_var != 20)
{
doit();
} else {
printf ("\nthe_var @ 0x%08x = %d 0x%08x\n", &the_var, the_var, the_var);
}
}
Run Code Online (Sandbox Code Playgroud)
程序正在运行粘性位(所有者uid 0)我所要做的就是破解它并/bin/sh以root身份运行.
我知道如何破解程序fe.缓冲区溢出和strcpy(shellcode),但不要如何在这一个上使用'格式字符串攻击'.
正如你所看到的,有一个var the_var,如果它不等于50那么shell正在运行(也许试着以某种方式改变它,一些肮脏的魔法?).无论如何,有一个printf (buf)