Fix libafl_qemu python bindings and example (#2030)

This commit is contained in:
Romain Malmain 2024-04-09 16:09:47 +02:00 committed by GitHub
parent f252469d86
commit 33c6ea1ae4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 25 additions and 2 deletions

View File

@ -0,0 +1,17 @@
# Python LibAFL QEMU
## Build
First, install python bindings (check `LibAFL/bindings/pylibafl`) and use the virtual environment.
Then, create the `in` folder and put some input inside
```bash
$ mkdir in
$ echo aaaaa > in/input
```
## Run
```bash
$ python fuzzer.py
```

View File

@ -6,7 +6,7 @@ import lief
MAX_SIZE = 0x100
BINARY_PATH = './a.out'
emu = qemu.Emulator(['qemu-x86_64', BINARY_PATH], [])
emu = qemu.Qemu(['qemu-x86_64', BINARY_PATH], [])
elf = lief.parse(BINARY_PATH)
test_one_input = elf.get_function_address("LLVMFuzzerTestOneInput")

View File

@ -1813,6 +1813,12 @@ pub mod pybind {
Ok(Qemu { qemu })
}
fn run(&self) {
unsafe {
self.qemu.run().unwrap();
}
}
fn write_mem(&self, addr: GuestAddr, buf: &[u8]) {
unsafe {
self.qemu.write_mem(addr, buf);

View File

@ -209,7 +209,7 @@ where
let mut harness = |input: &BytesInput| {
let target = input.target_bytes();
let buf = target.as_slice();
(harness_bytes)(buf);
harness_bytes(buf);
ExitKind::Ok
};