summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbuild_native.sh22
-rw-r--r--ent.xml14
-rwxr-xr-xsrc/common.h4
-rw-r--r--src/main.c31
4 files changed, 62 insertions, 9 deletions
diff --git a/build_native.sh b/build_native.sh
new file mode 100755
index 0000000..12ec3b9
--- /dev/null
+++ b/build_native.sh
@@ -0,0 +1,22 @@
+#!/bin/bash
+
+cat js/*.js > exp.js
+echo >> exp.js
+echo "main();" >> exp.js
+
+# build for host
+gcc -I $(pwd)/inc/ \
+ src/main.c \
+ src/ip_tools.c \
+ src/stage0_primitives.c \
+ src/stage1_primitives.c \
+ src/patchfinder.c \
+ src/stage2.c \
+ src/shit.c \
+ -o bin/main_arm \
+ -D__WHOAMI__="\"$(whoami)\"" \
+ -D__PWD__="\"$(pwd)\"" \
+ -g \
+ --std=c99
+
+ldid -Sent.xml bin/main_arm
diff --git a/ent.xml b/ent.xml
index 2821d0e..f0b0a1e 100644
--- a/ent.xml
+++ b/ent.xml
@@ -1,8 +1,8 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
- <key>get-task-allow</key>
- <true/>
-</dict>
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>get-task-allow</key>
+ <true/>
+</dict>
</plist> \ No newline at end of file
diff --git a/src/common.h b/src/common.h
index 8f5a32b..9550400 100755
--- a/src/common.h
+++ b/src/common.h
@@ -12,4 +12,6 @@ struct racoon_offsets {
extern char* fuck_memory_leaks;
-#endif \ No newline at end of file
+void* memmem(const void *l, size_t l_len, const void *s, size_t s_len);
+
+#endif
diff --git a/src/main.c b/src/main.c
index c3df450..c3e4077 100644
--- a/src/main.c
+++ b/src/main.c
@@ -11,7 +11,6 @@
#include <string.h>
#include <stdio.h>
-
#include "stage1_primitives.h"
#include "stage0_primitives.h"
#include "patchfinder.h"
@@ -23,6 +22,36 @@
uint32_t DNS4_OFFSET;
uint32_t LC_CONF_OFFSET;
+// https://opensource.apple.com/source/Libc/Libc-825.26/string/FreeBSD/memmem.c.auto.html
+void *
+memmem(const void *l, size_t l_len, const void *s, size_t s_len)
+{
+ register char *cur, *last;
+ const char *cl = (const char *)l;
+ const char *cs = (const char *)s;
+
+ /* we need something to compare */
+ if (l_len == 0 || s_len == 0)
+ return NULL;
+
+ /* "s" must be smaller or equal to "l" */
+ if (l_len < s_len)
+ return NULL;
+
+ /* special case where s_len == 1 */
+ if (s_len == 1)
+ return memchr(l, (int)*cs, l_len);
+
+ /* the last position where its possible to find "s" in "l" */
+ last = (char *)cl + l_len - s_len;
+
+ for (cur = (char *)cl; cur <= last; cur++)
+ if (cur[0] == cs[0] && memcmp(cur, cs, s_len) == 0)
+ return cur;
+
+ return NULL;
+}
+
char* fuck_memory_leaks = NULL;
FILE* fp = NULL;