Skip to content
This repository has been archived by the owner on Feb 4, 2023. It is now read-only.

Commit

Permalink
Bug Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Lakr233 committed Jan 22, 2022
1 parent 6088ee1 commit 91de305
Show file tree
Hide file tree
Showing 8 changed files with 141 additions and 18 deletions.
4 changes: 2 additions & 2 deletions Application/iridium.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_IDENTITY = "iPhone Developer";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 13;
CURRENT_PROJECT_VERSION = 15;
DEVELOPMENT_TEAM = GXZ23M5TP2;
ENABLE_BITCODE = NO;
GENERATE_INFOPLIST_FILE = YES;
Expand Down Expand Up @@ -449,7 +449,7 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_IDENTITY = "iPhone Developer";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 13;
CURRENT_PROJECT_VERSION = 15;
DEVELOPMENT_TEAM = GXZ23M5TP2;
ENABLE_BITCODE = NO;
GENERATE_INFOPLIST_FILE = YES;
Expand Down
1 change: 1 addition & 0 deletions Application/iridium/Backend/AgentWrapper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class Agent {
} else {
#if DEBUG
debugPrint("binary for auxiliary agent was not found, ignored due to debug build")
binaryLocation = URL(fileURLWithPath: "/\(UUID().uuidString)")
#else
fatalError("could not find auxiliary agent on system")
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,14 +153,17 @@ class DecrypterViewController: UIViewController {
available: {
self.decryptResult != nil
},
action: { _ in
action: { sourceController in
guard let item = self.decryptResult else {
return
}
let activityViewController = UIActivityViewController(
activityItems: [item],
applicationActivities: nil
)
if let wppc = activityViewController.popoverPresentationController {
wppc.sourceView = sourceController.view
}
self.present(
activityViewController,
animated: true,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
//
// AuxiliaryExecute+Spawn.swift
// AuxiliaryExecute
//
// Created by Cyandev on 2022/1/10.
//

#if swift(>=5.5)

import Foundation

@available(iOS 15.0, macOS 12.0.0, *)
public extension AuxiliaryExecute {
/// async/await function for spawn using withCheckedContinuation
/// - Parameters:
/// - command: full path of the binary file. eg: "/bin/cat"
/// - args: arg to pass to the binary, exclude argv[0] which is the path itself. eg: ["nya"]
/// - environment: any environment to be appended/overwrite when calling posix spawn. eg: ["mua" : "nya"]
/// - timeout: any wall timeout if lager than 0, in seconds. eg: 6
/// - stdout: a block call from pipeControlQueue in background when buffer from stdout available for read
/// - stderr: a block call from pipeControlQueue in background when buffer from stderr available for read
/// - Returns: execution recipe, see it's definition for details
@discardableResult
static func spawnAsync(
command: String,
args: [String] = [],
environment: [String: String] = [:],
timeout: Double = 0,
stdoutBlock: ((String) -> Void)? = nil,
stderrBlock: ((String) -> Void)? = nil
) async -> ExecuteRecipe {
await withCheckedContinuation { cont in
self.spawn(
command: command,
args: args,
environment: environment,
timeout: timeout,
stdoutBlock: stdoutBlock,
stderrBlock: stderrBlock
) { recipe in
cont.resume(returning: recipe)
}
}
}

/// async/await function for spawn using withCheckedContinuation
/// - Parameters:
/// - command: full path of the binary file. eg: "/bin/cat"
/// - args: arg to pass to the binary, exclude argv[0] which is the path itself. eg: ["nya"]
/// - environment: any environment to be appended/overwrite when calling posix spawn. eg: ["mua" : "nya"]
/// - timeout: any wall timeout if lager than 0, in seconds. eg: 6
/// - output: a block call from pipeControlQueue in background when buffer from stdout or stderr available for read
/// - Returns: execution recipe, see it's definition for details
@discardableResult
static func spawnAsync(
command: String,
args: [String] = [],
environment: [String: String] = [:],
timeout: Double = 0,
output: ((String) -> Void)? = nil
) async -> ExecuteRecipe {
let lock = NSLock()
return await spawnAsync(
command: command,
args: args,
environment: environment,
timeout: timeout,
stdoutBlock: { str in
lock.lock()
output?(str)
lock.unlock()
}, stderrBlock: { str in
lock.lock()
output?(str)
lock.unlock()
}
)
}
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,19 @@ public extension AuxiliaryExecute {
var wait: pid_t = 0
var isTimeout = false

func handleProcessExit(isTimeout: Bool, status: Int32) {
let timerSource = DispatchSource.makeTimerSource(flags: [], queue: processControlQueue)
timerSource.setEventHandler {
isTimeout = true
kill(pid, SIGKILL)
}

let processSource = DispatchSource.makeProcessSource(identifier: pid, eventMask: .exit, queue: processControlQueue)
processSource.setEventHandler {
wait = waitpid(pid, &status, 0)

processSource.cancel()
timerSource.cancel()

// by using exactly method, we won't crash it!
let recipe = ExecuteRecipe(
exitCode: Int(exactly: status) ?? -1,
Expand All @@ -265,19 +277,10 @@ public extension AuxiliaryExecute {
)
completionBlock?(recipe)
}

let processSource = DispatchSource.makeProcessSource(identifier: pid, eventMask: .exit, queue: processControlQueue)
processSource.setEventHandler {
wait = waitpid(pid, &status, 0)
processSource.cancel()
handleProcessExit(isTimeout: isTimeout, status: status)
}
processSource.resume()

// timeout control
processControlQueue.asyncAfter(deadline: wallTimeout) {
isTimeout = true
kill(pid, SIGKILL)
}
timerSource.schedule(deadline: wallTimeout)
timerSource.resume()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
import XCTest

final class AuxiliaryExecuteTests: XCTestCase {
func testExample() throws {

func testMain() throws {
XCTAssertNotNil(Int(exactly: AuxiliaryExecute.maxTimeoutValue))
XCTAssertNotNil(Int32(exactly: AuxiliaryExecute.maxTimeoutValue))
XCTAssertNotNil(Double(exactly: AuxiliaryExecute.maxTimeoutValue))
Expand Down Expand Up @@ -68,4 +69,38 @@ final class AuxiliaryExecuteTests: XCTestCase {
XCTAssert(result.error == .timeout)
}
}

@available(macOS 12.0.0, *)
func testAsync() async throws {
do {
let result = await AuxiliaryExecute.spawnAsync(
command: "/usr/bin/uname",
args: ["-a"],
timeout: 1
) { stdout in
print(stdout)
} stderrBlock: { stderr in
print(stderr)
}

XCTAssertEqual(result.exitCode, 0)
XCTAssert(result.stdout.contains("Darwin Kernel"))
}

do {
let result = await AuxiliaryExecute.spawnAsync(
command: "/usr/bin/tail",
args: ["-f", "/dev/null"],
timeout: 1
) { stdout in
print(stdout)
} stderrBlock: { stderr in
print(stderr)
}

XCTAssertEqual(result.exitCode, Int(SIGKILL))
XCTAssertEqual(result.error, .timeout)
}
}

}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Iridium

An iOS app decrypter, full static using fouldecrypt. Supporting iOS 13+
An iOS app decrypter, full static using fouldecrypt. Supporting iOS 13.5+

![Preview](./Workflow/Preview/main.png)

Expand Down
2 changes: 1 addition & 1 deletion Workflow/DEBIAN/control
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Author: Lakr Aream <[email protected]>
Maintainer: Lakr Aream <[email protected]>
Version: @@VERSION@@
Section: Applications
Pre-Depends: firmware (>= 13.0)
Pre-Depends: firmware (>= 13.5)
Architecture: iphoneos-arm
depiction: https://moreinfo.thebigboss.org/moreinfo/depiction.php?file=iridiumDp
tag: purpose::uikit

0 comments on commit 91de305

Please sign in to comment.