Kullanılacak küçük bir C programım var. Ve ayrıca yapılacak olan saldırının arkasındaki mantığı da anladım. Ancak, çalıştığım kadarıyla, sadece benim için çalışmıyor. "Printf (user_input);"Biçim Dize Saldırısı
#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); /* getting a string from user */
printf(user_input);
printf("\n");
/* Verify whether your attack is successful */
printf("The original secrets: 0x%x -- 0x%x\n", SECRET1, SECRET2);
printf("The new secrets: 0x%x -- 0x%x\n", secret[0], secret[1]);
return 0;
}
Sadece adres ve gizli [0] biçim dizesi kullanarak değerini yazdırmak gerekiyor
"\ x6e \ xaf \ xff \ xff% x% x% x% x% s" gibi bir şey vermeye çalıştım. ama bu çalışmıyor. Herhangi bir öneri takdir edilecektir. Çok teşekkürler.
Bir şeyin adresini yazdırmak isterseniz, muhtemelen, '&' operatörünün adresini kullanmalısınız. Iyi biçimlendirilmiş kod için –
+1. –