test.sh: "trusty-amd64" does not work well with "realpath". Use

"readlink -f" for Ubuntu instead.
This commit is contained in:
h1994st
2020-03-29 01:22:44 -04:00
committed by Dominik Maier
parent 50fc7327f2
commit 64e1d3a975
2 changed files with 20 additions and 8 deletions

View File

@ -17,6 +17,13 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
import random import random
COMMANDS = [
b"GET",
b"PUT",
b"DEL",
]
def init(seed): def init(seed):
''' '''
Called once when AFLFuzz starts up. Used to seed our RNG. Called once when AFLFuzz starts up. Used to seed our RNG.
@ -48,8 +55,9 @@ def fuzz(buf, add_buf, max_size):
@rtype: bytearray @rtype: bytearray
@return: A new bytearray containing the mutated data @return: A new bytearray containing the mutated data
''' '''
ret = bytearray(buf) ret = bytearray(100)
# Do something interesting with ret
ret[:3] = random.choice(COMMANDS)
return ret return ret

View File

@ -894,9 +894,13 @@ test -d ../unicorn_mode/unicornafl && {
} }
$ECHO "$BLUE[*] Testing: custom mutator" $ECHO "$BLUE[*] Testing: custom mutator"
unset AFL_CC # Line 474 sets AFL_CC to "gcc". We reset it to use the default compiler unset AFL_CC # Test case "gcc_plugin" sets AFL_CC to "gcc". We reset it to use the default compiler
CUSTOM_MUTATOR_PATH=$( realpath ../examples/custom_mutators ) test `uname -s` = 'Darwin' && {
test -e test-custom-mutator.c -a -e ${CUSTOM_MUTATOR_PATH}/example.c -a -e ${CUSTOM_MUTATOR_PATH}/example.c && { CUSTOM_MUTATOR_PATH=$( realpath ../examples/custom_mutators )
} || {
CUSTOM_MUTATOR_PATH=$( readlink -f ../examples/custom_mutators )
}
test -e test-custom-mutator.c -a -e ${CUSTOM_MUTATOR_PATH}/example.c -a -e ${CUSTOM_MUTATOR_PATH}/example.py && {
# Compile the vulnerable program # Compile the vulnerable program
../afl-clang-fast -o test-custom-mutator test-custom-mutator.c > /dev/null 2>&1 ../afl-clang-fast -o test-custom-mutator test-custom-mutator.c > /dev/null 2>&1
# Compile the custom mutator # Compile the custom mutator
@ -904,7 +908,7 @@ test -e test-custom-mutator.c -a -e ${CUSTOM_MUTATOR_PATH}/example.c -a -e ${CUS
test -e test-custom-mutator -a -e ${CUSTOM_MUTATOR_PATH}/libexamplemutator.so && { test -e test-custom-mutator -a -e ${CUSTOM_MUTATOR_PATH}/libexamplemutator.so && {
# Create input directory # Create input directory
mkdir -p in mkdir -p in
echo 00000 > in/in echo "00000" > in/in
# Run afl-fuzz w/ the C mutator # Run afl-fuzz w/ the C mutator
$ECHO "$GREY[*] running afl-fuzz for the C mutator, this will take approx 10 seconds" $ECHO "$GREY[*] running afl-fuzz for the C mutator, this will take approx 10 seconds"
@ -915,7 +919,7 @@ test -e test-custom-mutator.c -a -e ${CUSTOM_MUTATOR_PATH}/example.c -a -e ${CUS
} >>errors 2>&1 } >>errors 2>&1
# Check results # Check results
test -n "$( ls out/queue/id:000001* 2>/dev/null )" && { # TODO: update here test -n "$( ls out/crashes/id:000000* 2>/dev/null )" && { # TODO: update here
$ECHO "$GREEN[+] afl-fuzz is working correctly with the C mutator" $ECHO "$GREEN[+] afl-fuzz is working correctly with the C mutator"
} || { } || {
echo CUT------------------------------------------------------------------CUT echo CUT------------------------------------------------------------------CUT
@ -939,7 +943,7 @@ test -e test-custom-mutator.c -a -e ${CUSTOM_MUTATOR_PATH}/example.c -a -e ${CUS
} >>errors 2>&1 } >>errors 2>&1
# Check results # Check results
test -n "$( ls out/queue/id:000001* 2>/dev/null )" && { # TODO: update here test -n "$( ls out/crashes/id:000000* 2>/dev/null )" && { # TODO: update here
$ECHO "$GREEN[+] afl-fuzz is working correctly with the Python mutator" $ECHO "$GREEN[+] afl-fuzz is working correctly with the Python mutator"
} || { } || {
echo CUT------------------------------------------------------------------CUT echo CUT------------------------------------------------------------------CUT