小编sha*_*lic的帖子

格式字符串攻击

我有一个小的C程序可以被利用.而且我也理解了要执行的攻击背后的逻辑.但是,尽管我尝试过,但这对我来说并不合适.

#include <stdio.h>
#include <stdlib.h>

#define SECRET1 0x44
#define SECRET2 0x55

int main(int argc, char *argv[]) {
  char user_input[100];
  int *secret;
  int int_input;
  int a, b, c, d; /* other variables, not used here.*/

  /* The secret value is stored on the heap */
  secret = (int *) malloc(2*sizeof(int));

  /* getting the secret */
  secret[0] = SECRET1; secret[1] = SECRET2;

  printf("Please enter a decimal integer\n");
  scanf("%d", &int_input);  /* getting an input from user */
  printf("Please enter a string\n");
  scanf("%s", user_input); …
Run Code Online (Sandbox Code Playgroud)

c buffer-overflow format-string fortify-source

5
推荐指数
1
解决办法
3089
查看次数