FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
winafl/test.cpp at master · googleprojectzero/winafl · GitHub
googleprojectzero
/
winafl
Public
Notifications
You must be signed in to change notification settings
Fork
560
Star
2.6k
Code
Issues
163
Pull requests
7
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
winafl
/
test.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
125 lines (113 loc) · 2.65 KB
Breadcrumbs
winafl
/
test.cpp
Copy path
File metadata and controls
125 lines (113 loc) · 2.65 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/*
WinAFL - A simple test binary that crashes on certain inputs:
- 'test1' with a normal write access violation at NULL
- 'test2' with a /GS stack cookie violation
-------------------------------------------------------------
Written and maintained by Ivan Fratric <ifratric@google.com>
Copyright 2016 Google Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#
define
_CRT_SECURE_NO_WARNINGS
#
include
<
stdio.h
>
#
include
<
windows.h
>
#
include
<
string.h
>
int
__declspec
(noinline) test_target(
char
* input_file_path,
char
* argv_0)
{
char
*crash =
NULL
;
FILE
*fp =
fopen
(input_file_path,
"
rb
"
);
char
c;
if
(!fp) {
printf
(
"
Error opening file
\n
"
);
return
0
;
}
if
(
fread
(&c,
1
,
1
, fp) !=
1
) {
printf
(
"
Error reading file
\n
"
);
fclose
(fp);
return
0
;
}
if
(c !=
'
t
'
) {
printf
(
"
Error 1
\n
"
);
fclose
(fp);
return
0
;
}
if
(
fread
(&c,
1
,
1
, fp) !=
1
) {
printf
(
"
Error reading file
\n
"
);
fclose
(fp);
return
0
;
}
if
(c !=
'
e
'
) {
printf
(
"
Error 2
\n
"
);
fclose
(fp);
return
0
;
}
if
(
fread
(&c,
1
,
1
, fp) !=
1
) {
printf
(
"
Error reading file
\n
"
);
fclose
(fp);
return
0
;
}
if
(c !=
'
s
'
) {
printf
(
"
Error 3
\n
"
);
fclose
(fp);
return
0
;
}
if
(
fread
(&c,
1
,
1
, fp) !=
1
) {
printf
(
"
Error reading file
\n
"
);
fclose
(fp);
return
0
;
}
if
(c !=
'
t
'
) {
printf
(
"
Error 4
\n
"
);
fclose
(fp);
return
0
;
}
printf
(
"
!!!!!!!!!!OK!!!!!!!!!!
\n
"
);
if
(
fread
(&c,
1
,
1
, fp) !=
1
) {
printf
(
"
Error reading file
\n
"
);
fclose
(fp);
return
0
;
}
if
(c ==
'
1
'
) {
//
cause a crash
crash[
0
] =
1
;
}
else
if
(c ==
'
2
'
) {
char
buffer[
5
] = {
0
};
//
stack-based overflow to trigger the GS cookie corruption
for
(
int
i =
0
; i <
5
; ++i)
strcat
(buffer, argv_0);
printf
(
"
buffer: %s
\n
"
, buffer);
}
else
{
printf
(
"
Error 5
\n
"
);
}
fclose
(fp);
return
0
;
}
int
main
(
int
argc,
char
** argv)
{
if
(argc <
2
) {
printf
(
"
Usage: %s <input file>
\n
"
, argv[
0
]);
return
0
;
}
if
(argc ==
3
&& !
strcmp
(argv[
2
],
"
loop
"
))
{
//
loop inside application and call target infinitey
while
(
true
)
{
test_target
(argv[
1
], argv[
0
]);
}
}
else
{
//
regular single target call
return
test_target
(argv[
1
], argv[
0
]);
}
}
Back
|
FazBrowse Home
|
New Git URL