Skip to content

Instantly share code, notes, and snippets.

@ant4g0nist
Last active Jun 19, 2021
Embed
What would you like to do?
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := libhwui
LOCAL_SRC_FILES := /android/rootfs/system/lib64/libhwui.so
include $(PREBUILT_SHARED_LIBRARY)
### build your lib ###
include $(CLEAR_VARS)
LOCAL_LDLIBS := -lhwui -L/android/rootfs/system/lib64/
LOCAL_MODULE := libBooFuzz
LOCAL_SRC_FILES := lib/fuzz.cpp
include $(BUILD_SHARED_LIBRARY)
# ### build the main ###
include $(CLEAR_VARS)
LOCAL_LDLIBS := -llog -landroidicu -lz -lGLESv1_CM -lGLESOverlay -lEGL -lGLESv3 -lBooFuzz -L../libs/arm64-v8a/ -landroidicu -lhwui -L/android/rootfs/system/lib64/ -Wl,-rpath-link=/android/rootfs/system/lib64/ -Wl,--dynamic-linker=/android/rootfs/system/bin/linker64
LOCAL_MODULE := boofuzz
LOCAL_SRC_FILES := boo.cpp
include $(BUILD_EXECUTABLE)
APP_MODULES := libBooFuzz boofuzz
APP_ABI := arm64-v8a
#include "lib/fuzz.h"
#include <stdio.h>
int main(int argc, char** argv) {
// libQemuFuzzerTestOneInput((const uint8_t*)&"voila", 10);
const uint8_t data = 0;
libQemuFuzzerTestOneInput(&data, 1);
}
// lib/fuzz.cpp
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include "fuzz.h"
extern "C" int libQemuFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
if (Size <5 && Size > 4096)
return 0;
if(Data[0] == 0x41)
{
if(Data[1] == 0x42)
{
if(Data[2] == 0x43)
{
if(Data[4] == 0x44)
{
if(Data[5] == 0x45)
{
char * ptr = (char*) 0x61616161;
ptr[0]=0;
}
}
}
}
}
return 0;
}
build:
ndk-build
root@4558d8a05c92:/android/examples/Sample# ls
jni  libs  obj  seeds
root@4558d8a05c92:/android/examples/Sample# cd jni/
root@4558d8a05c92:/android/examples/Sample/jni# ls
Android.mk  Application.mk  Makefile  boo.cpp  lib
root@4558d8a05c92:/android/examples/Sample/jni# ls lib/
fuzz.cpp  fuzz.h  include

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment