├── .gitattributes
├── .gitignore
├── LICENSE.md
├── Makefile
├── README.md
├── XcodeAnyDebug.plist
├── build.sh
├── control
├── layout
├── DEBIAN
│ ├── postinst
│ ├── preinst
│ └── prerm
├── Library
│ └── LaunchDaemons
│ │ └── XcodeAnyDebug-startup.plist
└── usr
│ ├── bin
│ └── xcodeanydebug
│ │ ├── DTServiceHub.entitlements
│ │ └── debugserver.entitlements
│ └── libexec
│ └── XcodeAnyDebug-startup
└── main.x
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .theos/
2 | /packages/
3 | .DS_Store
4 |
5 | .vscode/settings.json
6 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2023-2024 Lars Fröder (opa334)
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
--------------------------------------------------------------------------------
/Makefile:
--------------------------------------------------------------------------------
1 | export PACKAGE_VERSION := 1.0
2 |
3 | ARCHS := arm64 arm64e
4 | ifeq ($(THEOS_PACKAGE_SCHEME),roothide)
5 | JBROOT :=
6 | ROOTFS := /rootfs
7 | TARGET := iphone:clang:16.5:15.0
8 | else ifeq ($(THEOS_PACKAGE_SCHEME),rootless)
9 | JBROOT := /var/jb
10 | ROOTFS :=
11 | TARGET := iphone:clang:16.5:15.0
12 | else
13 | JBROOT :=
14 | ROOTFS :=
15 | TARGET := iphone:clang:14.5:14.0
16 | endif
17 |
18 | include $(THEOS)/makefiles/common.mk
19 |
20 | TWEAK_NAME += XcodeAnyDebug
21 |
22 | XcodeAnyDebug_FILES += main.x
23 | XcodeAnyDebug_CFLAGS += -fobjc-arc
24 |
25 | include $(THEOS_MAKE_PATH)/tweak.mk
26 |
27 | before-package::
28 | for file in \
29 | $(THEOS_STAGING_DIR)/DEBIAN/* \
30 | $(THEOS_STAGING_DIR)/usr/libexec/XcodeAnyDebug-startup \
31 | $(THEOS_STAGING_DIR)/Library/LaunchDaemons/XcodeAnyDebug-startup.plist \
32 | ; do \
33 | sed -e "s|@JBROOT@|$(JBROOT)|g" -e "s|@ROOTFS@|$(ROOTFS)|g" "$$file" > "$$file.tmp"; \
34 | cat "$$file.tmp" > "$$file"; \
35 | rm -f "$$file.tmp"; \
36 | done
37 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # XcodeAnyDebug
2 |
3 | Debug any process in Xcode.
4 |
5 | Tested on iOS 15.0/15.4/16.2/16.4/16.5.1/16.7.10/18.3 with palera1n, Dopamine and Dopamine (RootHide) jailbreaks.
6 |
7 |
8 | # How To Build
9 |
10 | https://github.com/roothide/Developer
11 |
--------------------------------------------------------------------------------
/XcodeAnyDebug.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Filter
6 |
7 | Executables
8 |
9 | lockdownd
10 | dtdebugproxyd
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/build.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | set -e
4 |
5 | FINALPACKAGE=1 THEOS_PACKAGE_SCHEME='' gmake clean package
6 | FINALPACKAGE=1 THEOS_PACKAGE_SCHEME=rootless gmake clean package
7 | FINALPACKAGE=1 THEOS_PACKAGE_SCHEME=roothide gmake clean package
8 |
--------------------------------------------------------------------------------
/control:
--------------------------------------------------------------------------------
1 | Package: xcode-any-debug
2 | Name: Xcode Any Debug
3 | Version: 0.0.3
4 | Architecture: iphoneos-arm
5 | Description: debug any process with xcode (jailbroken required)
6 | Maintainer: roothide
7 | Author: roothide
8 | Section: Tweaks
9 | Depends: ldid, plutil, mobilesubstrate (>= 0.9.5000)
10 |
--------------------------------------------------------------------------------
/layout/DEBIAN/postinst:
--------------------------------------------------------------------------------
1 | #!@JBROOT@/bin/bash
2 |
3 | set -e
4 |
5 | ldid -M -S@JBROOT@/usr/bin/xcodeanydebug/debugserver.entitlements @JBROOT@/usr/bin/xcodeanydebug/debugserver
6 |
7 | if [ -e @ROOTFS@/System/Library/PrivateFrameworks/DVTInstrumentsFoundation.framework/DTServiceHub ] \
8 | && [ -e @ROOTFS@/System/Library/DeveloperModeLaunchDaemons/com.apple.instruments.deviceservice.plist ]; then
9 |
10 | cp @ROOTFS@/System/Library/PrivateFrameworks/DVTInstrumentsFoundation.framework/DTServiceHub @JBROOT@/usr/bin/xcodeanydebug/DTServiceHub
11 | ldid -e @ROOTFS@/System/Library/PrivateFrameworks/DVTInstrumentsFoundation.framework/DTServiceHub > @JBROOT@/tmp/DTServiceHub.entitlements
12 | plutil -remove -key "com.apple.private.sandbox.profile:embedded" @JBROOT@/tmp/DTServiceHub.entitlements
13 | ldid -S@JBROOT@/tmp/DTServiceHub.entitlements @JBROOT@/usr/bin/xcodeanydebug/DTServiceHub
14 | ldid -M -S@JBROOT@/usr/bin/xcodeanydebug/DTServiceHub.entitlements @JBROOT@/usr/bin/xcodeanydebug/DTServiceHub
15 |
16 | cp @ROOTFS@/System/Library/DeveloperModeLaunchDaemons/com.apple.instruments.deviceservice.plist @JBROOT@/usr/bin/xcodeanydebug/com.apple.instruments.deviceservice.plist
17 | plutil -key Program -value "@JBROOT@/usr/bin/xcodeanydebug/DTServiceHub" @JBROOT@/usr/bin/xcodeanydebug/com.apple.instruments.deviceservice.plist
18 | plutil -key ProgramArguments -array @JBROOT@/usr/bin/xcodeanydebug/com.apple.instruments.deviceservice.plist
19 | plutil -key ProgramArguments -arrayadd -string "/System/Library/PrivateFrameworks/DVTInstrumentsFoundation.framework/DTServiceHub" @JBROOT@/usr/bin/xcodeanydebug/com.apple.instruments.deviceservice.plist
20 |
21 | @JBROOT@/usr/libexec/XcodeAnyDebug-startup
22 |
23 | fi
24 |
25 | killall -9 lockdownd dtdebugproxyd debugserver || true
26 |
--------------------------------------------------------------------------------
/layout/DEBIAN/preinst:
--------------------------------------------------------------------------------
1 | #!@JBROOT@/bin/bash
2 |
3 | set -e
4 |
5 | if [ -f @JBROOT@/usr/bin/xcodeanydebug ]; then
6 | rm -rf @JBROOT@/usr/bin/xcodeanydebug
7 | fi
8 |
9 | mkdir -p @JBROOT@/usr/bin/xcodeanydebug
10 |
11 | if [ -f @ROOTFS@/usr/libexec/debugserver ]; then
12 | # iOS 16+
13 | cp @ROOTFS@/usr/libexec/debugserver @JBROOT@/usr/bin/xcodeanydebug/debugserver
14 |
15 | elif [ -d @ROOTFS@/Developer ] && [ "$(ls -A @ROOTFS@/Developer)" ]; then
16 | if [ -f @ROOTFS@/Developer/usr/bin/debugserver ]; then
17 | cp @ROOTFS@/Developer/usr/bin/debugserver @JBROOT@/usr/bin/xcodeanydebug/debugserver
18 | else
19 | echo -e "\n* debugserver for xcode not found on your device\n\n" >&2
20 | exit 1
21 | fi
22 | else
23 | echo "* Developer Disk Image not mounted, run xcode to connect and pair your device first." >&2
24 | exit 1
25 | fi
26 |
--------------------------------------------------------------------------------
/layout/DEBIAN/prerm:
--------------------------------------------------------------------------------
1 | #!@JBROOT@/bin/bash
2 |
3 | rm -rf @JBROOT@/usr/bin/xcodeanydebug || true
4 |
5 | killall -9 lockdownd dtdebugproxyd debugserver || true
6 |
--------------------------------------------------------------------------------
/layout/Library/LaunchDaemons/XcodeAnyDebug-startup.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | ExecuteAllowed
6 |
7 | Label
8 | XcodeAnyDebug.startup
9 | POSIXSpawnType
10 | Interactive
11 | ProcessType
12 | Interactive
13 | Program
14 | @JBROOT@/bin/sh
15 | ProgramArguments
16 |
17 | @JBROOT@/bin/sh
18 | @JBROOT@/usr/libexec/XcodeAnyDebug-startup
19 |
20 | RunAtLoad
21 |
22 |
23 |
--------------------------------------------------------------------------------
/layout/usr/bin/xcodeanydebug/DTServiceHub.entitlements:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | platform-application
7 |
8 | com.apple.private.security.no-sandbox
9 |
10 | com.apple.private.security.storage.AppBundles
11 |
12 | com.apple.private.security.storage.AppDataContainers
13 |
14 |
15 |
16 | com.apple.appletv.pbs.allow-launch-kiosk
17 |
18 | com.apple.assertiond.app-state-monitor
19 |
20 | com.apple.backboardd.debugapplications
21 |
22 | com.apple.backboardd.launchapplications
23 |
24 | com.apple.diagnosticd.diagnostic
25 |
26 | com.apple.frontboard.debugapplications
27 |
28 | com.apple.frontboard.launchapplications
29 |
30 | com.apple.private.cs.debugger
31 |
32 | com.apple.private.logging.diagnostic
33 |
34 | com.apple.private.memorystatus
35 |
36 | com.apple.security.cs.debugger
37 |
38 | com.apple.security.network.client
39 |
40 | com.apple.security.network.server
41 |
42 | com.apple.springboard.debugapplications
43 |
44 | com.apple.system-task-ports
45 |
46 | run-unsigned-code
47 |
48 | task_for_pid-allow
49 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/layout/usr/bin/xcodeanydebug/debugserver.entitlements:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | platform-application
7 |
8 | com.apple.private.security.no-sandbox
9 |
10 | com.apple.private.security.storage.AppBundles
11 |
12 | com.apple.private.security.storage.AppDataContainers
13 |
14 |
15 |
16 | com.apple.appletv.pbs.allow-launch-kiosk
17 |
18 | com.apple.assertiond.app-state-monitor
19 |
20 | com.apple.backboardd.debugapplications
21 |
22 | com.apple.backboardd.launchapplications
23 |
24 | com.apple.diagnosticd.diagnostic
25 |
26 | com.apple.frontboard.debugapplications
27 |
28 | com.apple.frontboard.launchapplications
29 |
30 | com.apple.private.cs.debugger
31 |
32 | com.apple.private.logging.diagnostic
33 |
34 | com.apple.private.memorystatus
35 |
36 | com.apple.security.cs.debugger
37 |
38 | com.apple.security.network.client
39 |
40 | com.apple.security.network.server
41 |
42 | com.apple.springboard.debugapplications
43 |
44 | com.apple.system-task-ports
45 |
46 | run-unsigned-code
47 |
48 | task_for_pid-allow
49 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/layout/usr/libexec/XcodeAnyDebug-startup:
--------------------------------------------------------------------------------
1 | #!@JBROOT@/bin/sh
2 |
3 | @JBROOT@/usr/bin/launchctl unload @ROOTFS@/System/Library/DeveloperModeLaunchDaemons/com.apple.instruments.deviceservice.plist || true
4 |
5 | @JBROOT@/usr/bin/launchctl load @JBROOT@/usr/bin/xcodeanydebug/com.apple.instruments.deviceservice.plist
6 |
--------------------------------------------------------------------------------
/main.x:
--------------------------------------------------------------------------------
1 | #import
2 |
3 | #import
4 | #import
5 |
6 | #define TAG "[XcodeAnyDebug] "
7 |
8 | @interface DTDSLaunchTargetID : NSObject
9 | - (instancetype)initWithUser:(uid_t)user group:(gid_t)group;
10 | @end
11 |
12 | @interface DTDSSpawnOptions : NSObject
13 | @property (nonatomic, strong) DTDSLaunchTargetID *targetUserAndGroup;
14 | @end
15 |
16 | %group SMJob
17 |
18 | static void* _SMJobSubmit;
19 |
20 | %hookf(Boolean, _SMJobSubmit, CFStringRef domain, CFDictionaryRef job, CFTypeID auth, CFErrorRef *outError)
21 | {
22 | NSMutableDictionary* mjob = [(__bridge NSDictionary*)job mutableCopy];
23 | if (job != nil && mjob[@"ProgramArguments"] != nil)
24 | {
25 | NSArray* argv = mjob[@"ProgramArguments"];
26 |
27 | NSLog(@TAG "_SMJobSubmit argv=%@", argv);
28 |
29 | if ([argv[0] hasSuffix:@"/debugserver"])
30 | {
31 | NSMutableArray* new_argv = [argv mutableCopy];
32 |
33 | new_argv[0] = jbroot(@"/usr/bin/xcodeanydebug/debugserver");
34 |
35 | mjob[@"UserName"] = @"root";
36 | mjob[@"ProgramArguments"] = new_argv;
37 | }
38 |
39 | job = (__bridge_retained CFDictionaryRef)mjob;
40 | }
41 | return %orig;
42 | }
43 |
44 | %end
45 |
46 | %group Dtds
47 |
48 | static void* _dtdsSpawnExecutableWithOptions;
49 |
50 | %hookf(Boolean, _dtdsSpawnExecutableWithOptions, const char *path, DTDSSpawnOptions *options, pid_t *pid, NSError **error)
51 | {
52 | NSLog(@TAG "_dtdsSpawnExecutableWithOptions path=%s", path);
53 |
54 | if ([[NSString stringWithUTF8String:path] hasSuffix:@"/debugserver"])
55 | {
56 | DTDSLaunchTargetID *target = [[%c(DTDSLaunchTargetID) alloc] initWithUser:0 group:0];
57 | [options setTargetUserAndGroup:target];
58 |
59 | NSString *newPath = jbroot(@"/usr/bin/xcodeanydebug/debugserver");
60 | return %orig([newPath UTF8String], options, pid, error);
61 | }
62 |
63 | return %orig;
64 | }
65 |
66 | %end
67 |
68 | %ctor {
69 | BOOL isDtds = NO;
70 | for (NSString* arg in [[NSProcessInfo processInfo] arguments]) {
71 | if ([arg hasSuffix:@"dtdebugproxyd"]) {
72 | isDtds = YES;
73 | break;
74 | }
75 | }
76 | NSLog(@TAG "isDtds=%@", isDtds ? @"YES" : @"NO");
77 | if (isDtds) {
78 | _dtdsSpawnExecutableWithOptions = dlsym(RTLD_DEFAULT, "dtdsSpawnExecutableWithOptions");
79 | %init(Dtds);
80 | } else {
81 | _SMJobSubmit = dlsym(RTLD_DEFAULT, "SMJobSubmit");
82 | %init(SMJob);
83 | }
84 | }
85 |
--------------------------------------------------------------------------------