/* example.c
*
* $ gcc -o example example.c
* $ execstack -s example # make stack executable
*/
#include <stdio.h>
int main() {
int a = -5;
float b = 5.5;
char *c = "My String";
printf("A = %d, B = %f, C = %s\n", a, b, c);
}
视频教程的第一部分和第二部分使用的示例代码:
/* fmt.c - sample program vulnerable to format string exploitation
*
* $ gcc -o fmt fmt.c
* $ execstack -s fmt # make stack executable
*/
#include <stdio.h>
#include <string.h>
int main(int argc, char *argv[]) {
char b[128];
strcpy(b, argv[1]);
printf(b);
printf("\n");
}