假设我有以下代码:
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
int num1 = 0;
int main(int argc, char **argv){
double num2;
int *ptr = &num1;
printf(argv[1]);
if (num1== 2527){
printf("Well done");
}
if(num2 == 4.56)
printf("You are a format string expert");
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我正在努力了解如何正确行事,但我无法用互联网上的指南来组织我的思想.
它假设是这样的:
./Program %p %p %p %p
Run Code Online (Sandbox Code Playgroud)
然后
./Program $( printf "\xAA\xAA\xAA\xAA") %.2523d%n
Run Code Online (Sandbox Code Playgroud)
我只是想不出来,请帮我解决这个问题.
其重点是通过prinft函数将字符串利用到正在运行的程序中.我需要打印"完成"和"你是格式字符串专家".就我而言,通过Linux终端/ shell.正如HuStmpHrrr所注意到的:这确实应该是White Hacking - Software Security