From a9b7068e8db6cb41dd1081f0ac424d373d517191 Mon Sep 17 00:00:00 2001 From: Vlad Frangu Date: Sat, 11 Nov 2023 21:23:30 +0200 Subject: [PATCH 1/5] feat: sideload fixer in tweak --- README.md | 7 +++++++ Sources/VendettaTweak/Tweak.x.swift | 15 +++++++++++++++ control | 2 +- 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..6fd4b75 --- /dev/null +++ b/README.md @@ -0,0 +1,7 @@ +# VendettaTweak + +A rootful/rootless tweak to inject Vendetta into a Discord IPA. + +## Installation + +When injecting this via [`azule`](https://github.com/Al4ise/Azule/tree/main), use the rootful `deb` files (the ones ending in `arm.deb` NOT `arm64.deb`) diff --git a/Sources/VendettaTweak/Tweak.x.swift b/Sources/VendettaTweak/Tweak.x.swift index 75448b3..e5fa692 100644 --- a/Sources/VendettaTweak/Tweak.x.swift +++ b/Sources/VendettaTweak/Tweak.x.swift @@ -1,6 +1,7 @@ import Orion import VendettaTweakC import os +import Foundation let vendettaLog = OSLog(subsystem: Bundle.main.bundleIdentifier!, category: "vendetta") let source = URL(string: "vendetta")! @@ -13,6 +14,20 @@ let vendettaPatchesBundlePath = ? "\(install_prefix)/Library/Application Support/VendettaTweak/VendettaPatches.bundle" : "\(Bundle.main.bundleURL.path)/VendettaPatches.bundle" +class FileManagerLoadHook: ClassHook { + func containerURLForSecurityApplicationGroupIdentifier(_ groupIdentifier: NSString?) -> URL? { + os_log("containerURLForSecurityApplicationGroupIdentifier called! %{public}@ groupIdentifier", log: vendettaLog, type: .debug, groupIdentifier ?? "nil") + + if groupIdentifier != nil { + let paths = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask) + let lastPath = paths.last! + return lastPath.appendingPathComponent("AppGroup") + } + + return orig.containerURLForSecurityApplicationGroupIdentifier(groupIdentifier) + } +} + class LoadHook: ClassHook { func executeApplicationScript(_ script: Data, url: URL, async: Bool) { os_log("executeApplicationScript called!", log: vendettaLog, type: .debug) diff --git a/control b/control index d9a817c..2ba1f85 100644 --- a/control +++ b/control @@ -1,6 +1,6 @@ Package: dev.beefers.vendetta Name: Vendetta -Version: 0.0.1 +Version: 0.0.2 Architecture: iphoneos-arm Description: A mod for Discord's mobile apps. Maintainer: FieryFlames From ccae01977073444fb93d89235a7bd6d67464c7b3 Mon Sep 17 00:00:00 2001 From: Vlad Frangu Date: Sat, 11 Nov 2023 21:24:07 +0200 Subject: [PATCH 2/5] chore: this aint just for IPAs --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6fd4b75..c159766 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # VendettaTweak -A rootful/rootless tweak to inject Vendetta into a Discord IPA. +A rootful/rootless tweak to inject Vendetta into Discord. ## Installation From 7a64e54dfe890d35fc3c17405aaefdf3320b15c5 Mon Sep 17 00:00:00 2001 From: Vlad Frangu Date: Sat, 11 Nov 2023 21:26:17 +0200 Subject: [PATCH 3/5] chore: remove useless import --- Sources/VendettaTweak/Tweak.x.swift | 1 - 1 file changed, 1 deletion(-) diff --git a/Sources/VendettaTweak/Tweak.x.swift b/Sources/VendettaTweak/Tweak.x.swift index e5fa692..144a5ef 100644 --- a/Sources/VendettaTweak/Tweak.x.swift +++ b/Sources/VendettaTweak/Tweak.x.swift @@ -1,7 +1,6 @@ import Orion import VendettaTweakC import os -import Foundation let vendettaLog = OSLog(subsystem: Bundle.main.bundleIdentifier!, category: "vendetta") let source = URL(string: "vendetta")! From 533aeeeb51fa5e9d99a8f6a6ee8b23924c565fcc Mon Sep 17 00:00:00 2001 From: Vlad Frangu Date: Sat, 11 Nov 2023 21:39:40 +0200 Subject: [PATCH 4/5] chore: suggested changes --- Sources/VendettaTweak/Tweak.x.swift | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/Sources/VendettaTweak/Tweak.x.swift b/Sources/VendettaTweak/Tweak.x.swift index 144a5ef..ba54204 100644 --- a/Sources/VendettaTweak/Tweak.x.swift +++ b/Sources/VendettaTweak/Tweak.x.swift @@ -6,24 +6,25 @@ let vendettaLog = OSLog(subsystem: Bundle.main.bundleIdentifier!, category: "ven let source = URL(string: "vendetta")! let install_prefix = String(cString: get_install_prefix()) +let isJailbroken = FileManager.default.fileExists(atPath: "\(install_prefix)/Library/Application Support/VendettaTweak/VendettaPatches.bundle") -let vendettaPatchesBundlePath = - FileManager.default.fileExists( - atPath: "\(install_prefix)/Library/Application Support/VendettaTweak/VendettaPatches.bundle") - ? "\(install_prefix)/Library/Application Support/VendettaTweak/VendettaPatches.bundle" - : "\(Bundle.main.bundleURL.path)/VendettaPatches.bundle" +let vendettaPatchesBundlePath = if isJailbroken { + "\(install_prefix)/Library/Application Support/VendettaTweak/VendettaPatches.bundle" +} else { + "\(Bundle.main.bundleURL.path)/VendettaPatches.bundle" +} class FileManagerLoadHook: ClassHook { func containerURLForSecurityApplicationGroupIdentifier(_ groupIdentifier: NSString?) -> URL? { os_log("containerURLForSecurityApplicationGroupIdentifier called! %{public}@ groupIdentifier", log: vendettaLog, type: .debug, groupIdentifier ?? "nil") - if groupIdentifier != nil { - let paths = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask) - let lastPath = paths.last! - return lastPath.appendingPathComponent("AppGroup") + if (isJailbroken) { + return orig.containerURLForSecurityApplicationGroupIdentifier(groupIdentifier) } - return orig.containerURLForSecurityApplicationGroupIdentifier(groupIdentifier) + let paths = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask) + let lastPath = paths.last! + return lastPath.appendingPathComponent("AppGroup") } } From 79ebc7fccc310be75a1554108f6731a6ea2b3d1b Mon Sep 17 00:00:00 2001 From: Vlad Frangu Date: Sat, 11 Nov 2023 23:38:48 +0200 Subject: [PATCH 5/5] chore: readme --- README.md | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c159766..70528ac 100644 --- a/README.md +++ b/README.md @@ -4,4 +4,57 @@ A rootful/rootless tweak to inject Vendetta into Discord. ## Installation -When injecting this via [`azule`](https://github.com/Al4ise/Azule/tree/main), use the rootful `deb` files (the ones ending in `arm.deb` NOT `arm64.deb`) +### Jailbroken (Rootful/Rootless) + +1. Install Orion runtime via your preferred package manager, by adding `https://repo.chariz.com/` to your sources, then finding `Orion Runtime`. +1. Install Vendetta by downloading the appropriate `.deb` file (or by building your own, see [Building VendettaTweak locally](#building-vendettatweak-locally)). Use the file ending in `arm.deb` for rootful jailbreaks, and the file ending in `arm64.deb` for rootless jailbreaks. + +### Non-Jailbroken + +1. Download Orion from [here](https://github.com/theos/orion/releases). You will need the `deb` file ending in `arm.deb` NOT `arm64.deb`. +1. Download the rootful Vendetta `.deb` file (file ending in `arm.deb`) or build your own by following the [Building VendettaTweak locally](#building-vendettatweak-locally) steps. +1. Clone [azule](https://github.com/Al4ise/Azule/tree/main) into a folder and `cd` into it. +1. Extract or obtain a decrypted Discord IPA. To extract the IPA from a jailbroken iDevice, we recommend [bagbak](https://github.com/ChiChou/bagbak). +1. Run `./azule -i -o -f `. Make sure to provide the full paths to the files (you cannot use relative paths unfortunately). Example: `./azule -i /Users/vendetta/IPA/Discord.ipa -o /Users/vendetta/IPA/VendettaDiscord -f /Users/vendetta/IPA/dev.theos.orion14_1.0.1_iphoneos-arm.deb /Users/vendetta/IPA/dev.beefers.vendetta_0.0.2_iphoneos-arm.deb` +1. Install the generated IPA using your preferred sideloading method (at the time of writing this, only Sideloadly works). + +## Building VendettaTweak locally + +> **Note** +> These steps assume you use MacOS. + +1. Install Xcode from the App Store. If you've previously installed the `Command Line Utilities` package, you will need to run `sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer` to make sure you're using the Xcode tools instead. + +> If you want to revert the `xcode-select` change, run `sudo xcode-select -switch /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk` + +2. Install the required dependencies. You can do this by running `brew install make ldid` in your terminal. If you do not have brew installed, follow the instructions [here](https://brew.sh/). + +3. Setup your path accordingly. We recommend you run the following before running the next commands, as well as any time you want to build VendettaTweak. + +```bash +export PATH="$(brew --prefix make)/libexec/gnubin:$PATH" +# feel free to set whatever path you want, but it needs to be a direct path, without relative parts +export THEOS="/Users/vendetta/IPA/theos" +``` + +4. Setup [theos](https://theos.dev/docs/installation-macos) by running the script provided by theos. + +```bash +bash -c "$(curl -fsSL https://raw.githubusercontent.com/theos/theos/master/bin/install-theos)" +``` + +If you've already installed theos, you can run `$THEOS/bin/update-theos` to make sure it's up to date. + +5. Clone this repository with `git clone git@github.com:vendetta-mod/VendettaTweak.git --recurse-submodules` and `cd` into it. Replace the URL with your fork if you've forked this repository. + +6. To build VendettaTweak, you can run `rm -rf packages && make clean && make package FINALPACKAGE=1 && make package FINALPACKAGE=1 THEOS_PACKAGE_SCHEME=rootless`. The first command will remove any previous packages, the second will clean the project, the third will build the rootful package (which is denoted by the `arm.deb` ending), and the fourth will build the rootless package (which is denoted by the `arm64.deb` ending). + +The first time you run this, it might take a bit longer, but subsequent builds should be much faster. + +The resulting `.deb` files will be in the `packages` folder. As a reminder, `*arm.deb` is for rootful jailbreaks and sideloading, and `*arm64.deb` is for rootless jailbreaks. + +## Contributing + +If you want to contribute, you will basically need to follow the steps for [Building VendettaTweak locally](#building-vendettatweak-locally), as well as run `make spm` for the Swift LSP to work. + +