-
Notifications
You must be signed in to change notification settings - Fork 5
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 d3fa341
Showing
5 changed files
with
132 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,2 @@ | ||
|
||
.DS_Store |
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 @@ | ||
#import "Task.h" |
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,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. |
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,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 |
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,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() |