Open dzonerzy opened 2 years ago
The fuzzer won't be able to brute-force 32 bit values, usually. You can try to hand the values as token/dictionary to AFL and it should work. Alternatively, switch to QEMU mode and use complog or wait for upstream unicorn to fix CMP hooks, cc @wtdcode
Could you have a retry now?
Sure I'll let you know once tested.
I tried after updating I'm having a different issue now, here's the code:
import os
import sys
from qiling import Qiling
from qiling.const import QL_VERBOSE
from qiling.extensions.afl import ql_afl_fuzz
def start_afl(ql: Qiling, user_data):
def place_input_callback(_ql: Qiling, fuzzed: bytes, persistent_round: int):
size = len(fuzzed)
mem = _ql.reg.read("r0") # here r0 should point to buffer, instead I get 0, seems like uc context is lost
_ql.reg.write("r1", size)
_ql.mem.write(mem, fuzzed)
return True
try:
ql_afl_fuzz(ql, input_file=user_data, place_input_callback=place_input_callback, exits=[ql.os.exit_point])
except:
os.abort()
def emulate(binary, rootfs, fuzzed_binary):
ql = Qiling(binary, rootfs, verbose=QL_VERBOSE.DEBUG)
ql.restore(snapshot="./snap.bin")
ql.hook_address(start_afl, 0x00010b30, user_data=fuzzed_binary)
ql.emu_start(begin=0x00010b30, end=0x0010b34)
if __name__ == "__main__":
emulate(["./test", "./pier"], "./rootfs", sys.argv[1])
Inside the place_input_callback callback the Qiling context seems wrong, in fact r0 register inside the start_afl callback point to the buffer while inside the place_input_callback is zero. That wasn't happening with the previous version. cc @wtdcode
Any updates on this?
Basically i created a vulnerable binary and linked it against uclib-ng (arm-eabihf), below the source code:
Then i created a simple qiling script which make first a snapshot the use the snapshot to fuzz the parsing function
Anyway seems like after 5 completed cycles it still can't find the vulnerable path, while forcing it into place_input_callback just works fine and make afl register the crash.
I run afl with
AFL_DEBUG=1 afl-fuzz -D -U -i input/ -o output/ -- python3 main.py @@
test-arm.tar.gz