OLD | NEW |
(Empty) | |
| 1 #!/bin/sh |
| 2 # |
| 3 # american fuzzy lop - clang assembly normalizer |
| 4 # ---------------------------------------------- |
| 5 # |
| 6 # Written and maintained by Michal Zalewski <lcamtuf@google.com> |
| 7 # The idea for this wrapper comes from Ryan Govostes. |
| 8 # |
| 9 # Copyright 2013, 2014 Google Inc. All rights reserved. |
| 10 # |
| 11 # Licensed under the Apache License, Version 2.0 (the "License"); |
| 12 # you may not use this file except in compliance with the License. |
| 13 # You may obtain a copy of the License at: |
| 14 # |
| 15 # http://www.apache.org/licenses/LICENSE-2.0 |
| 16 # |
| 17 # This 'as' wrapper should allow you to instrument unruly, hand-written |
| 18 # assembly with afl-as. |
| 19 # |
| 20 # Usage: |
| 21 # |
| 22 # export AFL_REAL_PATH=/path/to/directory/with/afl-as/ |
| 23 # AFL_PATH=/path/to/this/directory/ make clean all |
| 24 |
| 25 if [ "$#" -lt "2" ]; then |
| 26 echo "[-] Error: this utility can't be called directly." 1>&2 |
| 27 exit 1 |
| 28 fi |
| 29 |
| 30 if [ "$AFL_REAL_PATH" = "" ]; then |
| 31 echo "[-] Error: AFL_REAL_PATH not set!" 1>&2 |
| 32 exit 1 |
| 33 fi |
| 34 |
| 35 if [ ! -x "$AFL_REAL_PATH/afl-as" ]; then |
| 36 echo "[-] Error: AFL_REAL_PATH does not contain the 'afl-as' binary." 1>&2 |
| 37 exit 1 |
| 38 fi |
| 39 |
| 40 unset __AFL_AS_CMDLINE __AFL_FNAME |
| 41 |
| 42 while [ ! "$#" = "0" ]; do |
| 43 |
| 44 if [ "$#" = "1" ]; then |
| 45 __AFL_FNAME="$1" |
| 46 else |
| 47 __AFL_AS_CMDLINE="${__AFL_AS_CMDLINE} $1" |
| 48 fi |
| 49 |
| 50 shift |
| 51 |
| 52 done |
| 53 |
| 54 test "$TMPDIR" = "" && TMPDIR=/tmp |
| 55 |
| 56 TMPFILE=`mktemp $TMPDIR/.afl-XXXXXXXXXX.s` |
| 57 |
| 58 test "$TMPFILE" = "" && exit 1 |
| 59 |
| 60 clang -cc1as -filetype asm -output-asm-variant 0 "${__AFL_FNAME}" >"$TMPFILE" |
| 61 |
| 62 ERR="$?" |
| 63 |
| 64 if [ ! "$ERR" = "0" ]; then |
| 65 rm -f "$TMPFILE" |
| 66 exit $ERR |
| 67 fi |
| 68 |
| 69 "$AFL_REAL_PATH/afl-as" ${__AFL_AS_CMDLINE} "$TMPFILE" |
| 70 |
| 71 ERR="$?" |
| 72 |
| 73 rm -f "$TMPFILE" |
| 74 |
| 75 exit "$ERR" |
OLD | NEW |