Skip to content

Commit b00feae

Browse files
committed
Upgrade to E9Patch-1.0.0-rc3 & other improvements
1 parent c64d91e commit b00feae

File tree

7 files changed

+40
-19
lines changed

7 files changed

+40
-19
lines changed

README.md

+8-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ To build E9AFL, simply run the `build.sh` script:
1919

2020
$ ./build.sh
2121

22+
To build the Debian package, simply run the `install.sh` script:
23+
24+
$ ./install.sh
25+
2226
## Usage
2327

2428
First, install `afl-fuzz`:
@@ -31,7 +35,10 @@ To use E9AFL, simply run the command:
3135

3236
This will generate an AFL-instrumented `binary.afl` which can be
3337
used with `afl-fuzz`.
34-
See the example below.
38+
39+
For more information on tool usage, see the man page:
40+
41+
$ man -l doc/e9afl.l
3542

3643
## Example
3744

VERSION

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.7.0

build.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ fi
3232

3333
set -e
3434

35-
VERSION=c30c678632f4a60b2f77c8c3cc252c5d557a33e0
35+
VERSION=c08b98f76191221da950a34d7a7216844cd43629
3636

3737
# STEP (1): install e9patch if necessary:
3838
if [ ! -x e9patch-$VERSION/e9patch ]
@@ -70,7 +70,7 @@ e9patch-$VERSION/e9compile.sh afl-rt.c -I e9patch-$VERSION/examples/ \
7070
chmod a-x afl-rt
7171

7272
# STEP (4): build the driver:
73-
g++ -std=c++11 -fPIC -pie -O2 -o e9afl e9afl.cpp
73+
g++ -std=c++11 -fPIC -pie -O2 -DVERSION=`cat VERSION` -o e9afl e9afl.cpp
7474
strip e9afl
7575

7676
# STEP (5): build the installation package:

doc/e9afl.1

+4-1
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,11 @@ Use \fBoutput\fR as the output binary name.
7878
By default, \fBe9afl\fR uses the basename of the input binary appended with
7979
the string \fB".afl"\fR.
8080
.TP
81-
\fB--help\fR
81+
\fB-h\fR, \fB--help\fR
8282
Display the help message and exit.
83+
.TP
84+
\fB-v\fR, \fB--version\fR
85+
Print the version and exit.
8386
.SH "SEE ALSO"
8487
\fIafl-fuzz\fR(1)
8588
.SH AUTHOR

e9AFLPlugin.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* | __/\__, / ___ \| _| | |___
66
* \___| /_/_/ \_\_| |_____|
77
*
8-
* Copyright (C) 2021 National University of Singapore
8+
* Copyright (C) 2022 National University of Singapore
99
*
1010
* This program is free software: you can redistribute it and/or modify
1111
* it under the terms of the GNU General Public License as published by
@@ -129,7 +129,7 @@ enum
129129
/*
130130
* Initialization.
131131
*/
132-
extern void *e9_plugin_init_v1(const Context *cxt)
132+
extern void *e9_plugin_init(const Context *cxt)
133133
{
134134
static const struct option long_options[] =
135135
{
@@ -658,7 +658,7 @@ static void calcInstrumentPoints(const ELF *elf, const Instr *Is, size_t size,
658658
/*
659659
* Events.
660660
*/
661-
extern void e9_plugin_event_v1(const Context *cxt, Event event)
661+
extern void e9_plugin_event(const Context *cxt, Event event)
662662
{
663663
switch (event)
664664
{
@@ -678,23 +678,23 @@ extern void e9_plugin_event_v1(const Context *cxt, Event event)
678678
/*
679679
* Matching. Return `true' iff we should instrument this instruction.
680680
*/
681-
extern intptr_t e9_plugin_match_v1(const Context *cxt)
681+
extern intptr_t e9_plugin_match(const Context *cxt)
682682
{
683683
return (instrument.find(cxt->I->address) != instrument.end());
684684
}
685685

686686
/*
687687
* Patch template.
688688
*/
689-
extern void e9_plugin_code_v1(const Context *cxt)
689+
extern void e9_plugin_code(const Context *cxt)
690690
{
691691
fputs("\"$afl\",", cxt->out);
692692
}
693693

694694
/*
695695
* Patching.
696696
*/
697-
extern void e9_plugin_patch_v1(const Context *cxt)
697+
extern void e9_plugin_patch(const Context *cxt)
698698
{
699699
if (instrument.find(cxt->I->address) == instrument.end())
700700
return;

e9afl.cpp

+18-8
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* | __/\__, / ___ \| _| | |___
66
* \___| /_/_/ \_\_| |_____|
77
*
8-
* Copyright (C) 2021 National University of Singapore
8+
* Copyright (C) 2022 National University of Singapore
99
*
1010
* This program is free software: you can redistribute it and/or modify
1111
* it under the terms of the GNU General Public License as published by
@@ -33,14 +33,18 @@
3333

3434
#include <string>
3535

36+
#define STRING(s) STRING_2(s)
37+
#define STRING_2(s) #s
38+
3639
enum Option
3740
{
3841
OPTION_COUNTER,
3942
OPTION_OBLOCK,
4043
OPTION_OSELECT,
4144
OPTION_DEBUG,
4245
OPTION_OUTPUT,
43-
OPTION_HELP
46+
OPTION_HELP,
47+
OPTION_VERSION,
4448
};
4549

4650
enum Value
@@ -172,12 +176,13 @@ int main(int argc, char **argv)
172176
{"Oselect", required_argument, nullptr, OPTION_OSELECT},
173177
{"debug", no_argument, nullptr, OPTION_DEBUG},
174178
{"help", no_argument, nullptr, OPTION_HELP},
179+
{"version", no_argument, nullptr, OPTION_VERSION},
175180
{nullptr, no_argument, nullptr, 0}
176181
};
177182
while (true)
178183
{
179184
int idx;
180-
int opt = getopt_long_only(argc, argv, "do:", long_options, &idx);
185+
int opt = getopt_long_only(argc, argv, "dho:v", long_options, &idx);
181186
if (opt < 0)
182187
break;
183188
switch (opt)
@@ -198,10 +203,10 @@ int main(int argc, char **argv)
198203
free(option_output);
199204
option_output = strdup(optarg);
200205
break;
201-
case OPTION_HELP:
206+
case 'h': case OPTION_HELP:
202207
fprintf(stderr, "usage %s [OPTIONS] binary [e9tool-OPTIONS]\n",
203208
argv[0]);
204-
fprintf(stderr,
209+
printf(
205210
"\n"
206211
"OPTIONS:\n"
207212
"\t--counter=classic,neverzero,saturated\n"
@@ -214,9 +219,14 @@ int main(int argc, char **argv)
214219
"\t\tEnable debugging output.\n"
215220
"\t-o OUTPUT\n"
216221
"\t\tSet OUTPUT to be the output binary filename.\n"
217-
"\t-help\n"
218-
"\t\tPrint this message\n\n");
219-
exit(0);
222+
"\t-h, --help\n"
223+
"\t\tPrint this message.\n"
224+
"\t-v, -version\n"
225+
"\t\tPrint version information.\n\n");
226+
exit(EXIT_SUCCESS);
227+
case 'v': case OPTION_VERSION:
228+
printf("E9AFL " STRING(VERSION) "\n");
229+
exit(EXIT_SUCCESS);
220230
default:
221231
error("failed to parse command-line options; try `--help' "
222232
"for more information");

install.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ else
3131
fi
3232

3333
NAME=e9afl
34-
VERSION=0.6.0
34+
VERSION=`cat VERSION`
3535

3636
if [ ! -x install/e9afl ]
3737
then

0 commit comments

Comments
 (0)