Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Diatrus committed Jun 2, 2021
0 parents commit d3fa341
Show file tree
Hide file tree
Showing 5 changed files with 132 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

.DS_Store
1 change: 1 addition & 0 deletions Bridge.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#import "Task.h"
25 changes: 25 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
BSD 2-Clause License

Copyright (c) 2021, Hayden Seay
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14 changes: 14 additions & 0 deletions Task.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#import <Foundation/Foundation.h>

@interface NSTask : NSObject

- (instancetype __nonnull)init;
- (void)launch;
- (void)setArguments:(NSArray<NSString *> * __nullable)arg1;
- (void)setLaunchPath:(NSString * __nullable)arg1;
- (void)setStandardError:(id __nullable)arg1;
- (void)setStandardOutput:(id __nullable)arg1;
- (id __nullable)standardError;
- (id __nullable)standardOutput;

@end
90 changes: 90 additions & 0 deletions main.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
// Thanks to 1conan's TSSSaver

import Foundation

@_silgen_name("MGCopyAnswer")
func MGCopyAnswer(_: CFString) -> Optional<Unmanaged<CFPropertyList>>

func request(body: [String : String], _ completion: @escaping ((_ success: Bool, _ data: Data?) -> Void)) {
var request = URLRequest(url: URL(string: "https://tsssaver.1conan.com/v2/api/save.php")!)
request.httpMethod = "POST"

do {
request.httpBody = try JSONSerialization.data(withJSONObject: body, options: .prettyPrinted)
} catch let error {
fatalError(error.localizedDescription)
}

request.addValue("text/plain;charset=UTF-8", forHTTPHeaderField: "Content-Type")
request.addValue("*/*", forHTTPHeaderField: "Accept")

URLSession.shared.dataTask(with: request) { data, _, _ -> Void in
if let data = data {
return completion(true, data)
}
return completion(false, nil)
}.resume()
}

guard let ecid = MGCopyAnswer("UniqueChipID" as CFString),
let device = MGCopyAnswer("ProductType" as CFString),
let board = MGCopyAnswer("HWModelStr" as CFString) else {
fatalError("Can't read device values")
}

let ecidInt = ecid.takeRetainedValue() as! Int // Decimal ECID
let deviceString = device.takeRetainedValue() as! String // iPad8,11
let boardString = board.takeRetainedValue() as! String // J27AP

let pipe = Pipe()
let task = NSTask()
task.setLaunchPath("/usr/bin/dimentio")
task.setStandardOutput(pipe)
task.launch()

let outputData = pipe.fileHandleForReading.readDataToEndOfFile()
let output = String(decoding: outputData, as: UTF8.self)
let outputSplit = output.split(whereSeparator: \.isNewline)

let outputSlice = outputSplit.suffix(2)
let neededOutput = Array(outputSlice)

var nonce_d = ""
var generator = ""

for n in 0...1 {
if let range = neededOutput[n].range(of: "nonce_d:") {
nonce_d = neededOutput[n][range.upperBound...].trimmingCharacters(in: .whitespaces)
} else if let range = neededOutput[n].range(of: "Current nonce is") {
generator = neededOutput[n][range.upperBound...].trimmingCharacters(in: .whitespaces)
}
}

var parameters = ["ecid": "\(ecidInt)",
"deviceIdentifier": deviceString,
"boardConfig": boardString,
"captchaResponse": ""]

if nonce_d != "" {
parameters["apnonce"] = nonce_d
parameters["generator"] = generator
}

request(body: parameters) { success, data in
guard success else {
fatalError("Request to TSSSaver was unsuccessful")
}
do {
if let json = try JSONSerialization.jsonObject(with: data!, options: []) as? [String: Any] {
guard let link = json["url"] as? String else {
fatalError("TSSSaver didn't return as expected \(json)")
}
print("Link to blobs: \(link)")
exit(0)
}
} catch {
fatalError("Parser error")
}
}

dispatchMain()

0 comments on commit d3fa341

Please sign in to comment.