Skip to content

UnicornAFL v3 #43

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 110 commits into
base: main
Choose a base branch
from
Open

UnicornAFL v3 #43

wants to merge 110 commits into from

Conversation

wtdcode
Copy link
Member

@wtdcode wtdcode commented May 17, 2025

It is almost there! I just added maturin support, and the API should be the same with previous versions. The only things we left are:

  • CI distribution Support
  • C bindings
  • Documents!

@wtdcode
Copy link
Member Author

wtdcode commented Jun 10, 2025

what the heck manylinux only has clang-3/5 =(

@wtdcode
Copy link
Member Author

wtdcode commented Jun 10, 2025

Fixed up python bindings & CI!

We need a python example as well to test it really works. Maybe just copy the same harness from the rust sample. @Evian-Zhang Would you like to do this?

@Evian-Zhang
Copy link
Contributor

Sure, I have created a Python sample, but found out that the Python binding have many bugs... See #48 Maybe you could fix those bugs. ❤️

Co-Authored-by: Evian-Zhang <[email protected]>
@wtdcode
Copy link
Member Author

wtdcode commented Jun 11, 2025

Fixed and it works with: AFL_QEMU_CUSTOM_BIN=1 AFL_I_DONT_CARE_ABOUT_MISSING_CRASHES=1 AFL_SKIP_CPUFREQ=1 ~/opensource/AFLplusplus/afl-fuzz -Q -i ./target/input/ -o ./target/output -c 0 -- python3 ./examples/sample.py @@, i.e. no longer need unicorn mode.

@domenukk
Copy link
Member

All unicorn mode does is set SKIP_BIN_CHECK IIRC.

@wtdcode
Copy link
Member Author

wtdcode commented Jun 11, 2025

All unicorn mode does is set SKIP_BIN_CHECK IIRC.

check_binary is skipped automatically by afl-fuzz.

btw, check AFLplusplus/AFLplusplus#2468

@wtdcode
Copy link
Member Author

wtdcode commented Jun 11, 2025

*QEMU mode was used above because AFL++ explicity prevents us from using cmplog for unicorn mode.

@domenukk
Copy link
Member

Ah, well, we should patch afl++ then

ctypes.cast(cb2, ctypes.c_void_p).value,
always_validate,
persistent_iters,
ctypes.cast(idx, ctypes.c_void_p)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for intruding, but is it possible that is should be this:

Suggested change
ctypes.cast(idx, ctypes.c_void_p)
ctypes.cast(idx, ctypes.c_void_p).value

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch. Thanks.

exits_array, ctypes.c_void_p), exits_len, cb2, always_validate, persistent_iters, ctypes.cast(idx, ctypes.c_void_p))

if isinstance(input_file, str):
input_file = input_file.encode('utf-8')
Copy link

@rliebig rliebig Jun 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
input_file = input_file.encode('utf-8')
input_file = input_file.encode('utf-8') + b"\x00"

This does not seem sufficient - python_str.encode does not garantee null termination of the string buffer. I believe that that we must manually add a single zero byte to ensure that the string can be decoded by CStr::from_ptr(). Another valid path would be ctypes.create_string_buffer but that would not improve readability.

@wtdcode
Copy link
Member Author

wtdcode commented Jun 13, 2025 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants