mirror of
https://github.com/tihmstar/futurerestore.git
synced 2025-04-20 14:31:41 +00:00
Major code refactor, update idr for a14 fix
This commit is contained in:
parent
06137f3ba4
commit
6406f51650
2
external/idevicerestore
vendored
2
external/idevicerestore
vendored
|
@ -1 +1 @@
|
|||
Subproject commit 6f78f57cd825c84c872af4615da09de59cb8830e
|
||||
Subproject commit b3ac88e2c5c6faeab88eca86bb4ff0f94972d0f7
|
File diff suppressed because it is too large
Load diff
|
@ -19,6 +19,8 @@
|
|||
#include <stdio.h>
|
||||
#include <functional>
|
||||
#include <vector>
|
||||
#include <array>
|
||||
#include <string>
|
||||
#include <dirent.h>
|
||||
#include <sys/stat.h>
|
||||
#include <errno.h>
|
||||
|
@ -50,7 +52,7 @@ public:
|
|||
|
||||
class futurerestore {
|
||||
struct idevicerestore_client_t* _client;
|
||||
char *_ibootBuild = NULL;
|
||||
char *_ibootBuild = nullptr;
|
||||
bool _didInit = false;
|
||||
vector<plist_t> _aptickets;
|
||||
vector<pair<char *, size_t>>_im4ms;
|
||||
|
@ -62,28 +64,23 @@ class futurerestore {
|
|||
bool _serial = false;
|
||||
bool _noRestore = false;
|
||||
|
||||
char *_firmwareJson = NULL;
|
||||
jssytok_t *_firmwareTokens = NULL;;
|
||||
char *__latestManifest = NULL;
|
||||
char *__latestFirmwareUrl = NULL;
|
||||
char *_firmwareJson = nullptr;
|
||||
jssytok_t *_firmwareTokens = nullptr;;
|
||||
char *_latestManifest = nullptr;
|
||||
char *_latestFirmwareUrl = nullptr;
|
||||
|
||||
plist_t _sepbuildmanifest = NULL;
|
||||
plist_t _basebandbuildmanifest = NULL;
|
||||
|
||||
const char *_rosePath = NULL;
|
||||
const char *_sePath = NULL;
|
||||
const char *_savagePath[6];
|
||||
const char *_veridianDGMPath = NULL;
|
||||
const char *_veridianFWMPath = NULL;
|
||||
plist_t _sepbuildmanifest = nullptr;
|
||||
plist_t _basebandbuildmanifest = nullptr;
|
||||
|
||||
const char *_basebandPath = NULL;
|
||||
const char *_sepbuildmanifestPath = NULL;
|
||||
const char *_basebandbuildmanifestPath = NULL;
|
||||
const char *_ramdiskPath = NULL;
|
||||
const char *_kernelPath = NULL;
|
||||
std::string _ramdiskPath;
|
||||
std::string _kernelPath;
|
||||
std::string _sepPath;
|
||||
std::string _sepManifestPath;
|
||||
std::string _basebandPath;
|
||||
std::string _basebandManifestPath;
|
||||
|
||||
const char *_custom_nonce = NULL;
|
||||
const char *_boot_args = NULL;
|
||||
const char *_custom_nonce = nullptr;
|
||||
const char *_boot_args = nullptr;
|
||||
|
||||
bool _noCache = false;
|
||||
bool _skipBlob = false;
|
||||
|
@ -92,8 +89,7 @@ class futurerestore {
|
|||
bool _rerestoreiOS9 = false;
|
||||
//methods
|
||||
void enterPwnRecovery(plist_t build_identity, std::string bootargs);
|
||||
void enterPwnRecovery2(plist_t build_identity, std::string bootargs = "");
|
||||
|
||||
|
||||
public:
|
||||
futurerestore(bool isUpdateInstall = false, bool isPwnDfu = false, bool noIBSS = false, bool setNonce = false, bool serial = false, bool noRestore = false);
|
||||
bool init();
|
||||
|
@ -115,43 +111,44 @@ public:
|
|||
const char *getDeviceBoardNoCopy();
|
||||
char *getLatestManifest();
|
||||
char *getLatestFirmwareUrl();
|
||||
std::string getSepManifestPath(){return _sepManifestPath;}
|
||||
std::string getBasebandManifestPath(){return _basebandManifestPath;}
|
||||
void downloadLatestRose();
|
||||
void downloadLatestSE();
|
||||
void downloadLatestSavage();
|
||||
void downloadLatestVeridian();
|
||||
void downloadLatestFirmwareComponents();
|
||||
void loadLatestBaseband();
|
||||
void loadLatestSep();
|
||||
void downloadLatestBaseband();
|
||||
void downloadLatestSep();
|
||||
|
||||
void setSepManifestPath(const char *sepManifestPath);
|
||||
void setBasebandManifestPath(const char *basebandManifestPath);
|
||||
void loadRose(const char *rosePath);
|
||||
void loadSE(const char *sePath);
|
||||
void loadSavage(const char *savagePath[6]);
|
||||
void loadVeridian(const char *veridianDGMPath, const char *veridianFWMPath);
|
||||
void loadRamdisk(const char *ramdiskPath);
|
||||
void loadKernel(const char *kernelPath);
|
||||
void loadSep(const char *sepPath);
|
||||
void setBasebandPath(const char *basebandPath);
|
||||
void setRamdiskPath(const char *ramdiskPath);
|
||||
void setKernelPath(const char *kernelPath);
|
||||
void loadSepManifest(std::string sepManifestPath);
|
||||
void loadBasebandManifest(std::string basebandManifestPath);
|
||||
void loadRose(std::string rosePath);
|
||||
void loadSE(std::string sePath);
|
||||
void loadSavage(std::array<std::string, 6> savagePaths);
|
||||
void loadVeridian(std::string veridianDGMPath, std::string veridianFWMPath);
|
||||
void loadRamdisk(std::string ramdiskPath);
|
||||
void loadKernel(std::string kernelPath);
|
||||
void loadSep(std::string sepPath);
|
||||
void loadBaseband(std::string basebandPath);
|
||||
|
||||
void setSepPath(std::string sepPath) {_sepPath = sepPath;}
|
||||
void setSepManifestPath(std::string sepManifestPath) {_sepManifestPath = sepManifestPath;}
|
||||
void setRamdiskPath(std::string ramdiskPath) {_ramdiskPath = ramdiskPath;}
|
||||
void setKernelPath(std::string kernelPath) {_kernelPath = kernelPath;}
|
||||
void setBasebandPath(std::string basebandPath) {_basebandPath = basebandPath;}
|
||||
void setBasebandManifestPath(std::string basebandManifestPath) {_basebandManifestPath = basebandManifestPath;}
|
||||
void setNonce(const char *custom_nonce){_custom_nonce = custom_nonce;};
|
||||
void setBootArgs(const char *boot_args){_boot_args = boot_args;};
|
||||
void disableCache(){_noCache = true;};
|
||||
void skipBlobValidation(){_skipBlob = true;};
|
||||
bool isUpdateInstall(){return _isUpdateInstall;};
|
||||
|
||||
plist_t sepManifest(){return _sepbuildmanifest;};
|
||||
plist_t basebandManifest(){return _basebandbuildmanifest;};
|
||||
const char *sepManifestPath(){return _sepbuildmanifestPath;};
|
||||
const char *basebandManifestPath(){return _basebandbuildmanifestPath;};
|
||||
|
||||
bool is32bit(){return !is_image4_supported(_client);};
|
||||
|
||||
uint64_t getBasebandGoldCertIDFromDevice();
|
||||
|
||||
void doRestore(const char *ipsw);
|
||||
int doJustBoot(const char *ipsw, std::string bootargs = "");
|
||||
|
||||
|
||||
~futurerestore();
|
||||
|
||||
static std::pair<const char *,size_t> getRamdiskHashFromSCAB(const char* scab, size_t scabSize);
|
||||
|
@ -160,8 +157,8 @@ public:
|
|||
static plist_t loadPlistFromFile(const char *path);
|
||||
static void saveStringToFile(const char *str, const char *path);
|
||||
static char *getPathOfElementInManifest(const char *element, const char *manifeststr, const char *boardConfig, int isUpdateInstall);
|
||||
bool elemExists(const char *element, const char *manifeststr, const char *boardConfig, int isUpdateInstall);
|
||||
static std::string getGeneratorFromSHSH2(const plist_t shsh2);
|
||||
static bool elemExists(const char *element, const char *manifeststr, const char *boardConfig, int isUpdateInstall);
|
||||
static std::string getGeneratorFromSHSH2(plist_t shsh2);
|
||||
};
|
||||
|
||||
#endif /* futurerestore_hpp */
|
||||
|
|
|
@ -6,11 +6,7 @@
|
|||
// Copyright © 2016 tihmstar. All rights reserved.
|
||||
//
|
||||
|
||||
#include <iostream>
|
||||
#include <getopt.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <vector>
|
||||
#include "futurerestore.hpp"
|
||||
|
||||
extern "C"{
|
||||
|
@ -34,31 +30,31 @@ extern "C"{
|
|||
#endif
|
||||
|
||||
static struct option longopts[] = {
|
||||
{ "apticket", required_argument, NULL, 't' },
|
||||
{ "baseband", required_argument, NULL, 'b' },
|
||||
{ "baseband-manifest", required_argument, NULL, 'p' },
|
||||
{ "sep", required_argument, NULL, 's' },
|
||||
{ "sep-manifest", required_argument, NULL, 'm' },
|
||||
{ "wait", no_argument, NULL, 'w' },
|
||||
{ "update", no_argument, NULL, 'u' },
|
||||
{ "debug", no_argument, NULL, 'd' },
|
||||
{ "exit-recovery", no_argument, NULL, 'e' },
|
||||
{ "latest-sep", no_argument, NULL, '0' },
|
||||
{ "no-restore", no_argument, NULL, 'z' },
|
||||
{ "latest-baseband", no_argument, NULL, '1' },
|
||||
{ "no-baseband", no_argument, NULL, '2' },
|
||||
{ "apticket", required_argument, nullptr, 't' },
|
||||
{ "baseband", required_argument, nullptr, 'b' },
|
||||
{ "baseband-manifest", required_argument, nullptr, 'p' },
|
||||
{ "sep", required_argument, nullptr, 's' },
|
||||
{ "sep-manifest", required_argument, nullptr, 'm' },
|
||||
{ "wait", no_argument, nullptr, 'w' },
|
||||
{ "update", no_argument, nullptr, 'u' },
|
||||
{ "debug", no_argument, nullptr, 'd' },
|
||||
{ "exit-recovery", no_argument, nullptr, 'e' },
|
||||
{ "latest-sep", no_argument, nullptr, '0' },
|
||||
{ "no-restore", no_argument, nullptr, 'z' },
|
||||
{ "latest-baseband", no_argument, nullptr, '1' },
|
||||
{ "no-baseband", no_argument, nullptr, '2' },
|
||||
#ifdef HAVE_LIBIPATCHER
|
||||
{ "use-pwndfu", no_argument, NULL, '3' },
|
||||
{ "no-ibss", no_argument, NULL, '4' },
|
||||
{ "rdsk", required_argument, NULL, '5' },
|
||||
{ "rkrn", required_argument, NULL, '6' },
|
||||
{ "set-nonce", optional_argument, NULL, '7' },
|
||||
{ "serial", no_argument, NULL, '8' },
|
||||
{ "boot-args", required_argument, NULL, '9' },
|
||||
{ "no-cache", no_argument, NULL, 'a' },
|
||||
{ "skip-blob", no_argument, NULL, 'c' },
|
||||
{ "use-pwndfu", no_argument, nullptr, '3' },
|
||||
{ "no-ibss", no_argument, nullptr, '4' },
|
||||
{ "rdsk", required_argument, nullptr, '5' },
|
||||
{ "rkrn", required_argument, nullptr, '6' },
|
||||
{ "set-nonce", optional_argument, nullptr, '7' },
|
||||
{ "serial", no_argument, nullptr, '8' },
|
||||
{ "boot-args", required_argument, nullptr, '9' },
|
||||
{ "no-cache", no_argument, nullptr, 'a' },
|
||||
{ "skip-blob", no_argument, nullptr, 'c' },
|
||||
#endif
|
||||
{ NULL, 0, NULL, 0 }
|
||||
{ nullptr, 0, nullptr, 0 }
|
||||
};
|
||||
|
||||
#define FLAG_WAIT 1 << 0
|
||||
|
@ -136,28 +132,24 @@ int main_r(int argc, const char * argv[]) {
|
|||
#endif
|
||||
|
||||
int optindex = 0;
|
||||
int opt = 0;
|
||||
int opt;
|
||||
long flags = 0;
|
||||
bool exitRecovery = false;
|
||||
bool noRestore = false;
|
||||
|
||||
int isSepManifestSigned = 0;
|
||||
int isBasebandSigned = 0;
|
||||
|
||||
const char *ipsw = NULL;
|
||||
const char *basebandPath = NULL;
|
||||
const char *basebandManifestPath = NULL;
|
||||
const char *sepPath = NULL;
|
||||
const char *sepManifestPath = NULL;
|
||||
const char *bootargs = NULL;
|
||||
const char *ramdiskPath = NULL;
|
||||
const char *kernelPath = NULL;
|
||||
const char *custom_nonce = NULL;
|
||||
const char *ipsw = nullptr;
|
||||
const char *basebandPath = nullptr;
|
||||
const char *basebandManifestPath = nullptr;
|
||||
const char *sepPath = nullptr;
|
||||
const char *sepManifestPath = nullptr;
|
||||
const char *bootargs = nullptr;
|
||||
const char *ramdiskPath = nullptr;
|
||||
const char *kernelPath = nullptr;
|
||||
const char *custom_nonce = nullptr;
|
||||
|
||||
vector<const char*> apticketPaths;
|
||||
|
||||
t_devicevals devVals = {0};
|
||||
t_iosVersion versVals = {0};
|
||||
t_devicevals devVals = {nullptr};
|
||||
t_iosVersion versVals = {nullptr};
|
||||
|
||||
if (argc == 1){
|
||||
cmd_help();
|
||||
|
@ -213,11 +205,11 @@ int main_r(int argc, const char * argv[]) {
|
|||
break;
|
||||
case '7': // long option: "set-nonce";
|
||||
flags |= FLAG_SET_NONCE;
|
||||
custom_nonce = (optarg) ? optarg : NULL;
|
||||
if(custom_nonce != NULL) {
|
||||
custom_nonce = (optarg) ? optarg : nullptr;
|
||||
if(custom_nonce != nullptr) {
|
||||
uint64_t gen;
|
||||
retassure(strlen(custom_nonce) == 16 || strlen(custom_nonce) == 18,"Incorrect nonce length!\n");
|
||||
sscanf(custom_nonce, "0x%16llx",&gen);
|
||||
gen = std::stoul(custom_nonce, nullptr, 16);
|
||||
retassure(gen, "failed to parse generator. Make sure it is in format 0x%16llx");
|
||||
}
|
||||
break;
|
||||
|
@ -226,7 +218,7 @@ int main_r(int argc, const char * argv[]) {
|
|||
break;
|
||||
case '9': // long option: "boot-args";
|
||||
flags |= FLAG_BOOT_ARGS;
|
||||
bootargs = (optarg) ? optarg : NULL;
|
||||
bootargs = (optarg) ? optarg : nullptr;
|
||||
break;
|
||||
case 'a': // long option: "no-cache";
|
||||
flags |= FLAG_NO_CACHE;
|
||||
|
@ -251,7 +243,6 @@ int main_r(int argc, const char * argv[]) {
|
|||
}
|
||||
|
||||
if (argc-optind == 1) {
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
|
||||
ipsw = argv[0];
|
||||
|
@ -303,10 +294,12 @@ int main_r(int argc, const char * argv[]) {
|
|||
}
|
||||
|
||||
try {
|
||||
if (apticketPaths.size()) client.loadAPTickets(apticketPaths);
|
||||
if (!apticketPaths.empty()) {
|
||||
client.loadAPTickets(apticketPaths);
|
||||
}
|
||||
|
||||
if (!(
|
||||
((apticketPaths.size() && ipsw)
|
||||
((!apticketPaths.empty() && ipsw)
|
||||
&& ((basebandPath && basebandManifestPath) || ((flags & FLAG_LATEST_BASEBAND) || (flags & FLAG_NO_BASEBAND)))
|
||||
&& ((sepPath && sepManifestPath) || (flags & FLAG_LATEST_SEP) || client.is32bit())
|
||||
) || (ipsw && (flags & FLAG_IS_PWN_DFU))
|
||||
|
@ -355,14 +348,14 @@ int main_r(int argc, const char * argv[]) {
|
|||
|
||||
if (flags & FLAG_LATEST_SEP){
|
||||
info("user specified to use latest signed SEP\n");
|
||||
client.loadLatestSep();
|
||||
client.downloadLatestSep();
|
||||
}else if (!client.is32bit()){
|
||||
client.loadSep(sepPath);
|
||||
client.setSepManifestPath(sepManifestPath);
|
||||
client.loadSepManifest(sepManifestPath);
|
||||
}
|
||||
|
||||
versVals.basebandMode = kBasebandModeWithoutBaseband;
|
||||
if (!client.is32bit() && !(isSepManifestSigned = isManifestSignedForDevice(client.sepManifestPath(), &devVals, &versVals, NULL))){
|
||||
if (!client.is32bit() && !(isManifestSignedForDevice(client.getSepManifestPath().c_str(), &devVals, &versVals, nullptr))){
|
||||
reterror("SEP firmware is NOT being signed!\n");
|
||||
}
|
||||
if (flags & FLAG_NO_BASEBAND){
|
||||
|
@ -379,10 +372,10 @@ int main_r(int argc, const char * argv[]) {
|
|||
}else{
|
||||
if (flags & FLAG_LATEST_BASEBAND){
|
||||
info("user specified to use latest signed baseband\n");
|
||||
client.loadLatestBaseband();
|
||||
client.downloadLatestBaseband();
|
||||
}else{
|
||||
client.setBasebandPath(basebandPath);
|
||||
client.setBasebandManifestPath(basebandManifestPath);
|
||||
client.loadBasebandManifest(basebandManifestPath);
|
||||
printf("Did set SEP+baseband path and firmware\n");
|
||||
}
|
||||
|
||||
|
@ -390,7 +383,7 @@ int main_r(int argc, const char * argv[]) {
|
|||
if (!(devVals.bbgcid = client.getBasebandGoldCertIDFromDevice())){
|
||||
printf("[WARNING] using tsschecker's fallback to get BasebandGoldCertID. This might result in invalid baseband signing status information\n");
|
||||
}
|
||||
if (!(isBasebandSigned = isManifestSignedForDevice(client.basebandManifestPath(), &devVals, &versVals, NULL))) {
|
||||
if (!(isManifestSignedForDevice(client.getBasebandManifestPath().c_str(), &devVals, &versVals, nullptr))) {
|
||||
reterror("baseband firmware is NOT being signed!\n");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue