Skip to content

Commit 14da277

Browse files
RootHideRootHide
RootHide
authored and
RootHide
committed
initial
1 parent 6a876d2 commit 14da277

20 files changed

+3055
-0
lines changed

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.vscode
2+
.theos
3+
packages
4+
libvroot.h

Makefile

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
2+
ARCHS = arm64 arm64e
3+
TARGET := iphone:clang:latest:15.0
4+
#THEOS_PACKAGE_SCHEME=rootless
5+
6+
THEOS_PLATFORM_DEB_COMPRESSION_TYPE = gzip
7+
8+
include $(THEOS)/makefiles/common.mk
9+
10+
LIBRARY_NAME = libroothide libvroot libvrootapi
11+
12+
libroothide_FILES = jbroot.c jbroot.cpp jbroot.m cache.c common.c
13+
libroothide_LDFLAGS += -install_name @loader_path/.jbroot/usr/lib/libroothide.dylib
14+
libroothide_INSTALL_PATH = /usr/lib
15+
16+
libvroot_FILES = vroot.c vroot_mktemp.c vroot.cpp vroot_rootfs.c common.c
17+
libvroot_CFLAGS += -I./
18+
libvroot_LDFLAGS += -install_name @loader_path/.jbroot/usr/lib/libvroot.dylib -L$(THEOS_OBJ_DIR) -lroothide
19+
libvroot_INSTALL_PATH = /usr/lib
20+
21+
libvrootapi_FILES = vrootapi.c
22+
libvrootapi_LDFLAGS += -install_name @loader_path/.jbroot/usr/lib/libvrootapi.dylib -L$(THEOS_OBJ_DIR) -lvroot
23+
libvrootapi_INSTALL_PATH = /usr/lib
24+
libvrootapi_USE_MODULES = no
25+
include $(THEOS_MAKE_PATH)/library.mk
26+
27+
28+
TOOL_NAME = updatelink symredirect
29+
30+
updatelink_FILES = updatelink.c
31+
updatelink_CFLAGS += -I./
32+
updatelink_LDFLAGS += -L$(THEOS_OBJ_DIR) -lroothide
33+
updatelink_INSTALL_PATH = /usr/libexec
34+
updatelink_CODESIGN_FLAGS = -Sentitlements.plist
35+
36+
symredirect_FILES = symredirect.cpp
37+
symredirect_CFLAGS += -I./ -std=c++11
38+
symredirect_INSTALL_PATH = /usr/bin
39+
symredirect_CODESIGN_FLAGS = -Sentitlements.plist
40+
41+
42+
include $(THEOS_MAKE_PATH)/tool.mk
43+
44+
45+
after-libvroot-all::
46+
$(CPP) vroot.h > libvroot.h
47+
48+
clean::
49+
rm -rf ./packages/*
50+
51+
after-install::
52+
install.exec 'installed'

cache.c

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#include "cache.h"
2+
#include <stdlib.h>
3+
#include <string.h>
4+
5+
const char* cache_path(struct cache_path* cache, const char* path)
6+
{
7+
if(!cache->array) {
8+
static pthread_mutex_t initlock=PTHREAD_MUTEX_INITIALIZER;
9+
pthread_mutex_lock(&initlock);
10+
if(!cache->array) {
11+
pthread_mutex_init(&cache->lock, NULL);
12+
cache->array = malloc(sizeof(cache->array[0])*CACHE_INIT_SIZE);
13+
cache->size = CACHE_INIT_SIZE;
14+
cache->used = 0;
15+
}
16+
pthread_mutex_unlock(&initlock);
17+
}
18+
19+
pthread_mutex_lock(&cache->lock);
20+
21+
const char* cachedpath = NULL;
22+
23+
for(size_t i=0; i<cache->used; i++)
24+
{
25+
if(strcmp(path, cache->array[i])==0) {
26+
cachedpath = cache->array[i];
27+
break;
28+
}
29+
}
30+
31+
if(!cachedpath)
32+
{
33+
cachedpath = strdup(path);
34+
35+
cache->array[cache->used] = cachedpath;
36+
cache->used++;
37+
}
38+
39+
if(cache->used==cache->size)
40+
{
41+
const char** new_cache_array = malloc(sizeof(cache->array[0])*cache->size*2);
42+
43+
memcpy(new_cache_array, cache->array, sizeof(cache->array[0])*cache->size);
44+
45+
free(cache->array);
46+
47+
cache->size = cache->size*2;
48+
cache->used = cache->used;
49+
cache->array = new_cache_array;
50+
}
51+
52+
pthread_mutex_unlock(&cache->lock);
53+
54+
return cachedpath;
55+
}

cache.h

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
#include <pthread.h>
3+
4+
#define CACHE_INIT_SIZE 100
5+
6+
struct cache_path {
7+
pthread_mutex_t lock;
8+
const char** array;
9+
size_t used;
10+
size_t size;
11+
};
12+
13+
const char* cache_path(struct cache_path* cache, const char* path);
14+

common.c

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#include "common.h"
2+
#include <stdlib.h>
3+
#include <string.h>
4+
5+
int is_jbrand_value(uint64_t value)
6+
{
7+
// uint8_t check = value>>8 ^ value >> 16 ^ value>>24 ^ value>>32 ^ value>>40 ^ value>>48 ^ value>>56;
8+
// return check == (uint8_t)value;
9+
return 1;
10+
}
11+
12+
int is_jbroot_name(const char* name)
13+
{
14+
if(strlen(name) != (sizeof(JB_ROOT_PREFIX)-1+JB_RAND_LENGTH))
15+
return 0;
16+
17+
if(strncmp(name, JB_ROOT_PREFIX, sizeof(JB_ROOT_PREFIX)-1) != 0)
18+
return 0;
19+
20+
char* endp=NULL;
21+
unsigned long value = strtoul(name+sizeof(JB_ROOT_PREFIX)-1, &endp, 16);
22+
if(!endp || *endp!='\0')
23+
return 0;
24+
25+
if(!is_jbrand_value(value))
26+
return 0;
27+
28+
return 1;
29+
}

common.h

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
2+
#define JB_ROOT_PARENT "/var"
3+
#define JB_ROOT_PREFIX ".jbroot-"
4+
#define JB_RAND_LENGTH (sizeof(uint64_t)*sizeof(char)*2)
5+
6+
#define ROOTFS_PREFIX "/rootfs"
7+
8+
#define LOG(...)
9+
10+
//#define LOG(...) {char* jbpathlog = getenv("JBROOTLOG"); if((jbpathlog && *jbpathlog)||access("/var/.jbrootlog", F_OK)==0) {printf(__VA_ARGS__);fflush(stdout);}}
11+
12+
#include <sys/syslog.h>
13+
//#define LOG(...) {openlog("roothide",LOG_PID,LOG_AUTH);syslog(LOG_DEBUG, __VA_ARGS__);closelog();}
14+
15+
int is_jbroot_name(const char* name);
16+
17+
#define EXPORT __attribute__ ((visibility ("default")))
18+

control

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Package: com.roothide.jbpath
2+
Name: jbpath
3+
Version: 0.0.1
4+
Architecture: iphoneos-arm64
5+
Description: An awesome tool of some sort!!
6+
Maintainer: roothide
7+
Author: roothide
8+
Section: System
9+
Tag: role::hacker

entitlements.plist

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN http://www.apple.com/DTDs/PropertyList-1.0.dtd">
2+
<plist version="1.0">
3+
<dict>
4+
<key>platform-application</key>
5+
<true/>
6+
<key>com.apple.private.security.no-sandbox</key>
7+
<true/>
8+
<key>com.apple.private.security.storage.AppBundles</key>
9+
<true/>
10+
<key>com.apple.private.security.storage.AppDataContainers</key>
11+
<true/>
12+
</dict>
13+
</plist>

0 commit comments

Comments
 (0)