{"id":13515587,"url":"https://github.com/andreafioraldi/frida-fuzzer","last_synced_at":"2025-04-05T09:06:29.170Z","repository":{"id":43820249,"uuid":"222563750","full_name":"andreafioraldi/frida-fuzzer","owner":"andreafioraldi","description":"This experimetal fuzzer is meant to be used for API in-memory fuzzing.","archived":false,"fork":false,"pushed_at":"2020-06-22T15:19:40.000Z","size":4109,"stargazers_count":563,"open_issues_count":10,"forks_count":93,"subscribers_count":20,"default_branch":"master","last_synced_at":"2024-05-21T06:12:29.474Z","etag":null,"topics":["afl","api","frida","fuzzing"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/andreafioraldi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-11-18T23:17:48.000Z","updated_at":"2024-05-10T10:06:21.000Z","dependencies_parsed_at":"2022-07-09T01:30:29.189Z","dependency_job_id":null,"html_url":"https://github.com/andreafioraldi/frida-fuzzer","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreafioraldi%2Ffrida-fuzzer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreafioraldi%2Ffrida-fuzzer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreafioraldi%2Ffrida-fuzzer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreafioraldi%2Ffrida-fuzzer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andreafioraldi","download_url":"https://codeload.github.com/andreafioraldi/frida-fuzzer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247312077,"owners_count":20918344,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["afl","api","frida","fuzzing"],"created_at":"2024-08-01T05:01:13.161Z","updated_at":"2025-04-05T09:06:29.136Z","avatar_url":"https://github.com/andreafioraldi.png","language":"JavaScript","funding_links":[],"categories":["Fuzzing","JavaScript","JavaScript (485)"],"sub_categories":[],"readme":"# Frida API Fuzzer\n\n\u003e v1.4 Copyright (C) 2020 Andrea Fioraldi \u003candreafioraldi@gmail.com\u003e\n\u003e \n\u003e Released under the Apache License v2.0\n\nThis experimental fuzzer is meant to be used for API in-memory fuzzing.\n\nThe design is highly inspired and based on AFL/AFL++.\n\nATM the mutator is quite simple, just the AFL's havoc and splice stages.\n\nI tested only the examples under tests/, this is a WIP project but is known to works at least on GNU/Linux x86_64 and Android x86_64.\n\nYou need Frida \u003e= 12.8.1 to run this (`pip3 install -U frida`) and frida-tools to compile the harness.\n\n## Usage\n\nThe `fuzz` library has to be imported into a custom harness and then compiled with `frida-compile` to generate the agent that `frida-fuzzer` will inject into the target app.\n\nThe majority of the logic of the fuzzer is in the agent.\n\nA harness has the following format:\n\n```js\nvar fuzz = require(\"./fuzz\");\n\nvar TARGET_MODULE = \"test_linux64\";\nvar TARGET_FUNCTION = DebugSymbol.fromName(\"target_func\").address;;\nvar RET_TYPE = \"void\";\nvar ARGS_TYPES = ['pointer', 'int'];\n\nvar func_handle = new NativeFunction(TARGET_FUNCTION, RET_TYPE, ARGS_TYPES, { traps: 'all' });\n\nfuzz.target_module = TARGET_MODULE;\n\nvar payload_mem = Memory.alloc(fuzz.config.MAX_FILE);\n\nfuzz.fuzzer_test_one_input = function (/* Uint8Array */ payload) {\n\n  Memory.writeByteArray(payload_mem, payload, payload.length);\n\n  func_handle(payload_mem, payload.length);\n\n}\n```\n\n`fuzz.fuzzer_test_one_input` is mandatory. If you don't specify `fuzz.target_module`, all the code executed will be instrumented.\n\nYou can also set `fuzz.manual_loop_start = true` to tell the fuzzer that you will call `fuzz.fuzzing_loop()` in a callback and so it must not call it for you (e.g. to start fuzzing when a button is clicked in the Android app).\n\nThe callback `fuzz.init_callback` can be set to execute code when the fuzzer is ready to begin. See `tests/test_java.js` for an example.\n\n`fuzz.dictionary` is a classic fuzzer dictionary, an array in which you can add items (accepted types are Array, ArrayBuffer, Uint8Array, String) that are used as additional values in the mutator. See `tests/test_libxml2.js` for an example.\n\n`frida-fuzzer` accepts the following arguments:\n\n\u003ctable\u003e\n    \u003ctr\u003e\n        \u003ctd\u003e-i FOLDER\u003c/td\u003e\n        \u003ctd\u003eFolder with initial seeds\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003ctd\u003e-o FOLDER\u003c/td\u003e\n        \u003ctd\u003eOutput folder with intermediate seeds and crashes\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003ctd\u003e-U\u003c/td\u003e\n        \u003ctd\u003eConnect to USB\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003ctd\u003e-spawn\u003c/td\u003e\n        \u003ctd\u003eSpawn and attach instead of simply attach\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003ctd\u003e-script SCRIPT\u003c/td\u003e\n        \u003ctd\u003eScript filename (default is fuzzer-agent.js)\u003c/td\u003e\n    \u003c/tr\u003e\n\u003c/table\u003e\n\nIf you don't specify the output folder, a temp folder is created under /tmp.\nIf you don't specify the folder with the initial seed, an uninformed seed `0000` is used as starting seed.\n\nIf you are fuzzing a local application, you may want to execute `system-config` before `frida-fuzzer` to tune the parameters of your system and speed-up the things.\n\nRunning `./frida-fuzzer -spawn ./tests/test_linux64` you will see something like the following status screen on your terminal:\n\n![screen](assets/screen.png)\n\nYou can also easily add a custom stage in `fuzz/fuzzer.js` and add it to the stages list in `fuzz/index.js`.\n\nTo customize the fuzzer, edit `fuzz/config.js`.\nThe variables that you may want to change are MAP_SIZE (If the code that you are fuzzing is small you can reduce it and gain a bit of speed), MAX_FILE (the maximum size of generated input) and QUEUE_CACHE_MAX_SIZE (increase the queue cache size for more speed, especially on Android).\n\n## Example\n\nLet's fuzz the native shared library in the example Android app in `tests`.\n\nMake sure you have root on your virtual device:\n\n```\nhost$ adb root\n```\n\nDownload the Android x86_64 frida-server from the repo release page and copy it\non the device under /data/local/tmp (use adb push).\n\nStart a shell and run the frida-server:\n\n```\ndevice# cd /data/local/tmp\ndevice# ./frida-server\n```\n\nNow install the test app `tests/app-debug.apk` using the drag \u0026 drop into the emulator window.\n\nThen, open the app.\n\nCompile the agent script wiht frida-compile:\n\n```\nhost$ frida-compile -x tests/test_ndk_x64.js -o fuzzer-agent.js\n```\n\nOpen the app in the emulator.\n\nFuzz the `test_func` function of the `libnative-lib.so` library shipped with the test app\nwith the command:\n\n```\nhost$ ./frida-fuzzer -U -o output_folder/ com.example.ndktest1\n```\n\nInteresting testcases and crashes are both saved into output_folder.\n\nEnjoy.\n\n![screen1](assets/screen1.png)\n\n## TODO\n\nHey OSS community, there are a lot of TODOs if someone wants to contribute.\n\n+ ~~Java code fuzzing (waiting for additional exposed methods in frida-java-bridge, should be easy, almost done)~~\n+ ~~splice stage (merge two testcase in queue and apply havoc on it)~~\n+ ~~support dictionaries (and so modify also havoc)~~\n+ ~~seed selection~~\n+ inlined instrumentation for arm64\n+ performance scoring (explore schedule of AFL)\n+ structural mutator (mutate bytes based on a grammar written in JSON)\n+ CompareCoverage (sub-instruction profiling to bypass fuzzing roadblocks)\n+ rewrite frida-fuzzer in C with frida-core to be able to run all stuff on the mobile device\n\nIf you have doubt on one of this featues feel free to DM me on [Twitter](https://twitter.com/andreafioraldi).\n\nFor features proposals, there is the [Issues section](https://github.com/andreafioraldi/frida-fuzzer/issues).\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandreafioraldi%2Ffrida-fuzzer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandreafioraldi%2Ffrida-fuzzer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandreafioraldi%2Ffrida-fuzzer/lists"}