1717 $ rm -fr afl_outputs/default/
1818"""
1919
20- # This is new. Instead of unicorn, we import unicornafl. It's the same Uc with some new `afl_` functions
21- import unicornafl as UcAfl
22-
23- # Make sure Qiling uses our patched unicorn instead of it's own, second so without instrumentation!
24- UcAfl .monkeypatch ()
20+ # This uses the new unicornafl, which no longer provides any Unicorn stuff so we have to import by our own.
21+ from unicornafl import *
22+ from unicorn import *
2523
2624import os
2725import sys
@@ -43,7 +41,7 @@ def main(input_file: str):
4341 stdout = None ,
4442 stderr = None )
4543
46- def place_input_callback (uc : UcAfl . Uc , input : bytes , persistent_round : int , data : Any ) -> Optional [bool ]:
44+ def place_input_callback (uc : Uc , input : bytes , persistent_round : int , data : Any ) -> Optional [bool ]:
4745 """Called with every newly generated input.
4846 """
4947
@@ -56,16 +54,17 @@ def start_afl(_ql: Qiling):
5654 # We start our AFL forkserver or run once if AFL is not available.
5755 # This will only return after the fuzzing stopped.
5856 try :
59- if not _ql .uc .afl_fuzz (input_file = input_file , place_input_callback = place_input_callback , exits = [ql .os .exit_point ]):
57+ # _ql.uc.afl_fuzz shall also work, but just for compatibility with old unicornafl
58+ if not uc_afl_fuzz (_ql .uc , input_file = input_file , place_input_callback = place_input_callback , exits = [ql .os .exit_point ]):
6059 _ql .log .warning ("Ran once without AFL attached" )
6160 os ._exit (0 )
6261
63- except UcAfl . UcAflError as ex :
62+ except UcAflError as ex :
6463 # This hook triggers more than once in this example.
6564 # If this is the exception cause, we don't care.
6665
6766 # TODO: choose a better hook position :)
68- if ex .errno != UcAfl . UC_AFL_RET_CALLED_TWICE :
67+ if ex .errno != UC_AFL_RET_CALLED_TWICE :
6968 raise
7069
7170 # get image base address
0 commit comments