AFLplusplus / AFLplusplus/LibAFL

elf.entry_point() for no-aslr binary

Open
#3,745 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
2.6k
Forks
481
Avg merge
2d 30m
Merged PRs (30d)
16

Description

## Problem
I'm new to LibAFL and I'm trying to work on a no-aslr binary, it's elf header type is EXEC, not DYN. And here is part of my code
```rust
fn get_elf_entry_point(qemu: Qemu) -> Result {
let mut elf_buffer = Vec::new();
let elf = EasyElf::from_file(qemu.binary_path(), &mut elf_buffer)?;
let load_addr = qemu.load_addr();
eprintln!("[Harness] ELF Load addr: {load_addr:#x}");
let start_pc = elf
.entry_point(qemu.load_addr())
.expect("Target elf's entry_point should not be None!") as u64;

// 使用 println! 确保能看到输出
eprintln!("[Harness] ELF Entry point calculated: {start_pc:#x}");
Ok(start_pc)
```
The problem is qemu.load_addr() will return 0x400000 and elf.entry_point(qemu.load_addr()) will return 0x802500(expected to be 0x402500).

The definition of elf.entry_point() is
```rust
#[must_use]
pub fn entry_point(&self, load_addr: GuestAddr) -> Option {
if self.elf.entry == 0 {
None
} else {
Some(load_addr + self.elf.entry as GuestAddr)
}
}
```
I wonder if this func need to add `if self.if_pic()` check liker other functions (eg. elf.resolve_symbol, elf.get_section) or just I misuse this function.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.