mirror of
https://github.com/AFLplusplus/AFLplusplus.git
synced 2025-06-11 09:41:35 +00:00
Merge pull request #1118 from devnexen/frida_android_build_upd
frida mode android build fix proposal.
This commit is contained in:
commit
88bcc34802
@ -80,6 +80,22 @@ ifeq "$(shell uname)" "Linux"
|
||||
OS:=linux
|
||||
endif
|
||||
|
||||
ifneq "$(findstring android, $(shell $(CC) --version 2>/dev/null))" ""
|
||||
OS:=android
|
||||
ifneq "$(findstring aarch64, $(shell $(CC) --version 2>/dev/null))" ""
|
||||
ARCH:=arm64
|
||||
endif
|
||||
ifneq "$(findstring arm, $(shell $(CC) --version 2>/dev/null))" ""
|
||||
ARCH:=arm
|
||||
endif
|
||||
ifneq "$(findstring x86_64, $(shell $(CC) --version 2>/dev/null))" ""
|
||||
ARCH:=x86_64
|
||||
endif
|
||||
ifneq "$(findstring i686, $(shell $(CC) --version 2>/dev/null))" ""
|
||||
ARCH:=x86
|
||||
endif
|
||||
endif
|
||||
|
||||
ifndef OS
|
||||
$(error "Operating system unsupported")
|
||||
endif
|
||||
|
@ -55,6 +55,20 @@ tests in 32-bit mode, run `make ARCH=x86 frida`. When switching between
|
||||
architectures it may be necessary to run `make clean` first for a given build
|
||||
target to remove previously generated binaries for a different architecture.
|
||||
|
||||
### Android
|
||||
|
||||
In order to build, you need to download the Android SDK.
|
||||
|
||||
```
|
||||
https://developer.android.com/ndk/downloads
|
||||
```
|
||||
|
||||
Then creating locally a standalone chain as follow.
|
||||
|
||||
```
|
||||
https://developer.android.com/ndk/guides/standalone_toolchain
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
FRIDA mode added some small modifications to `afl-fuzz` and similar tools
|
||||
|
@ -4,8 +4,12 @@
|
||||
#include <sys/shm.h>
|
||||
|
||||
#if defined(__linux__)
|
||||
#if !defined(__ANDROID__)
|
||||
#include <asm/prctl.h>
|
||||
#include <sys/syscall.h>
|
||||
#else
|
||||
#include <linux/ashmem.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include "frida-gumjs.h"
|
||||
@ -156,8 +160,16 @@ static void instrument_coverage_optimize_map_mmap(char * shm_file_path,
|
||||
|
||||
__afl_area_ptr = NULL;
|
||||
|
||||
#if !defined(__ANDROID__)
|
||||
shm_fd = shm_open(shm_file_path, O_RDWR, DEFAULT_PERMISSION);
|
||||
if (shm_fd == -1) { FATAL("shm_open() failed\n"); }
|
||||
#else
|
||||
shm_fd = open("/dev/ashmem", O_RDWR);
|
||||
if (shm_fd == -1) { FATAL("open() failed\n"); }
|
||||
if (ioctl(shm_fd, ASHMEM_SET_NAME, shm_file_path) == -1) { FATAL("ioctl(ASHMEM_SET_NAME) failed"); }
|
||||
if (ioctl(shm_fd, ASHMEM_SET_SIZE, __afl_map_size) == -1) { FATAL("ioctl(ASHMEM_SET_SIZE) failed"); }
|
||||
|
||||
#endif
|
||||
|
||||
__afl_area_ptr = mmap(address, __afl_map_size, PROT_READ | PROT_WRITE,
|
||||
MAP_FIXED_NOREPLACE | MAP_SHARED, shm_fd, 0);
|
||||
|
@ -1,4 +1,4 @@
|
||||
#ifndef __APPLE__
|
||||
#if defined(__linux__) && !defined(__ANDROID__)
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
|
@ -1,4 +1,4 @@
|
||||
#ifndef __APPLE__
|
||||
#if defined(__linux__) && !defined(__ANDROID__)
|
||||
|
||||
#include <execinfo.h>
|
||||
#include <fcntl.h>
|
||||
|
@ -1,4 +1,4 @@
|
||||
#ifndef __APPLE__
|
||||
#if defined(__linux__) && !defined(__ANDROID__)
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <sched.h>
|
||||
|
@ -1,4 +1,4 @@
|
||||
#ifndef __APPLE__
|
||||
#if defined(__linux__) && !defined(__ANDROID__)
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
@ -1,4 +1,4 @@
|
||||
#ifndef __APPLE__
|
||||
#if defined(__linux__) && !defined(__ANDROID__)
|
||||
|
||||
#include <alloca.h>
|
||||
#include <errno.h>
|
||||
|
@ -1,4 +1,4 @@
|
||||
#ifndef __APPLE__
|
||||
#if defined(__linux__) && !defined(__ANDROID__)
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
#ifndef __APPLE__
|
||||
#if defined(__linux__) && !defined(__ANDROID__)
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
@ -1,4 +1,4 @@
|
||||
#ifndef __APPLE__
|
||||
#if defined(__linux__) && !defined(__ANDROID__)
|
||||
|
||||
#include <limits.h>
|
||||
#include <stdio.h>
|
||||
|
Loading…
x
Reference in New Issue
Block a user