Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
844a502
Make buildable against SDK 9.0
rpetrich Oct 17, 2015
35abaec
Change description
rpetrich Oct 17, 2015
1657aad
Always re-register when rocketd is restarted
rpetrich Oct 17, 2015
2f09b1b
Send a response from the ReportCrash daemon if name isn't allowed (so…
rpetrich Oct 17, 2015
b56bbda
Optimize call to bootstrap_look_up by avoiding creation of an NSString
rpetrich Oct 17, 2015
f580515
Use beta depiction
rpetrich Oct 17, 2015
8ecfcef
Public Release 1.0.3 beta 1
rpetrich Oct 17, 2015
81fbafe
Remove beta depiction URL
rpetrich Oct 19, 2015
1ae235b
Public Release 1.0.3
rpetrich Oct 19, 2015
ed094ae
Use a 300 ms timeout when communicating over bootstrap ports
rpetrich Oct 21, 2015
dc89f38
More rigorous sanity check on startup
rpetrich Oct 26, 2015
34b63d3
Fix re-registration
rpetrich Oct 26, 2015
9cf5924
Monitor and relaunch rocketd
rpetrich Oct 26, 2015
9d8295c
Early exit on old iOS versions
rpetrich Oct 26, 2015
100fbb3
Add beta depiction
rpetrich Oct 26, 2015
cb4c72d
Public Release 1.0.4 beta 1
rpetrich Oct 26, 2015
0949410
Disable non-working rocketd test
rpetrich Oct 26, 2015
28768ab
Public Release 1.0.4 beta 2
rpetrich Oct 26, 2015
6dae69c
Restore non-beta depiction URL
rpetrich Nov 2, 2015
bd54f4a
Public Release 1.0.4
rpetrich Nov 2, 2015
06e2eba
Support iOS 10; Log in more places when DEBUG=1
rpetrich Jan 3, 2017
b071fe7
Make log statements show up on iOS 10
rpetrich Jan 3, 2017
015bb84
Support building using only a modern version of Xcode by default, but…
rpetrich Jan 3, 2017
5b8a73c
Introduce helper tool that reinstates rocketd (because the iOS 10.1 j…
rpetrich Jan 3, 2017
c7a70f1
Don't expose some internal hook symbols
rpetrich Jan 4, 2017
df8a64c
Use beta depiction
rpetrich Jan 4, 2017
78cb14c
Public Release 1.0.5 beta 1
rpetrich Jan 4, 2017
536da62
Use unfair locks to avoid deadlocking in spin locks on iOS 10
rpetrich Feb 5, 2017
7a99328
Add header guard to rocketbootstrap.h
rpetrich Feb 5, 2017
fea77d6
Adjust header documentation
rpetrich Feb 5, 2017
9b03161
Add XPC support (tested on iOS 9+)
rpetrich Feb 5, 2017
f2f1ca9
Add symlinks to system headers for XPC
rpetrich Feb 5, 2017
9db9e34
Public Release 1.0.5 Release Candidate 1
rpetrich Feb 5, 2017
28e7d1d
Remove beta depiction
rpetrich Feb 5, 2017
bcecaec
Public Release 1.0.5
rpetrich Feb 5, 2017
d861f95
Changes necessary to support Electra jailbreak for iOS 11 and builds …
rpetrich Feb 17, 2018
a845242
Make dynamic versions of rocketbootstrap_xpc_connection_create and ro…
rpetrich Feb 17, 2018
e690c19
Use https depiction
rpetrich Feb 17, 2018
e52bd4b
Public Release 1.0.6 alpha 1
rpetrich Feb 17, 2018
5e365de
Add support for Electra inside _rocketd_reenable
rpetrich Feb 23, 2018
89be058
Public Release 1.0.6 alpha 2
rpetrich Feb 23, 2018
7e9d6f1
Fix double-draining the autorelease pool
rpetrich Feb 24, 2018
4d02f66
Public Release 1.0.6 beta 1
rpetrich Feb 24, 2018
3793b26
Public Release 1.0.6
rpetrich Mar 7, 2018
5f65a9f
Fix build problems on latest Xcode toolchain on Mojave
rpetrich Mar 3, 2019
8f0ee0e
Redirect service names to have cy:rbs: prefix on iOS 12 and later, wh…
rpetrich Mar 3, 2019
968133f
Internal Release 1.0.7 alpha 1
rpetrich Mar 3, 2019
4f7912d
Fix inverted conditional in fallback path for "unlock then register" …
rpetrich Mar 4, 2019
a88c3cf
Public Release 1.0.7 beta 1
rpetrich Mar 4, 2019
888252f
Fix build problems with Xcode 10 causing resulting binaries to be inc…
rpetrich Mar 16, 2019
5705e63
Never use name redirection when substitute is available (by request o…
rpetrich Mar 17, 2019
e484b36
Public Release 1.0.7 beta 2
rpetrich Mar 17, 2019
e93b188
Add support for arm64e architecture
rpetrich Mar 30, 2019
dbc9984
Public Release 1.0.7 beta 3
rpetrich Mar 30, 2019
5d030a1
Support pointer authentication in clients when ROCKETBOOTSTRAP_LOAD_D…
rpetrich May 12, 2019
12d4f5c
Support pointer authentication when calling jb_connect/jb_fix_suid_no…
rpetrich May 12, 2019
31f8d18
Use normal repository
rpetrich Mar 9, 2020
1c19b11
Public Release 1.0.7
rpetrich Mar 9, 2020
686dfc6
Use rocketd always, and try redirection first before rocketd
rpetrich Apr 12, 2020
0733a38
Perform both types of unlocking when name redirection is supported
rpetrich Apr 12, 2020
994e624
Fully enable rocketd fallback
rpetrich Apr 12, 2020
41615c0
Switch to beta repo
rpetrich Apr 12, 2020
0d728a7
Public Release 1.0.8 beta 1
rpetrich Apr 12, 2020
6ddc1b9
Fix boot hang on chimera1n
coolstar Apr 25, 2020
75068f9
Public Release 1.0.9
rpetrich Apr 26, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion LightMessaging
Submodule LightMessaging updated 1 files
+52 −11 LightMessaging.h
51 changes: 43 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,57 @@ LIBRARY_NAME = librocketbootstrap
librocketbootstrap_FILES = Tweak.x Shims.x
librocketbootstrap_LIBRARIES = substrate
librocketbootstrap_FRAMEWORKS = Foundation
librocketbootstrap_USE_MODULES = 0

TOOL_NAME = rocketd
TOOL_NAME = rocketd _rocketd_reenable
rocketd_FILES = rocketd.c
rocketd_CFLAGS = -fblocks
rocketd_FRAMEWORKS = CoreFoundation
rocketd_INSTALL_PATH = /usr/libexec
rocketd_IPHONE_ARCHS = armv6 arm64
rocketd_USE_MODULES = 0
rocketd_CODESIGN_FLAGS = -Sentitlements.xml

ADDITIONAL_CFLAGS = -std=c99
_rocketd_reenable_FILES = rocketd_reenable.c
_rocketd_reenable_INSTALL_PATH = /usr/libexec
_rocketd_reenable_USE_MODULES = 0
_rocketd_reenable_CODESIGN_FLAGS = -Sentitlements.xml

IPHONE_ARCHS = armv6 armv7 armv7s arm64
ADDITIONAL_CFLAGS = -std=c99 -Ioverlayheaders

SDKVERSION_armv6 = 5.1
INCLUDE_SDKVERSION_armv6 = 7.0
TARGET_IPHONEOS_DEPLOYMENT_VERSION = 4.0
# Support targeting 3.0 in packaged builds, but allow testing packages/builds to be missing support for old iOS versions
XCODE4_PATH ?= /Applications/Xcode_Legacy.app
XCODE6_PATH ?= /Volumes/Xcode/Xcode.app
XCODE9_PATH ?= /Volumes/Xcode_9.4.1/Xcode.app

ifeq ($(wildcard $(XCODE4_PATH)/.*),)
ADDITIONAL_CFLAGS += -Idefaultheaders
IPHONE_ARCHS = armv7 armv7s arm64 arm64e
TARGET_IPHONEOS_DEPLOYMENT_VERSION = 8.4
ifeq ($(FINALPACKAGE),1)
$(error Building final package requires a legacy Xcode install!)
endif
else
armv6_CFLAGS += -Ifullheaders
armv7_CFLAGS += -Ifullheaders
armv7s_CFLAGS += -Ifullheaders
arm64_CFLAGS += -Idefaultheaders
arm64e_CFLAGS += -Idefaultheaders
rocketd_IPHONE_ARCHS = armv6 arm64
_rocketd_reenable_IPHONE_ARCHS = armv6 arm64
IPHONE_ARCHS = armv6 armv7 armv7s arm64 arm64e
SDKVERSION_armv6 = 5.1
INCLUDE_SDKVERSION_armv6 = 8.4
TARGET_IPHONEOS_DEPLOYMENT_VERSION_armv6 = 3.0
THEOS_PLATFORM_SDK_ROOT_armv6 = /Applications/Xcode_Legacy.app/Contents/Developer
TARGET_IPHONEOS_DEPLOYMENT_VERSION_armv7 = 4.0
TARGET_IPHONEOS_DEPLOYMENT_VERSION_armv7s = 6.0
TARGET_IPHONEOS_DEPLOYMENT_VERSION_arm64 = 7.0
TARGET_IPHONEOS_DEPLOYMENT_VERSION_arm64e = 12.0
TARGET_IPHONEOS_DEPLOYMENT_VERSION = 9.0
THEOS_PLATFORM_SDK_ROOT_armv6 = $(XCODE4_PATH)/Contents/Developer
THEOS_PLATFORM_SDK_ROOT_armv7 = $(XCODE6_PATH)/Contents/Developer
THEOS_PLATFORM_SDK_ROOT_armv7s = $(XCODE6_PATH)/Contents/Developer
THEOS_PLATFORM_SDK_ROOT_arm64 = $(XCODE9_PATH)/Contents/Developer
endif

include framework/makefiles/common.mk
include framework/makefiles/library.mk
Expand All @@ -28,3 +62,4 @@ stage::
mkdir -p "$(THEOS_STAGING_DIR)/usr/include"
cp -a rocketbootstrap.h rocketbootstrap_dynamic.h "$(THEOS_STAGING_DIR)/usr/include"
plutil -convert binary1 "$(THEOS_STAGING_DIR)/Library/MobileSubstrate/DynamicLibraries/RocketBootstrap.plist"
plutil -convert binary1 "$(THEOS_STAGING_DIR)/Library/LaunchDaemons/com.rpetrich.rocketbootstrapd.plist"
123 changes: 115 additions & 8 deletions Shims.x
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
#import "log.h"
#import "unfair_lock.h"
#import "rocketbootstrap_internal.h"

#import <CaptainHook/CaptainHook.h>
#import <libkern/OSAtomic.h>
#import <substrate.h>

static OSSpinLock spin_lock;
static unfair_lock shim_lock;

kern_return_t bootstrap_look_up3(mach_port_t bp, const name_t service_name, mach_port_t *sp, pid_t target_pid, const uuid_t instance_id, uint64_t flags) __attribute__((weak_import));
kern_return_t (*_bootstrap_look_up3)(mach_port_t bp, const name_t service_name, mach_port_t *sp, pid_t target_pid, const uuid_t instance_id, uint64_t flags);
static kern_return_t (*_bootstrap_look_up3)(mach_port_t bp, const name_t service_name, mach_port_t *sp, pid_t target_pid, const uuid_t instance_id, uint64_t flags);

kern_return_t $bootstrap_look_up3(mach_port_t bp, const name_t service_name, mach_port_t *sp, pid_t target_pid, const uuid_t instance_id, uint64_t flags)
static kern_return_t $bootstrap_look_up3(mach_port_t bp, const name_t service_name, mach_port_t *sp, pid_t target_pid, const uuid_t instance_id, uint64_t flags)
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSMutableDictionary *threadDictionary = [NSThread currentThread].threadDictionary;
Expand All @@ -26,12 +28,12 @@ kern_return_t $bootstrap_look_up3(mach_port_t bp, const name_t service_name, mac
static void hook_bootstrap_lookup(void)
{
static bool hooked_bootstrap_look_up;
OSSpinLockLock(&spin_lock);
unfair_lock_lock(&shim_lock);
if (!hooked_bootstrap_look_up) {
MSHookFunction(bootstrap_look_up3, $bootstrap_look_up3, (void **)&_bootstrap_look_up3);
hooked_bootstrap_look_up = true;
}
OSSpinLockUnlock(&spin_lock);
unfair_lock_unlock(&shim_lock);
}

CFMessagePortRef rocketbootstrap_cfmessageportcreateremote(CFAllocatorRef allocator, CFStringRef name)
Expand Down Expand Up @@ -98,13 +100,13 @@ static bool has_hooked_messaging_center;

- (void)runServerOnCurrentThreadProtectedByEntitlement:(id)entitlement
{
%orig();
if (objc_getAssociatedObject(self, &has_hooked_messaging_center)) {
NSString **_centerName = CHIvarRef(self, _centerName, NSString *);
if (_centerName && *_centerName) {
rocketbootstrap_unlock([*_centerName UTF8String]);
}
}
%orig();
}

%end
Expand All @@ -115,11 +117,116 @@ void rocketbootstrap_distributedmessagingcenter_apply(CPDistributedMessagingCent
{
if (rocketbootstrap_is_passthrough())
return;
OSSpinLockLock(&spin_lock);
unfair_lock_lock(&shim_lock);
if (!has_hooked_messaging_center) {
has_hooked_messaging_center = true;
%init(messaging_center);
}
OSSpinLockUnlock(&spin_lock);
unfair_lock_unlock(&shim_lock);
objc_setAssociatedObject(messaging_center, &has_hooked_messaging_center, (id)kCFBooleanTrue, OBJC_ASSOCIATION_ASSIGN);
}

#ifdef __clang__

#ifndef __IPHONE_9_0
#define __IPHONE_9_0 90000
#define __AVAILABILITY_INTERNAL__IPHONE_9_0
#endif

#include <xpc/xpc.h>

static xpc_endpoint_t _xpc_endpoint_create(mach_port_t port)
{
static xpc_endpoint_t(*__xpc_endpoint_create)(mach_port_t);
if (!__xpc_endpoint_create) {
MSImageRef libxpc = MSGetImageByName("/usr/lib/system/libxpc.dylib");
if (!libxpc) {
return NULL;
}
__xpc_endpoint_create = MSFindSymbol(libxpc, "__xpc_endpoint_create");
if (!__xpc_endpoint_create) {
return NULL;
}
}
return __xpc_endpoint_create(port);
}

static mach_port_t _xpc_connection_copy_listener_port(xpc_connection_t connection)
{
static mach_port_t(*__xpc_connection_copy_listener_port)(xpc_connection_t);
if (!__xpc_connection_copy_listener_port) {
MSImageRef libxpc = MSGetImageByName("/usr/lib/system/libxpc.dylib");
if (!libxpc) {
return MACH_PORT_NULL;
}
__xpc_connection_copy_listener_port = MSFindSymbol(libxpc, "__xpc_connection_copy_listener_port");
if (!__xpc_connection_copy_listener_port) {
return MACH_PORT_NULL;
}
}
return __xpc_connection_copy_listener_port(connection);
}

xpc_object_t xpc_connection_copy_entitlement_value(xpc_connection_t, const char* entitlement);

#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
xpc_connection_t rocketbootstrap_xpc_connection_create(const char *name, dispatch_queue_t targetq, uint64_t flags)
{
mach_port_t bootstrap = MACH_PORT_NULL;
if (task_get_bootstrap_port(mach_task_self(), &bootstrap) != 0) {
return NULL;
}
if (flags & XPC_CONNECTION_MACH_SERVICE_LISTENER) {
xpc_connection_t result = xpc_connection_create(NULL, targetq);
mach_port_t port = _xpc_connection_copy_listener_port(result);
if (rocketbootstrap_register(bootstrap, (char *)name, port) != 0) {
xpc_release(result);
return NULL;
}
return result;
}
mach_port_t send_port = MACH_PORT_NULL;
if (rocketbootstrap_look_up(bootstrap, name, &send_port) != 0) {
return NULL;
}
xpc_endpoint_t endpoint = _xpc_endpoint_create(send_port);
xpc_connection_t result = xpc_connection_create_from_endpoint(endpoint);
xpc_release(endpoint);
if (targetq != NULL) {
xpc_connection_set_target_queue(result, targetq);
}
return result;
}

xpc_object_t rocketbootstrap_xpc_connection_copy_application_identifier(xpc_connection_t connection)
{
xpc_object_t application_id = xpc_connection_copy_entitlement_value(connection, "application-identifier");
if (!application_id) {
return NULL;
}
if (xpc_get_type(application_id) != XPC_TYPE_STRING) {
xpc_release(application_id);
return NULL;
}
xpc_object_t team_id = xpc_connection_copy_entitlement_value(connection, "com.apple.developer.team-identifier");
if (!team_id) {
return application_id;
}
if (xpc_get_type(team_id) != XPC_TYPE_STRING) {
xpc_release(team_id);
return application_id;
}
const char *application_id_str = xpc_string_get_string_ptr(application_id);
const char *team_id_str = xpc_string_get_string_ptr(team_id);
size_t team_id_length = xpc_string_get_length(team_id);
if (memcmp(application_id_str, team_id_str, team_id_length) != 0 || application_id_str[team_id_length] != '.') {
xpc_release(team_id);
return application_id;
}
xpc_object_t trimmed_id = xpc_string_create(application_id_str + team_id_length + 1);
xpc_release(team_id);
xpc_release(application_id);
return trimmed_id;
}

#endif
Loading