mirror of
https://github.com/AFLplusplus/AFLplusplus.git
synced 2025-06-13 18:48:08 +00:00
Merge pull request #1118 from devnexen/frida_android_build_upd
frida mode android build fix proposal.
This commit is contained in:
@ -80,6 +80,22 @@ ifeq "$(shell uname)" "Linux"
|
|||||||
OS:=linux
|
OS:=linux
|
||||||
endif
|
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
|
ifndef OS
|
||||||
$(error "Operating system unsupported")
|
$(error "Operating system unsupported")
|
||||||
endif
|
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
|
architectures it may be necessary to run `make clean` first for a given build
|
||||||
target to remove previously generated binaries for a different architecture.
|
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
|
## Usage
|
||||||
|
|
||||||
FRIDA mode added some small modifications to `afl-fuzz` and similar tools
|
FRIDA mode added some small modifications to `afl-fuzz` and similar tools
|
||||||
|
@ -4,8 +4,12 @@
|
|||||||
#include <sys/shm.h>
|
#include <sys/shm.h>
|
||||||
|
|
||||||
#if defined(__linux__)
|
#if defined(__linux__)
|
||||||
|
#if !defined(__ANDROID__)
|
||||||
#include <asm/prctl.h>
|
#include <asm/prctl.h>
|
||||||
#include <sys/syscall.h>
|
#include <sys/syscall.h>
|
||||||
|
#else
|
||||||
|
#include <linux/ashmem.h>
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "frida-gumjs.h"
|
#include "frida-gumjs.h"
|
||||||
@ -156,8 +160,16 @@ static void instrument_coverage_optimize_map_mmap(char * shm_file_path,
|
|||||||
|
|
||||||
__afl_area_ptr = NULL;
|
__afl_area_ptr = NULL;
|
||||||
|
|
||||||
|
#if !defined(__ANDROID__)
|
||||||
shm_fd = shm_open(shm_file_path, O_RDWR, DEFAULT_PERMISSION);
|
shm_fd = shm_open(shm_file_path, O_RDWR, DEFAULT_PERMISSION);
|
||||||
if (shm_fd == -1) { FATAL("shm_open() failed\n"); }
|
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,
|
__afl_area_ptr = mmap(address, __afl_map_size, PROT_READ | PROT_WRITE,
|
||||||
MAP_FIXED_NOREPLACE | MAP_SHARED, shm_fd, 0);
|
MAP_FIXED_NOREPLACE | MAP_SHARED, shm_fd, 0);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#ifndef __APPLE__
|
#if defined(__linux__) && !defined(__ANDROID__)
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#ifndef __APPLE__
|
#if defined(__linux__) && !defined(__ANDROID__)
|
||||||
|
|
||||||
#include <execinfo.h>
|
#include <execinfo.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#ifndef __APPLE__
|
#if defined(__linux__) && !defined(__ANDROID__)
|
||||||
|
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <sched.h>
|
#include <sched.h>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#ifndef __APPLE__
|
#if defined(__linux__) && !defined(__ANDROID__)
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#ifndef __APPLE__
|
#if defined(__linux__) && !defined(__ANDROID__)
|
||||||
|
|
||||||
#include <alloca.h>
|
#include <alloca.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#ifndef __APPLE__
|
#if defined(__linux__) && !defined(__ANDROID__)
|
||||||
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#ifndef __APPLE__
|
#if defined(__linux__) && !defined(__ANDROID__)
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#ifndef __APPLE__
|
#if defined(__linux__) && !defined(__ANDROID__)
|
||||||
|
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
Reference in New Issue
Block a user