-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 611b3c4
Showing
15 changed files
with
3,087 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
xcuserdata | ||
*.xcworkspacedata | ||
xcshareddata |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# oslo | ||
|
||
An `os_log` viewer for iOS that supports streaming both real-time logs and archived logs. | ||
|
||
## Features | ||
- View real-time logs | ||
- View archived logs (even if they weren't streamed live) | ||
- Does not include logs prior to the last reboot | ||
- Unredacts `<private>` values in log messages | ||
- Process name filtering | ||
- Syntax highlighting by [kat](https://github.com/Theldus/kat/tree/master) | ||
- PID-based grouping + last-log filtering | ||
- "for each recent crash of `<process>`, show the last couple of logs that were printed before it terminated, grouped by PID and ordered by last-event-in-group timestamp" | ||
|
||
|
||
## Usage | ||
|
||
``` | ||
oslo [-l] [-s] [-g] [ProcessName] | ||
Options: | ||
-l Live logs (default) | ||
-s Stored/archived logs | ||
-g Group logs by PID (requires -s) | ||
ProcessName Filter by process name | ||
``` | ||
|
||
|
||
[](https://asciinema.org/a/tet26ugcwutH0CIwjKeS99C1P?poster=npt:07) | ||
|
||
|
||
Tested on iOS 14.0 - 18.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
import os | ||
import subprocess | ||
from dataclasses import dataclass | ||
from pathlib import Path | ||
from typing import Optional | ||
|
||
DEVICE_SSH_PORT = "2222" | ||
DEVICE_SSH_IP = "localhost" | ||
LOCAL_LDID2_PATH = "/opt/homebrew/bin/ldid2" | ||
|
||
|
||
@dataclass | ||
class BinaryInstallInformation: | ||
# The on-device path to copy the binary to | ||
on_device_path: str | ||
# An entitlements file to sign the local binary with before copying to the device. | ||
# If no file is specified, the binary will be signed without explicit entitlements | ||
entitlements_file: Optional[str] = None | ||
|
||
|
||
BINARY_DEPLOY_INFO = { | ||
"oslo": BinaryInstallInformation("/var/jb/usr/bin/oslo", "entitlements.xml"), | ||
} | ||
|
||
|
||
def run_command_on_device(command: str) -> bytes: | ||
return subprocess.check_output( | ||
f'ssh -oStricthostkeychecking=no -oUserknownhostsfile=/dev/null -p {DEVICE_SSH_PORT} root@{DEVICE_SSH_IP} "{command}"', | ||
shell=True, | ||
) | ||
|
||
|
||
def copy_file_to_device(local: str, remote: str) -> None: | ||
subprocess.check_output( | ||
f'scp -O -oStricthostkeychecking=no -oUserknownhostsfile=/dev/null -P {DEVICE_SSH_PORT} "{local}" root@{DEVICE_SSH_IP}:"{remote}"', | ||
shell=True, | ||
) | ||
|
||
|
||
def deploy_to_device(local_path: Path, binary_deploy_info: BinaryInstallInformation) -> None: | ||
# Sign the local binary | ||
if not Path(LOCAL_LDID2_PATH).exists(): | ||
raise Exception(f"Ldid2 path does not exist locally! {LOCAL_LDID2_PATH}") | ||
|
||
ldid_cmd_args = [LOCAL_LDID2_PATH] | ||
if binary_deploy_info.entitlements_file: | ||
ldid_cmd_args.append(f"-S{binary_deploy_info.entitlements_file}") | ||
else: | ||
ldid_cmd_args.append("-S") | ||
ldid_cmd_args.append(local_path.as_posix()) | ||
print(ldid_cmd_args) | ||
# print(subprocess.check_output(ldid_cmd_args)) | ||
|
||
# Delete existing binary on-device if it exists | ||
try: | ||
run_command_on_device(f"/var/jb/usr/bin/rm {binary_deploy_info.on_device_path}") | ||
except: | ||
print(f"failed to delete on-device binary {binary_deploy_info.on_device_path}") | ||
pass | ||
|
||
# Ensure the target install directory exists on-device | ||
try: | ||
on_device_destination_parent_dir = Path(binary_deploy_info.on_device_path).parent | ||
run_command_on_device(f"mkdir -p {on_device_destination_parent_dir.as_posix()}") | ||
except: | ||
# Dir already exists? | ||
pass | ||
|
||
# Copy local signed binary to device | ||
try: | ||
copy_file_to_device(local_path, binary_deploy_info.on_device_path) | ||
except Exception as e: | ||
raise Exception(f"Failed to copy {binary_deploy_info.on_device_path} to device with error: {e}") | ||
|
||
try: | ||
copy_file_to_device(binary_deploy_info.entitlements_file, "/tmp/entitlements.xml") | ||
except Exception as e: | ||
print(f"Failed to copy entitlements file to device with error: {e}") | ||
pass | ||
|
||
run_command_on_device(f"/var/jb/usr/bin/ldid -S/tmp/entitlements.xml {binary_deploy_info.on_device_path}") | ||
|
||
|
||
if __name__ == "__main__": | ||
print("deploying binaries device") | ||
|
||
if "BUILT_PRODUCTS_DIR" not in os.environ: | ||
raise Exception("BUILT_PRODUCTS_DIR not found") | ||
|
||
BUILT_PRODUCTS_DIR = Path(os.environ["BUILT_PRODUCTS_DIR"]) | ||
if not BUILT_PRODUCTS_DIR.exists(): | ||
raise Exception("BUILT_PRODUCTS_DIR var exists but directory does not") | ||
|
||
for framework_path in BUILT_PRODUCTS_DIR.glob("*.framework"): | ||
fw_binary_path = framework_path / framework_path.stem | ||
if not fw_binary_path.exists(): | ||
raise Exception(f"file does not exist: {fw_binary_path}") | ||
|
||
if framework_path.stem not in BINARY_DEPLOY_INFO: | ||
continue | ||
|
||
binary_deploy_info = BINARY_DEPLOY_INFO[framework_path.stem] | ||
deploy_to_device(fw_binary_path, binary_deploy_info) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?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>platform-application</key> | ||
<true/> | ||
<key>com.apple.private.logging.admin</key> | ||
<true/> | ||
<key>com.apple.private.logging.diagnostic</key> | ||
<true/> | ||
<key>com.apple.private.logging.stream</key> | ||
<true/> | ||
</dict> | ||
</plist> | ||
|
Oops, something went wrong.