diff options
author | WorksButNotTested <62701594+WorksButNotTested@users.noreply.github.com> | 2021-04-28 09:25:26 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-28 10:25:26 +0200 |
commit | 39ad3b89467d6de12cbb9d08ccd77d331c0d1f9e (patch) | |
tree | 18bdf509d47e0d971bd9d7faf56d27758b23b09c /frida_mode/src/util.c | |
parent | 8da5cba4012080afca5e7f7da9aaa6aa6e263f3e (diff) | |
download | afl++-39ad3b89467d6de12cbb9d08ccd77d331c0d1f9e.tar.gz |
Frida persistent (#880)
* Added x64 support for persistent mode (function call only), in-memory teest cases and complog * Review changes, fix NeverZero and code to parse the .text section of the main executable. Excluded ranges TBC * Various minor fixes and finished support for AFL_INST_LIBS * Review changes Co-authored-by: Your Name <you@example.com>
Diffstat (limited to 'frida_mode/src/util.c')
-rw-r--r-- | frida_mode/src/util.c | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/frida_mode/src/util.c b/frida_mode/src/util.c new file mode 100644 index 00000000..f42afd64 --- /dev/null +++ b/frida_mode/src/util.c @@ -0,0 +1,66 @@ +#include "util.h" + +#include "debug.h" + +guint64 util_read_address(char *key) { + + char *value_str = getenv(key); + + if (value_str == NULL) { return 0; } + + if (!g_str_has_prefix(value_str, "0x")) { + + FATAL("Invalid address should have 0x prefix: %s\n", value_str); + + } + + value_str = &value_str[2]; + + for (char *c = value_str; *c != '\0'; c++) { + + if (!g_ascii_isxdigit(*c)) { + + FATAL("Invalid address not formed of hex digits: %s\n", value_str); + + } + + } + + guint64 value = g_ascii_strtoull(value_str, NULL, 16); + if (value == 0) { + + FATAL("Invalid address failed hex conversion: %s\n", value_str); + + } + + return value; + +} + +guint64 util_read_num(char *key) { + + char *value_str = getenv(key); + + if (value_str == NULL) { return 0; } + + for (char *c = value_str; *c != '\0'; c++) { + + if (!g_ascii_isdigit(*c)) { + + FATAL("Invalid address not formed of decimal digits: %s\n", value_str); + + } + + } + + guint64 value = g_ascii_strtoull(value_str, NULL, 10); + if (value == 0) { + + FATAL("Invalid address failed numeric conversion: %s\n", value_str); + + } + + return value; + +} + |