Skip to content

Commit 972d58c

Browse files
authored
Spaghetti (#6)
* feat: working monitor + update * docs: Update README * feat: Version checks * feat: Helper enable/disable scripts * feat: Resolve SSL traffic issue
1 parent b733123 commit 972d58c

File tree

17 files changed

+491
-111
lines changed

17 files changed

+491
-111
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ releases
66
.DS_Store
77
*.dylib
88
.theos
9+
local

README.md

Lines changed: 88 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
A monitor solution for jailbroken iOS devices. The core goal of this project is to make sure a specific iOS application is constantly running without needed to use Single App Mode (SAM) or Guided Access Mode (GAM).
66

7-
A `./bin/setup` script is included to help with initial configuration of a jailbroken device.
7+
A script, `./bin/setup`, is included to help with initial configuration of a jailbroken device.
88

99
Lastly, in the future I would like to include a way to handle updates for the various components.
1010

@@ -17,44 +17,73 @@ If you only care about the monitoring component from this repo you can grab the
1717
1. Run `dpkg -i com.github.clburlison.dmon-XXX.deb`
1818
1. The LaunchDaemon service will now monitor to make sure all components are properly running
1919

20+
## Prerequisites
21+
22+
- A Mac
23+
- A jailbroken iPhone that is supervised
24+
- Apple Command Line Tools (`xcode-select --install`)
25+
- imobiledevice tools (`brew install libimobiledevice`)
26+
- Optional but **highly recommend** creating a ssh keypair
27+
- Setup your ssh config entry. This makes your life much easier as ssh sessions can be remembered.
28+
29+
```sh
30+
cat ~/.ssh/config
31+
Host iphone
32+
HostName localhost
33+
User root
34+
Port 2222
35+
StrictHostKeyChecking no
36+
37+
Host *
38+
ControlMaster auto
39+
ControlPath /tmp/%r@%h:%p
40+
ControlPersist 1800
41+
```
42+
2043
## Getting started
2144

2245
It is assumed you know your way around a command line. All commands are run on your computer connected to a single iOS device. While it is possible to do some of this manually on a jailbroken iOS device that is pron to human error.
2346

2447
1. Grab a valid iOS 14+ device and jailbreak it: https://ios.cfw.guide/get-started/select-iphone/
25-
1. Clone this git repo
48+
1. Clone this git repo.
2649

2750
```sh
2851
git clone https://github.com/clburlison/dmon
2952
```
3053

31-
1. Change directory into the freshly cloned repo
54+
1. Change directory into the freshly cloned repo.
3255

3356
```sh
3457
cd dmon
3558
```
3659

37-
1. Create a `config.json` at the root of this repo with the correct values
60+
1. Create a `config.json` at the root of this repo with the correct values.
61+
62+
Make sure to remove all `// comments` before saving. They are not valid json!
3863

3964
```json
4065
{
41-
"api_key": "YOUR_GC_API_KEY",
42-
"device_configuration_manager_url": "https://my_awesome_DCM_url"
66+
"api_key": "YOUR_API_KEY",
67+
"device_configuration_manager_url": "https://YOUR_AWESOME_DCM_URL",
68+
"dmon_url": "https://YOUR_URL:PORT/path/", // Url to download update files from
69+
"dmon_username": "username", // Basic Auth username. Leave empty if not used
70+
"dmon_password": "password" // Basic Auth password. Leave empty if not used
4371
}
4472
```
4573

46-
1. Download any extra .deb files you want installed into the `./debs/` directory. These are installed based on file name IE 01_foobar.deb, 02_curl.deb, etc.
47-
48-
> Substitute is installed as part of the `setup` script
74+
1. Download any extra .deb files you want installed into the `./debs/` directory.
4975

5076
debs to include:
5177

78+
- https://apt.bingner.com/debs/1443.00/com.ex.substitute_2.3.1_iphoneos-arm.deb
79+
- https://apt.bingner.com/debs/1443.00/com.saurik.substrate.safemode_0.9.6005_iphoneos-arm.deb
5280
- https://repo.spooferpro.com/debs/com.spooferpro.kernbypass_1.1.0_iphoneos-arm64.deb
53-
- Potentially any paid/private debs. nudge, nudge, wink, wink
81+
- https://github.com/clburlison/dmon/releases
5482
- (Optional) https://cydia.akemi.ai/debs/nodelete-ai.akemi.appsyncunified.deb
5583
- (Optional) https://cydia.akemi.ai/debs/nodelete-ai.akemi.appinst.deb
84+
- **Potentially any paid/private debs. nudge, nudge, wink, wink**
5685

57-
1. Grab a copy of Pokemon Go via [majd/ipatool](https://github.com/majd/ipatool)
86+
1. Grab a copy of Pokemon Go via [majd/ipatool](https://github.com/majd/ipatool).
5887

5988
```sh
6089
brew tap majd/repo
@@ -63,8 +92,8 @@ It is assumed you know your way around a command line. All commands are run on y
6392
ipatool download --purchase -b com.nianticlabs.pokemongo -o pogo.ipa
6493
```
6594

66-
1. Connect your iOS device to your computer via USB
67-
1. Open Terminal and run (remember to only have one phone connected)
95+
1. Connect your iOS device to your computer via USB.
96+
1. Open Terminal and run (remember to only have one phone connected).
6897

6998
```sh
7099
# Alteratively you can pass -u <device-uuid> if multiple phones are connected
@@ -75,13 +104,14 @@ It is assumed you know your way around a command line. All commands are run on y
75104

76105
```sh
77106
ssh root@localhost -p 2222 # default password is 'alpine'
107+
# Now disconnect with: Control + d
78108
```
79109

80-
1. In a third terminal window run:
110+
1. Now run:
81111

82112
```sh
83113
./bin/setup
84-
# If you want to setup passwordless ssh then pass the argument with the path to your key
114+
# If you want to setup passwordless ssh then pass the argument with the path to your public key
85115
./bin/setup -s ~/.ssh/main.pub
86116
```
87117

@@ -97,9 +127,51 @@ Bonus items that are out of scope for this project.
97127

98128
- All testing has been completed with iOS 15 using palera1n
99129
- Only confirmed on older A9 processors aka iPhone SE first gen
100-
- DEB Package is build on macOS Ventura
130+
- DEB Package is built on macOS Ventura
131+
132+
## Commonly asked questions
133+
134+
### Why didn't you use Theos to build the deb?
135+
136+
I was expecting to add a few external compiled binaries and didn't want to read a ton of documentation. Things changed and now I'm too lazy to rewrite.
137+
138+
### How can I stop it?!?!
139+
140+
1. Close Pokemon Go on the phone
141+
2. ssh into the phone & unload the launch daemon
142+
143+
```sh
144+
ssh iphone
145+
/usr/bin/launchctl unload /Library/LaunchDaemons/com.github.clburlison.dmon.plist
146+
```
147+
148+
### How do I setup the webserver?
149+
150+
It is a flat structure. You can use nginx, apache, caddy, python, node, etc. Your files should be named like this:
151+
152+
```sh
153+
top_level_folder
154+
├── gc.deb
155+
├── pogo.ipa
156+
└── version.txt
157+
```
158+
159+
Then in your config point `dmon_url` to `http://HOSTNAME:PORT/top_level_folder`.
160+
161+
### Why did you reuse the existing `config.json`?
162+
163+
This isn't a pure solution. I am lazy. Now bugger off.
164+
165+
### Why didn't you include the debs I need?
166+
167+
I don't have the original authors permissions to upload their files.
168+
169+
### Why is my https url not working?
170+
171+
We are using the stock CA Certificates installed as part of the iOS jailbreak. The Procursus Team placed files in `/usr/lib/ssl/cacert.pem` and I figured it would be safe to keep using them. Those root certs might have expired and need an update.
101172

102173
## References
103174

104175
- [dm.pl](https://github.com/theos/dm.pl)
176+
- [theos](https://theos.dev)
105177
- [appknox/Open](https://github.com/appknox/Open) which was originally from [conradev/Open](https://github.com/conradev/Open)

bin/disable

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env zsh
2+
3+
ssh iphone "/usr/bin/launchctl unload /Library/LaunchDaemons/com.github.clburlison.dmon.plist"

bin/enable

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env zsh
2+
3+
ssh iphone "/usr/bin/launchctl load /Library/LaunchDaemons/com.github.clburlison.dmon.plist"

bin/setup

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/zsh
22
############################################
3-
# Version 0.0.3
3+
# Version 0.0.4
44
############################################
55
SCRIPT_NAME=$(basename $0)
66
# Make sure this is always ran from the parent directory path.
@@ -12,7 +12,7 @@ while getopts 's:' OPTION; do
1212
s)
1313
SSH_KEY_PATH="$OPTARG"
1414
echo Setting up ssh passwordless auth with: "$SSH_KEY_PATH"
15-
ssh root@localhost -p 2222 'mkdir ~/.ssh'
15+
ssh -p 2222 root@localhost 'mkdir ~/.ssh'
1616
scp -P 2222 "$SSH_KEY_PATH" root@localhost:~/.ssh/authorized_keys
1717
;;
1818
?)
@@ -23,29 +23,30 @@ while getopts 's:' OPTION; do
2323
done
2424
shift "$(($OPTIND -1))"
2525

26-
echo Installing Pogo
27-
ideviceinstaller -i ./pogo.ipa
26+
# If local copy of Pogo exists then install it now
27+
if test -f "./pogo.ip"; then
28+
echo Installing Pogo
29+
ideviceinstaller -i ./pogo.ipa
30+
fi
2831

29-
# echo Install Substitute
32+
# echo Install Substitute. This spaghetti is not reliable. Use the debs!
3033
# Requires https://repo.palera.in which should be added by default
31-
ssh root@localhost -p 2222 'apt update'
32-
ssh root@localhost -p 2222 'apt upgrade -y --allow-unauthenticated'
33-
ssh root@localhost -p 2222 'apt install -y --allow-unauthenticated com.saurik.substrate.safemode'
34-
ssh root@localhost -p 2222 'apt install -y --allow-unauthenticated com.ex.substitute'
34+
# ssh root@localhost -p 2222 'apt update'
35+
# ssh root@localhost -p 2222 'apt upgrade -y --allow-unauthenticated'
36+
# ssh root@localhost -p 2222 'apt install -y --allow-unauthenticated com.saurik.substrate.safemode'
37+
# ssh root@localhost -p 2222 'apt install -y --allow-unauthenticated com.ex.substitute'
3538

36-
for f in ./debs/*
37-
do
38-
if [[ "$f" = *\.deb* ]]
39-
then
40-
echo Installing $f
41-
scp -P 2222 $f root@localhost:~/
42-
ssh root@localhost -p 2222 "dpkg -i $(basename $f)"
43-
fi
44-
done
39+
echo Copying over all debs
40+
scp -P 2222 -r ./debs root@localhost:~/
41+
echo Installing all debs
42+
ssh -p 2222 root@localhost "dpkg -i *.deb"
4543

4644
echo Copying over config file
47-
ssh root@localhost -p 2222 'mkdir -p /var/mobile/Application\ Support/GoCheats/'
45+
ssh -p 2222 root@localhost 'mkdir -p /var/mobile/Application\ Support/GoCheats/'
46+
# scp -P 2222 ./config.json root@localhost:'/var/mobile/Application\ Support/GoCheats/config.json'
4847
scp -P 2222 ./config.json root@localhost:/var/mobile/Application\ Support/GoCheats/config.json
48+
ssh -p 2222 root@localhost "chown -R mobile:mobile /var/mobile/Application\ Support/GoCheats/"
4949

50-
echo Phone clean - removing debs
51-
ssh root@localhost -p 2222 'rm ~/*.deb'
50+
echo Phone clean - removing debs - respring
51+
ssh -p 2222 root@localhost 'rm -rf debs'
52+
ssh -p 2222 root@localhost 'sbreload'

src/DEBIAN/control

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ Name: dmon
88
Package: com.github.clburlison.dmon
99
Section: Tweaks
1010
Tag: purpose::extension, role::enduser
11-
Version: 0.0.6
11+
Version: 0.0.7

src/DEBIAN/postinst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/bash
22

3-
/usr/bin/launchctl unload /Library/LaunchDaemons/com.github.clburlison.dmon.plist || true
3+
/usr/bin/launchctl unload /Library/LaunchDaemons/com.github.clburlison.dmon.plist 2>/dev/null
44
/usr/bin/sleep 2
55
/usr/bin/launchctl load /Library/LaunchDaemons/com.github.clburlison.dmon.plist

src/Library/LaunchDaemons/com.github.clburlison.dmon.plist

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,8 @@
66
<string>com.github.clburlison.dmon</string>
77
<key>ProgramArguments</key>
88
<array>
9-
<string>/bin/bash</string>
109
<string>/usr/bin/dmon</string>
1110
</array>
12-
<key>StartInterval</key>
13-
<integer>180</integer>
14-
<key>LowPriorityIO</key>
15-
<true/>
1611
<key>StandardErrorPath</key>
1712
<string>/dev/null</string>
1813
<key>StandardOutPath</key>

src/usr/bin/dmon

3.31 MB
Binary file not shown.

src/usr/bin/dmon_old

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/usr/bin/bash
2+
3+
# Not perfect. It takes iOS ~10 seconds to register
4+
# the application has been sent to the background
5+
# or crashed. Need to test and see if this is consistent.
6+
get_pogo_pid() {
7+
# echo $(ps aux | grep -i "PokmonGO.app" | grep -v grep | tr -s ' ' | cut -d ' ' -f 2)
8+
echo $(ps ax | grep -i "PokmonGO.app" | grep -v grep | cut -d ' ' -f 2)
9+
}
10+
11+
get_kernbypass_pid() {
12+
echo $(ps ax | grep -i "/usr/bin/kernbypass" | grep -v grep | cut -d ' ' -f 2)
13+
}
14+
15+
get_substrate_pid() {
16+
echo $(ps ax | grep -i "/etc/rc.d/substitute-launcher" | grep -v grep | cut -d ' ' -f 2)
17+
}
18+
19+
restart_pogo() {
20+
echo Restarting POGO and SERVICES
21+
# killall pokemongo
22+
# killall kernbypass
23+
# sleep 1
24+
# killall substrate
25+
# sleep 2
26+
# /etc/rc.d/substitute-launcher
27+
# sleep 5
28+
# sbreload
29+
local pogo_pid=$(get_pogo_pid)
30+
kill -9 $pogo_pid 2>/dev/null
31+
local bypass_pid=$(get_kernbypass_pid)
32+
kill -9 $bypass_pid 2>/dev/null
33+
sleep 5
34+
open com.nianticlabs.pokemongo
35+
echo "done"
36+
}
37+
38+
main() {
39+
local pid=$(get_pogo_pid)
40+
if [ -z "$pid" ]; then
41+
restart_pogo
42+
fi
43+
}
44+
45+
main

0 commit comments

Comments
 (0)