aboutsummaryrefslogtreecommitdiff
path: root/include/afl-fuzz.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/afl-fuzz.h')
-rw-r--r--include/afl-fuzz.h111
1 files changed, 92 insertions, 19 deletions
diff --git a/include/afl-fuzz.h b/include/afl-fuzz.h
index beb2de2a..c24f39e2 100644
--- a/include/afl-fuzz.h
+++ b/include/afl-fuzz.h
@@ -10,7 +10,7 @@
Dominik Maier <mail@dmnk.co>
Copyright 2016, 2017 Google Inc. All rights reserved.
- Copyright 2019-2023 AFLplusplus Project. All rights reserved.
+ Copyright 2019-2024 AFLplusplus Project. 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.
@@ -31,7 +31,7 @@
#define MESSAGES_TO_STDOUT
#ifndef _GNU_SOURCE
- #define _GNU_SOURCE 1
+ #define _GNU_SOURCE
#endif
#ifndef _FILE_OFFSET_BITS
#define _FILE_OFFSET_BITS 64
@@ -149,6 +149,48 @@ struct tainted {
};
+struct inf_profile {
+
+ u32 inf_skipped_bytes; /* Inference Stage Profiling */
+ u64 inf_execs_cost, inf_time_cost;
+
+};
+
+/* ToDo: add cmplog profile as well */
+struct havoc_profile {
+
+ u32 queued_det_stage, /* Det/Havoc Stage Profiling */
+ queued_havoc_stage, total_queued_det, edge_det_stage, edge_havoc_stage,
+ total_det_edge;
+
+ u64 det_stage_time, havoc_stage_time, total_det_time;
+
+};
+
+struct skipdet_entry {
+
+ u8 continue_inf, done_eff;
+ u32 undet_bits, quick_eff_bytes;
+
+ u8 *skip_eff_map, /* we'v finish the eff_map */
+ *done_inf_map; /* some bytes are not done yet */
+
+};
+
+struct skipdet_global {
+
+ u8 use_skip_havoc;
+
+ u32 undet_bits_threshold;
+
+ u64 last_cov_undet;
+
+ u8 *virgin_det_bits; /* global fuzzed bits */
+
+ struct inf_profile *inf_prof;
+
+};
+
struct queue_entry {
u8 *fname; /* File name for the test case */
@@ -157,6 +199,7 @@ struct queue_entry {
u8 colorized, /* Do not run redqueen stage again */
cal_failed; /* Calibration failed? */
+
bool trim_done, /* Trimmed? */
was_fuzzed, /* historical, but needed for MOpt */
passed_det, /* Deterministic stages passed? */
@@ -168,17 +211,15 @@ struct queue_entry {
disabled; /* Is disabled from fuzz selection */
u32 bitmap_size, /* Number of bits set in bitmap */
- fuzz_level, /* Number of fuzzing iterations */
- n_fuzz_entry /* offset in n_fuzz */
#ifdef INTROSPECTION
- ,
stats_selected, /* stats: how often selected */
stats_skipped, /* stats: how often skipped */
stats_finds, /* stats: # of saved finds */
stats_crashes, /* stats: # of saved crashes */
- stats_tmouts /* stats: # of saved timeouts */
+ stats_tmouts, /* stats: # of saved timeouts */
#endif
- ;
+ fuzz_level, /* Number of fuzzing iterations */
+ n_fuzz_entry; /* offset in n_fuzz */
u64 exec_us, /* Execution time (us) */
handicap, /* Number of queue cycles behind */
@@ -204,6 +245,8 @@ struct queue_entry {
struct queue_entry *mother; /* queue entry this based on */
+ struct skipdet_entry *skipdet_e;
+
};
struct extra_data {
@@ -248,6 +291,8 @@ enum {
/* 19 */ STAGE_CUSTOM_MUTATOR,
/* 20 */ STAGE_COLORIZATION,
/* 21 */ STAGE_ITS,
+ /* 22 */ STAGE_INF,
+ /* 23 */ STAGE_QUICK,
STAGE_NUM_MAX
@@ -346,6 +391,7 @@ enum {
/* 13 */ PY_FUNC_DESCRIBE,
/* 14 */ PY_FUNC_FUZZ_SEND,
/* 15 */ PY_FUNC_SPLICE_OPTOUT,
+ /* 16 */ PY_FUNC_POST_RUN,
PY_FUNC_COUNT
};
@@ -401,7 +447,8 @@ typedef struct afl_env_vars {
afl_exit_on_seed_issues, afl_try_affinity, afl_ignore_problems,
afl_keep_timeouts, afl_no_crash_readme, afl_ignore_timeouts,
afl_no_startup_calibration, afl_no_warn_instability,
- afl_post_process_keep_original;
+ afl_post_process_keep_original, afl_crashing_seeds_as_new_crash,
+ afl_final_sync, afl_ignore_seed_problems;
u8 *afl_tmpdir, *afl_custom_mutator_library, *afl_python_module, *afl_path,
*afl_hang_tmout, *afl_forksrv_init_tmout, *afl_preload,
@@ -494,7 +541,8 @@ typedef struct afl_state {
*orig_cmdline, /* Original command line */
*infoexec; /* Command to execute on a new crash */
- u32 hang_tmout; /* Timeout used for hang det (ms) */
+ u32 hang_tmout, /* Timeout used for hang det (ms) */
+ stats_update_freq; /* Stats update frequency (execs) */
u8 havoc_stack_pow2, /* HAVOC_STACK_POW2 */
no_unlink, /* do not unlink cur_input */
@@ -503,14 +551,12 @@ typedef struct afl_state {
custom_splice_optout, /* Custom mutator no splice buffer */
is_main_node, /* if this is the main node */
is_secondary_node, /* if this is a secondary instance */
- pizza_is_served; /* pizza mode */
-
- u32 stats_update_freq; /* Stats update frequency (execs) */
-
- u8 schedule; /* Power schedule (default: EXPLORE)*/
- u8 havoc_max_mult;
-
- u8 skip_deterministic, /* Skip deterministic stages? */
+ pizza_is_served, /* pizza mode */
+ input_mode, /* target wants text inputs */
+ fuzz_mode, /* coverage/exploration or crash/exploitation mode */
+ schedule, /* Power schedule (default: EXPLORE)*/
+ havoc_max_mult, /* havoc multiplier */
+ skip_deterministic, /* Skip deterministic stages? */
use_splicing, /* Recombine input files? */
non_instrumented_mode, /* Run in non-instrumented mode? */
score_changed, /* Scoring for favorites changed? */
@@ -597,7 +643,8 @@ typedef struct afl_state {
last_hang_time, /* Time for most recent hang (ms) */
longest_find_time, /* Longest time taken for a find */
exit_on_time, /* Delay to exit if no new paths */
- sync_time; /* Sync time (ms) */
+ sync_time, /* Sync time (ms) */
+ switch_fuzz_mode; /* auto or fixed fuzz mode */
u32 slowest_exec_ms, /* Slowest testcase non hang in ms */
subseq_tmouts; /* Number of timeouts in a row */
@@ -610,6 +657,7 @@ typedef struct afl_state {
u32 stage_cur, stage_max; /* Stage progression */
s32 splicing_with; /* Splicing with which test case? */
+ s64 smallest_favored; /* smallest queue id favored */
u32 main_node_id, main_node_max; /* Main instance job splitting */
@@ -674,7 +722,8 @@ typedef struct afl_state {
u32 cmplog_max_filesize;
u32 cmplog_lvl;
u32 colorize_success;
- u8 cmplog_enable_arith, cmplog_enable_transform, cmplog_random_colorization;
+ u8 cmplog_enable_arith, cmplog_enable_transform, cmplog_enable_scale,
+ cmplog_enable_xtreme_transform, cmplog_random_colorization;
struct afl_pass_stat *pass_stats;
struct cmp_map *orig_cmp_map;
@@ -779,6 +828,11 @@ typedef struct afl_state {
* is too large) */
struct queue_entry **q_testcase_cache;
+ /* Global Profile Data for deterministic/havoc-splice stage */
+ struct havoc_profile *havoc_prof;
+
+ struct skipdet_global *skipdet_g;
+
#ifdef INTROSPECTION
char mutation[8072];
char m_tmp[4096];
@@ -1019,6 +1073,16 @@ struct custom_mutator {
void (*afl_custom_fuzz_send)(void *data, const u8 *buf, size_t buf_size);
/**
+ * This method can be used if you want to run some code or scripts each time
+ * AFL++ executes the target with afl-fuzz.
+ *
+ * (Optional)
+ *
+ * @param data pointer returned in afl_custom_init by this custom mutator
+ */
+ void (*afl_custom_post_run)(void *data);
+
+ /**
* Allow for additional analysis (e.g. calling a different tool that does a
* different kind of coverage and saves this for the custom mutator).
*
@@ -1073,6 +1137,7 @@ void finalize_py_module(void *);
u32 fuzz_count_py(void *, const u8 *, size_t);
void fuzz_send_py(void *, const u8 *, size_t);
+void post_run_py(void *);
size_t post_process_py(void *, u8 *, size_t, u8 **);
s32 init_trim_py(void *, u8 *, size_t);
s32 post_trim_py(void *, u8);
@@ -1203,6 +1268,7 @@ u8 check_if_text_buf(u8 *buf, u32 len);
#ifndef AFL_SHOWMAP
void setup_signal_handlers(void);
#endif
+char *get_fuzzing_state(afl_state_t *afl);
/* CmpLog */
@@ -1217,6 +1283,13 @@ AFL_RAND_RETURN rand_next(afl_state_t *afl);
/* probability between 0.0 and 1.0 */
double rand_next_percent(afl_state_t *afl);
+/* SkipDet Functions */
+
+u8 skip_deterministic_stage(afl_state_t *, u8 *, u8 *, u32, u64);
+u8 is_det_timeout(u64, u8);
+
+void plot_profile_data(afl_state_t *, struct queue_entry *);
+
/**** Inline routines ****/
/* Generate a random number (from 0 to limit - 1). This may