LibAFL icon indicating copy to clipboard operation
LibAFL copied to clipboard

libafl-frida stalker miss many blocks?

Open icepng opened this issue 3 years ago • 5 comments

I try to fuzz android library based libafl-frida. I write a harness library which uses dlopen to load the target library.

When fuzzing, I use frida to hook one of the functions in target library, and it was hit. However, I print all block addresses in stalker transformer , the addresses in that function are not found.

I try to use javascript interface of stalker based frida-server, and everything seems good. I guessed it's the problem of frida-gum of rust. Anyone encounters the same problem?

icepng avatar Sep 23 '22 07:09 icepng

Did you specify that the target library be instrumented using the ‘-l’ flag?

s1341 avatar Sep 23 '22 07:09 s1341

I use the -l flag. I found some functions in target library were hit.

icepng avatar Sep 23 '22 07:09 icepng

do you have a minimal PoC so that we can reproduce?

tokatoka avatar Sep 23 '22 17:09 tokatoka

I test it in samsung phone, the target library needed some libs of the samsung phone. And I found it's not the problem of libafl. The problem is the achievement of frida stalker exclude function (frida-gum), I didn't know the reason why the stalker exclude works fail on my target, and i solved it by commenting on it, and this problem also exists in afl++ frida mode.

icepng avatar Sep 25 '22 13:09 icepng

thanks for the info so you mean these lines?

        for range in ranges.gaps(&(0..usize::MAX)) {
            println!("excluding range: {:x}-{:x}", range.start, range.end);
            stalker.exclude(&MemoryRange::new(
                NativePointer(range.start as *mut c_void),
                range.end - range.start,
            ));
        }

tokatoka avatar Sep 25 '22 14:09 tokatoka

thanks for the info so you mean these lines?

        for range in ranges.gaps(&(0..usize::MAX)) {
            println!("excluding range: {:x}-{:x}", range.start, range.end);
            stalker.exclude(&MemoryRange::new(
                NativePointer(range.start as *mut c_void),
                range.end - range.start,
            ));
        }

Sure, I comment stalker.exclude

icepng avatar Sep 26 '22 09:09 icepng

so it's not our issue, then I'll close this

tokatoka avatar Sep 27 '22 20:09 tokatoka

This is the result of leaving out some -l arguments. There must be a clear line of execution from every function you want stalked back to the entry point. This is is because of how frida-stalker works.

s1341 avatar Sep 28 '22 05:09 s1341