aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Shvedov <60114847+a-shvedov@users.noreply.github.com>2024-06-03 19:01:50 +0300
committerGitHub <noreply@github.com>2024-06-03 19:01:50 +0300
commitb8536ced093ca46f004bea76adbd1ad484d8a8d7 (patch)
tree07b7bf56952d48026ac761d52b7a4352bed341a7
parent5fb657f56945dcc7bc2ed2817fac863b69315ac7 (diff)
downloadafl++-b8536ced093ca46f004bea76adbd1ad484d8a8d7.tar.gz
Update generate_libtoken_dict.sh
-rw-r--r--utils/libtokencap/generate_libtoken_dict.sh16
1 files changed, 13 insertions, 3 deletions
diff --git a/utils/libtokencap/generate_libtoken_dict.sh b/utils/libtokencap/generate_libtoken_dict.sh
index 1ddec06b..cc8c5de7 100644
--- a/utils/libtokencap/generate_libtoken_dict.sh
+++ b/utils/libtokencap/generate_libtoken_dict.sh
@@ -1,6 +1,6 @@
#help
usage() {
- echo "Usage: $0 -o <target_output> -b <target_bin> -p <LD_PRELOAD_PATH> [-t <timeout_sec>]"
+ echo "Usage: $0 -o <target_output> -b <target_bin> -p <LD_PRELOAD_PATH> [-t <timeout_sec>] -- [target_args]"
echo "Options:"
echo " -o Path to target output directory"
echo " -b Path to target program binary"
@@ -21,6 +21,9 @@ while getopts ":o:b:p:t:" opt; do
esac
done
+#shift away the parsed opts
+shift $((OPTIND - 1))
+
#check options
if [ -z "$target_output" ] || [ -z "$target_bin" ] || [ -z "$LD_PRELOAD_PATH" ]; then
echo "Error: Missing mandatory opts" >&2
@@ -29,7 +32,7 @@ fi
# initialize vars
AFL_TOKEN_FILE="${PWD}/temp_output.txt"
-AFL_DICT_FILE="$(basename "$target_output").dict"
+AFL_DICT_FILE="${PWD}/$(basename "$target_bin")_tokens.dict"
#generate token-file
{
@@ -37,9 +40,16 @@ AFL_DICT_FILE="$(basename "$target_output").dict"
for i in $(find "$target_output" -type f -name "id*"); do
LD_PRELOAD="$LD_PRELOAD_PATH" \
timeout -s SIGKILL "$timeout_sec" \
- "$target_bin" "$i"
+ "$target_bin" "$@" "$i"
done
} >"$AFL_TOKEN_FILE"
# sort & remove duplicates
sort -u "$AFL_TOKEN_FILE" >"$AFL_DICT_FILE"
+
+# delete temp-file
+rm "$AFL_TOKEN_FILE"
+
+# print done-message
+echo "Token dictionary created: $AFL_DICT_FILE"
+echo "Script completed successfully"