added patched iboot.img to the ramdisk - doh! Thanks trebonian
This commit is contained in:
Родитель
ef9693f1e8
Коммит
9c581578bf
|
@ -3,11 +3,14 @@
|
|||
|
||||
#include <xpwn/plist.h>
|
||||
#include <xpwn/outputstate.h>
|
||||
#include <hfs/hfsplus.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
Dictionary* parseIPSW(const char* inputIPSW, const char* bundleRoot, char** bundlePath, OutputState** state);
|
||||
int doPatch(StringValue* patchValue, StringValue* fileValue, const char* bundlePath, OutputState** state);
|
||||
void doPatchInPlace(Volume* volume, char* filePath, char* patchPath);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
RANLIB ?= ranlib
|
||||
PCHOBJS=patch.o
|
||||
PCHOBJS=main.o
|
||||
XPWNOBJS=plist.o pwnutil.o outputstate.o nor_files.o 8900.o img2.o bspatch.o ibootim.o lzss.o lzssfile.o ../dmg/zlib-1.2.3/contrib/minizip/ioapi.o ../dmg/zlib-1.2.3/contrib/minizip/unzip.o ../dmg/zlib-1.2.3/contrib/minizip/zip.o
|
||||
DMGOBJS=../dmg/base64.o ../dmg/resources.o ../dmg/checksum.o ../dmg/udif.o ../dmg/partition.o ../dmg/io.o ../dmg/filevault.o ../dmg/dmgfile.o ../dmg/dmglib.o
|
||||
HFSOBJS=../hfs/volume.o ../hfs/btree.o ../hfs/extents.o ../hfs/rawfile.o ../hfs/catalog.o ../hfs/flatfile.o ../hfs/utility.o ../hfs/fastunicodecompare.o ../hfs/hfslib.o
|
||||
|
|
|
@ -21,148 +21,6 @@ void TestByteOrder()
|
|||
endianness = byte[0] ? IS_LITTLE_ENDIAN : IS_BIG_ENDIAN;
|
||||
}
|
||||
|
||||
int doPatch(StringValue* patchValue, StringValue* fileValue, const char* bundlePath, OutputState** state) {
|
||||
char* patchPath;
|
||||
size_t bufferSize;
|
||||
void* buffer;
|
||||
|
||||
AbstractFile* patchFile;
|
||||
AbstractFile* file;
|
||||
AbstractFile* out;
|
||||
|
||||
buffer = malloc(1);
|
||||
|
||||
patchPath = malloc(sizeof(char) * (strlen(bundlePath) + strlen(patchValue->value) + 2));
|
||||
strcpy(patchPath, bundlePath);
|
||||
strcat(patchPath, "/");
|
||||
strcat(patchPath, patchValue->value);
|
||||
|
||||
printf("%s (%s)... ", fileValue->value, patchPath); fflush(stdout);
|
||||
|
||||
patchFile = createAbstractFileFromFile(fopen(patchPath, "rb"));
|
||||
|
||||
bufferSize = 0;
|
||||
|
||||
out = duplicateAbstractFile(getFileFromOutputState(state, fileValue->value), createAbstractFileFromMemoryFile((void**)&buffer, &bufferSize));
|
||||
|
||||
file = openAbstractFile(getFileFromOutputState(state, fileValue->value));
|
||||
|
||||
if(!patchFile || !file || !out) {
|
||||
printf("file error\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if(patch(file, out, patchFile) != 0) {
|
||||
printf("patch failed\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
printf("writing... "); fflush(stdout);
|
||||
|
||||
/* out = createAbstractFileFromFile(fopen(filePath, "wb"));
|
||||
out->write(out, buffer, bufferSize);
|
||||
out->close(out);*/
|
||||
|
||||
addToOutput(state, fileValue->value, buffer, bufferSize);
|
||||
|
||||
printf("success\n"); fflush(stdout);
|
||||
|
||||
free(patchPath);
|
||||
}
|
||||
|
||||
void doPatchInPlace(Volume* volume, char* filePath, char* patchPath) {
|
||||
void* buffer;
|
||||
void* buffer2;
|
||||
size_t bufferSize;
|
||||
size_t bufferSize2;
|
||||
AbstractFile* bufferFile;
|
||||
AbstractFile* patchFile;
|
||||
AbstractFile* out;
|
||||
|
||||
|
||||
buffer = malloc(1);
|
||||
bufferSize = 0;
|
||||
bufferFile = createAbstractFileFromMemoryFile((void**)&buffer, &bufferSize);
|
||||
|
||||
printf("retrieving..."); fflush(stdout);
|
||||
get_hfs(volume, filePath, bufferFile);
|
||||
|
||||
printf("patching..."); fflush(stdout);
|
||||
|
||||
patchFile = createAbstractFileFromFile(fopen(patchPath, "rb"));
|
||||
|
||||
buffer2 = malloc(1);
|
||||
bufferSize2 = 0;
|
||||
out = duplicateAbstractFile(createAbstractFileFromMemoryFile((void**)&buffer, &bufferSize), createAbstractFileFromMemoryFile((void**)&buffer2, &bufferSize2));
|
||||
|
||||
if(!patchFile || !bufferFile || !out) {
|
||||
printf("file error\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if(patch(bufferFile, out, patchFile) != 0) {
|
||||
printf("patch failed\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
printf("writing... "); fflush(stdout);
|
||||
add_hfs(volume, createAbstractFileFromMemoryFile((void**)&buffer2, &bufferSize2), filePath);
|
||||
free(buffer2);
|
||||
free(buffer);
|
||||
|
||||
printf("success\n"); fflush(stdout);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void fixupBootNeuterArgs(Volume* volume, char unlockBaseband, char selfDestruct, char use39, char use46) {
|
||||
char bootNeuterPlist[] = "/System/Library/LaunchDaemons/com.devteam.bootneuter.auto.plist";
|
||||
AbstractFile* plistFile;
|
||||
char* plist;
|
||||
Dictionary* info;
|
||||
size_t bufferSize;
|
||||
ArrayValue* arguments;
|
||||
|
||||
printf("fixing up BootNeuter arguments...\n");
|
||||
|
||||
plist = malloc(1);
|
||||
bufferSize = 0;
|
||||
plistFile = createAbstractFileFromMemoryFile((void**)&plist, &bufferSize);
|
||||
get_hfs(volume, bootNeuterPlist, plistFile);
|
||||
plistFile->close(plistFile);
|
||||
info = createRoot(plist);
|
||||
free(plist);
|
||||
|
||||
arguments = (ArrayValue*) getValueByKey(info, "ProgramArguments");
|
||||
addStringToArray(arguments, "-autoMode");
|
||||
addStringToArray(arguments, "YES");
|
||||
|
||||
if(unlockBaseband) {
|
||||
addStringToArray(arguments, "-unlockBaseband");
|
||||
addStringToArray(arguments, "YES");
|
||||
}
|
||||
|
||||
if(selfDestruct) {
|
||||
addStringToArray(arguments, "-selfDestruct");
|
||||
addStringToArray(arguments, "YES");
|
||||
}
|
||||
|
||||
if(use39) {
|
||||
addStringToArray(arguments, "-bootLoader");
|
||||
addStringToArray(arguments, "3.9");
|
||||
} else if(use46) {
|
||||
addStringToArray(arguments, "-bootLoader");
|
||||
addStringToArray(arguments, "4.6");
|
||||
}
|
||||
|
||||
plist = getXmlFromRoot(info);
|
||||
releaseDictionary(info);
|
||||
|
||||
plistFile = createAbstractFileFromMemory((void**)&plist, sizeof(char) * strlen(plist));
|
||||
add_hfs(volume, plistFile, bootNeuterPlist);
|
||||
free(plist);
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
TestByteOrder();
|
||||
|
||||
|
@ -416,7 +274,7 @@ int main(int argc, char* argv[]) {
|
|||
add_hfs(rootVolume, getFileFromOutputState(&outputState, fileValue->value), pathValue->value);
|
||||
} if(strcmp(actionValue->value, "Patch") == 0) {
|
||||
patchValue = (StringValue*) getValueByKey(patchDict, "Patch");
|
||||
patchPath = malloc(sizeof(char) * (strlen(bundlePath) + strlen(patchValue->value) + 2));
|
||||
patchPath = (char*) malloc(sizeof(char) * (strlen(bundlePath) + strlen(patchValue->value) + 2));
|
||||
strcpy(patchPath, bundlePath);
|
||||
strcat(patchPath, "/");
|
||||
strcat(patchPath, patchValue->value);
|
|
@ -6,6 +6,7 @@
|
|||
#include <xpwn/plist.h>
|
||||
#include <xpwn/outputstate.h>
|
||||
#include <xpwn/pwnutil.h>
|
||||
#include <xpwn/nor_files.h>
|
||||
|
||||
#define BUFFERSIZE (1024*1024)
|
||||
|
||||
|
@ -111,3 +112,139 @@ Dictionary* parseIPSW(const char* inputIPSW, const char* bundleRoot, char** bund
|
|||
|
||||
return info;
|
||||
}
|
||||
|
||||
int doPatch(StringValue* patchValue, StringValue* fileValue, const char* bundlePath, OutputState** state) {
|
||||
char* patchPath;
|
||||
size_t bufferSize;
|
||||
void* buffer;
|
||||
|
||||
AbstractFile* patchFile;
|
||||
AbstractFile* file;
|
||||
AbstractFile* out;
|
||||
|
||||
buffer = malloc(1);
|
||||
|
||||
patchPath = malloc(sizeof(char) * (strlen(bundlePath) + strlen(patchValue->value) + 2));
|
||||
strcpy(patchPath, bundlePath);
|
||||
strcat(patchPath, "/");
|
||||
strcat(patchPath, patchValue->value);
|
||||
|
||||
printf("%s (%s)... ", fileValue->value, patchPath); fflush(stdout);
|
||||
|
||||
patchFile = createAbstractFileFromFile(fopen(patchPath, "rb"));
|
||||
|
||||
bufferSize = 0;
|
||||
|
||||
out = duplicateAbstractFile(getFileFromOutputState(state, fileValue->value), createAbstractFileFromMemoryFile((void**)&buffer, &bufferSize));
|
||||
|
||||
file = openAbstractFile(getFileFromOutputState(state, fileValue->value));
|
||||
|
||||
if(!patchFile || !file || !out) {
|
||||
printf("file error\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if(patch(file, out, patchFile) != 0) {
|
||||
printf("patch failed\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
printf("writing... "); fflush(stdout);
|
||||
|
||||
addToOutput(state, fileValue->value, buffer, bufferSize);
|
||||
|
||||
printf("success\n"); fflush(stdout);
|
||||
|
||||
free(patchPath);
|
||||
}
|
||||
|
||||
void doPatchInPlace(Volume* volume, char* filePath, char* patchPath) {
|
||||
void* buffer;
|
||||
void* buffer2;
|
||||
size_t bufferSize;
|
||||
size_t bufferSize2;
|
||||
AbstractFile* bufferFile;
|
||||
AbstractFile* patchFile;
|
||||
AbstractFile* out;
|
||||
|
||||
|
||||
buffer = malloc(1);
|
||||
bufferSize = 0;
|
||||
bufferFile = createAbstractFileFromMemoryFile((void**)&buffer, &bufferSize);
|
||||
|
||||
printf("retrieving..."); fflush(stdout);
|
||||
get_hfs(volume, filePath, bufferFile);
|
||||
|
||||
printf("patching..."); fflush(stdout);
|
||||
|
||||
patchFile = createAbstractFileFromFile(fopen(patchPath, "rb"));
|
||||
|
||||
buffer2 = malloc(1);
|
||||
bufferSize2 = 0;
|
||||
out = duplicateAbstractFile(createAbstractFileFromMemoryFile((void**)&buffer, &bufferSize), createAbstractFileFromMemoryFile((void**)&buffer2, &bufferSize2));
|
||||
|
||||
if(!patchFile || !bufferFile || !out) {
|
||||
printf("file error\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if(patch(bufferFile, out, patchFile) != 0) {
|
||||
printf("patch failed\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
printf("writing... "); fflush(stdout);
|
||||
add_hfs(volume, createAbstractFileFromMemoryFile((void**)&buffer2, &bufferSize2), filePath);
|
||||
free(buffer2);
|
||||
free(buffer);
|
||||
|
||||
printf("success\n"); fflush(stdout);
|
||||
}
|
||||
|
||||
void fixupBootNeuterArgs(Volume* volume, char unlockBaseband, char selfDestruct, char use39, char use46) {
|
||||
char bootNeuterPlist[] = "/System/Library/LaunchDaemons/com.devteam.bootneuter.auto.plist";
|
||||
AbstractFile* plistFile;
|
||||
char* plist;
|
||||
Dictionary* info;
|
||||
size_t bufferSize;
|
||||
ArrayValue* arguments;
|
||||
|
||||
printf("fixing up BootNeuter arguments...\n");
|
||||
|
||||
plist = malloc(1);
|
||||
bufferSize = 0;
|
||||
plistFile = createAbstractFileFromMemoryFile((void**)&plist, &bufferSize);
|
||||
get_hfs(volume, bootNeuterPlist, plistFile);
|
||||
plistFile->close(plistFile);
|
||||
info = createRoot(plist);
|
||||
free(plist);
|
||||
|
||||
arguments = (ArrayValue*) getValueByKey(info, "ProgramArguments");
|
||||
addStringToArray(arguments, "-autoMode");
|
||||
addStringToArray(arguments, "YES");
|
||||
|
||||
if(unlockBaseband) {
|
||||
addStringToArray(arguments, "-unlockBaseband");
|
||||
addStringToArray(arguments, "YES");
|
||||
}
|
||||
|
||||
if(selfDestruct) {
|
||||
addStringToArray(arguments, "-selfDestruct");
|
||||
addStringToArray(arguments, "YES");
|
||||
}
|
||||
|
||||
if(use39) {
|
||||
addStringToArray(arguments, "-bootLoader");
|
||||
addStringToArray(arguments, "3.9");
|
||||
} else if(use46) {
|
||||
addStringToArray(arguments, "-bootLoader");
|
||||
addStringToArray(arguments, "4.6");
|
||||
}
|
||||
|
||||
plist = getXmlFromRoot(info);
|
||||
releaseDictionary(info);
|
||||
|
||||
plistFile = createAbstractFileFromMemory((void**)&plist, sizeof(char) * strlen(plist));
|
||||
add_hfs(volume, plistFile, bootNeuterPlist);
|
||||
free(plist);
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ OBJDIR=build
|
|||
|
||||
OBJS=xpwn.o
|
||||
LIBOBJS=libibooter.o
|
||||
IPSWOBJS=../../ipsw-patch/pwnutil.o ../../ipsw-patch/plist.o ../../ipsw-patch/outputstate.o ../../dmg/zlib-1.2.3/contrib/minizip/ioapi.o ../../dmg/zlib-1.2.3/contrib/minizip/unzip.o ../../dmg/zlib-1.2.3/contrib/minizip/zip.o
|
||||
IPSWOBJS=../../ipsw-patch/bspatch.o ../../ipsw-patch/bzip2-1.0.5/libbz2.a ../../ipsw-patch/pwnutil.o ../../ipsw-patch/plist.o ../../ipsw-patch/outputstate.o ../../dmg/zlib-1.2.3/contrib/minizip/ioapi.o ../../dmg/zlib-1.2.3/contrib/minizip/unzip.o ../../dmg/zlib-1.2.3/contrib/minizip/zip.o
|
||||
IMGOBJS=../../ipsw-patch/nor_files.o ../../ipsw-patch/8900.o ../../ipsw-patch/img2.o ../../ipsw-patch/ibootim.o ../../ipsw-patch/lzss.o ../../ipsw-patch/lzssfile.o ../../ipsw-patch/libpng-1.2.28/libpng.a ../../dmg/zlib-1.2.3/libz.a ../../dmg/openssl-0.9.8g/libcrypto.a
|
||||
HFSOBJS=../../hfs/volume.o ../../hfs/btree.o ../../hfs/extents.o ../../hfs/rawfile.o ../../hfs/catalog.o ../../hfs/flatfile.o ../../hfs/utility.o ../../hfs/fastunicodecompare.o ../../hfs/hfslib.o
|
||||
LIBRARIES=`if $(CC) ../win32test.c -o /dev/null 2>/dev/null ; then echo ""; else echo "-lgdi32"; fi` `if [ \`uname\` = "Darwin" ]; then echo "-framework CoreFoundation -framework IOKit"; else echo ""; fi`
|
||||
|
@ -29,7 +29,7 @@ $(OBJDIR)/%.o: %.cpp
|
|||
../ipsw-patch/pch:
|
||||
cd ../ipsw-patch; make
|
||||
|
||||
xpwn: $(OBJDIR)/$(OBJS) $(OBJDIR)/$(LIBOBJS) $(COMMONOBJS) ../ipsw-patch/pch
|
||||
xpwn: $(OBJDIR)/$(OBJS) $(OBJDIR)/$(LIBOBJS) $(COMMONOBJS) ../ipsw-patch/pch libusb
|
||||
cd $(OBJDIR); $(CXX) $(LDFLAGS) $(IPSWOBJS) $(IMGOBJS) $(OBJS) $(LIBOBJS) $(LIBUSB) $(HFSOBJS) $(COMMONOBJS) $(LIBRARIES) -o $@
|
||||
|
||||
libusb:
|
||||
|
|
|
@ -84,14 +84,35 @@ int main(int argc, char *argv[])
|
|||
|
||||
cout << " ... Opening ramdisk" << endl;
|
||||
AbstractFile* ramdiskSrc = createAbstractFileFromFile(fopen("ramdisk.dmg", "rb"));
|
||||
if(!ramdiskSrc) {
|
||||
cout << "error: cannot find ramdisk.dmg!" << endl;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
size_t bufferSize = ramdiskSrc->getLength(ramdiskSrc);
|
||||
void* buffer = (void*) malloc(bufferSize);
|
||||
cout << " ... Reading ramdisk" << endl;
|
||||
ramdiskSrc->read(ramdiskSrc, buffer, bufferSize);
|
||||
io_func* myRamdisk = IOFuncFromAbstractFile(createAbstractFileFromMemoryFile(&buffer, &bufferSize));
|
||||
Volume* ramdiskVolume = openVolume(myRamdisk);
|
||||
|
||||
Dictionary* ibootDict = (Dictionary*)getValueByKey((Dictionary*)getValueByKey(info, "FirmwarePatches"), "iBoot");
|
||||
if(!ibootDict) {
|
||||
cout << "Error reading iBoot info" << endl;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
add_hfs(ramdiskVolume, getFileFromOutputState(&ipswContents, ((StringValue*)getValueByKey(ibootDict, "File"))->value), "/ipwner/iboot.img2");
|
||||
StringValue* patchValue = (StringValue*) getValueByKey(ibootDict, "Patch");
|
||||
char* patchPath = (char*) malloc(sizeof(char) * (strlen(bundlePath) + strlen(patchValue->value) + 2));
|
||||
strcpy(patchPath, bundlePath);
|
||||
strcat(patchPath, "/");
|
||||
strcat(patchPath, patchValue->value);
|
||||
printf("patching /ipwner/iboot.img2 (%s)... ", patchPath);
|
||||
doPatchInPlace(ramdiskVolume, "/ipwner/iboot.img2", patchPath);
|
||||
free(patchPath);
|
||||
|
||||
if(applelogo || recoverymode) {
|
||||
io_func* myRamdisk = IOFuncFromAbstractFile(createAbstractFileFromMemoryFile(&buffer, &bufferSize));
|
||||
Volume* ramdiskVolume = openVolume(myRamdisk);
|
||||
cout << " ... Adding boot logos" << endl;
|
||||
|
||||
StringValue* fileValue;
|
||||
|
@ -112,11 +133,12 @@ int main(int argc, char *argv[])
|
|||
add_hfs(ramdiskVolume, createAbstractFileFromMemory(&imageBuffer, imageSize), "/ipwner/recovery.img2");
|
||||
}
|
||||
|
||||
cout << " ... Finalizing ramdisk" << endl;
|
||||
closeVolume(ramdiskVolume);
|
||||
CLOSE(myRamdisk);
|
||||
}
|
||||
|
||||
cout << " ... Finalizing ramdisk" << endl;
|
||||
closeVolume(ramdiskVolume);
|
||||
CLOSE(myRamdisk);
|
||||
|
||||
ramdisk = createAbstractFileFromMemoryFile(&buffer, &bufferSize);
|
||||
|
||||
kernelValue = (StringValue*) getValueByKey((Dictionary*)getValueByKey((Dictionary*)getValueByKey(info, "FirmwarePatches"), "KernelCache"), "File");
|
||||
|
|
Загрузка…
Ссылка в новой задаче