This commit is contained in:
planetbeing 2008-07-21 02:15:03 +00:00
Родитель f6face73d2
Коммит 0c6a370bcc
25 изменённых файлов: 125 добавлений и 485 удалений

Просмотреть файл

@ -1,77 +0,0 @@
all: hfs/hfsplus dmg/dmg hdutil/hdutil ipsw-patch/pch xpwn/xpwn
dmg/dmg:
cd dmg; make
hfs/hfsplus:
cd hfs; make
hdutil/hdutil:
cd hdutil; make
ipsw-patch/pch: hfs/hfsplus dmg/dmg
cd ipsw-patch; make
xpwn/xpwn: hfs/hfsplus dmg/dmg
cd xpwn; make
install: ipsw-patch/pch xpwn/xpwn
-rm -rf xpwn-build
mkdir xpwn-build
cp ipsw-patch/pch xpwn-build/ipsw
cp xpwn/build/xpwn xpwn-build/xpwn
cp xpwn/ramdisk.dmg xpwn-build/ramdisk.dmg
cp -R ipsw-patch/FirmwareBundles xpwn-build/FirmwareBundles
cp -R ipsw-patch/bundles xpwn-build/bundles
cp README.markdown xpwn-build/README
cp LICENSE xpwn-build/LICENSE
tar jcvf xpwn-linux.tar.bz2 xpwn-build
install-win: ipsw-patch/pch xpwn/xpwn
-rm -rf xpwn-build
mkdir xpwn-build
-cp ipsw-patch/pch.exe xpwn-build/ipsw.exe
-cp xpwn/build/xpwn.exe xpwn-build/xpwn.exe
-cp ipsw-patch/pch xpwn-build/ipsw.exe
-cp xpwn/build/xpwn xpwn-build/xpwn.exe
cp xpwn/ramdisk.dmg xpwn-build/ramdisk.dmg
cp -R ipsw-patch/FirmwareBundles xpwn-build/FirmwareBundles
cp -R ipsw-patch/bundles xpwn-build/bundles
sed "`echo s/$$/\\\r`/" README.markdown > xpwn-build/README.txt
sed "`echo s/$$/\\\r`/" LICENSE > xpwn-build/LICENSE.txt
cd xpwn-build; zip -r ../xpwn-windows.zip *
clean:
-rm common/*.o
cd dmg; make clean
cd hfs; make clean
cd hdutil; make clean
cd ipsw-patch; make clean
cd xpwn; make clean
dist-clean: clean
-cd dmg/zlib-1.2.3; make clean
-rm dmg/zlib-1.2.3/Makefile
-rm dmg/zlib-1.2.3/*.exe
-rm dmg/openssl-0.9.8g/crypto/objects/obj_dat.h
-cd dmg/openssl-0.9.8g; make clean
-cd ipsw-patch/libpng-1.2.28; make clean
-cd ipsw-patch/bzip2-1.0.5; make clean
-cd xpwn/libusb-0.1.12; make clean
-rm -rf xpwn/libusb-0.1.12/autom4te.cache
-rm xpwn/libusb-0.1.12/config.h
-rm xpwn/libusb-0.1.12/config.log
-rm xpwn/libusb-0.1.12/config.status
-rm xpwn/libusb-0.1.12/config.status.lineno
-rm xpwn/libusb-0.1.12/libtool
-rm xpwn/libusb-0.1.12/doc/Makefile
-rm xpwn/libusb-0.1.12/tests/Makefile
-rm -rf xpwn/libusb-0.1.12/.deps
-rm -rf xpwn/libusb-0.1.12/tests/.deps
-rm xpwn/libusb-0.1.12/Makefile
-cd xpwn/libusb-win32; make clean
-rm -rf ide/xcode/build
-rm dmg/zlib-1.2.3/contrib/minizip/*.o
-rm ipsw-patch/bzip2-1.0.5/*.exe
-rm -rf xpwn-build

Просмотреть файл

@ -75,12 +75,13 @@ ipsw is a more complex tool to generate custom IPSWs that you can restore
after using xpwn (or any other pwnage-based utility). This is important, since
that's how the jailbreak actually occurs.
./ipsw <input.ipsw> <output.ipsw> [-b <bootimage.png>] [-nobbupdate] \
./ipsw <input.ipsw> <output.ipsw> [-b <bootimage.png>] [-nowipe] \
[-r <recoveryimage.png>] [-e "<action to exclude>"] \
[[-unlock] [-use39] [-use46] [-cleanup] \
-3 <bootloader 3.9 file> -4 <bootloader 4.6 file>] \
<package1.tar> <package2.tar>...
Yes, I know, confusing syntax. The first two options are the IPSW you want to
modify, and where you want to save the modified IPSW respectively. -b and -r
have the same semantics and requirements as for xpwn. You can also specify
@ -90,8 +91,8 @@ for your particular IPSW (in FirmwareBundles/).
The most common use of the '-e' flag is to disable automatic activation, i.e.
'-e "Phone Activation"'. Note that the double-quotes are necessary.
-nobbupdate disables Apple's baseband upgrade program from running during
the restore. However, bbupdate must be enabled for unlocking with BootNeuter.
-nowipe disables Apple's wiping of the NAND (user data), before proceeding
with the restore. This allows the restore to happen much, much more quickly.
-unlock, -use39, -use46, -cleanup, -3, and -4 are valid only if you merge the
BootNeuter package. These provide instructions to BootNeuter (which provides

Просмотреть файл

@ -611,11 +611,13 @@ status_again:
}
int main(int argc, char* argv[]) {
printf("----------------------------------------------------PLEASE READ THIS---------------------------------------------------\n");
printf("Please make certain that all iTunes related processes are not running at this time (use Task Manager, etc. to end them)\n");
printf("Your iPhone/iPod touch must be placed into DFU mode AFTER iTunes had been turned off. This will allow me to talk to\n");
printf("it without iTunes getting in beforehand. USB Product ID of iPhone ought to be 0x1222\n");
printf("----------------------------------------------------PLEASE READ THIS---------------------------------------------------\n");
printf("---------------------------PLEASE READ THIS---------------------------\n");
printf("Please make certain that all iTunes related processes are not running\n");
printf("at this time (use Task Manager, etc. to end them). Your iPhone/iPod\n");
printf("must be placed into DFU mode AFTER iTunes had been turned off. This\n");
printf(" will allow me to talk to it without iTunes getting in beforehand.\n");
printf("USB Product ID of iPhone ought to be 0x1222\n");
printf("---------------------------PLEASE READ THIS---------------------------\n");
if(argc < 3) {
printf("usage: %s <custom.ipsw> <n82ap|m68ap|n45ap>\n", argv[0]);
@ -634,9 +636,9 @@ int main(int argc, char* argv[]) {
loadZipFile(argv[1], &data, ibssName);
download(getFileFromOutputState(&data, "Firmware/dfu/WTF.s5l8900xall.RELEASE.dfu"), 2048, 1);
sleep(1);
sleep(5);
download(getFileFromOutputState(&data, wtfName), 2048, 1);
sleep(3);
sleep(5);
download(getFileFromOutputState(&data, ibssName), 2048, 1);
releaseOutput(&data);

Просмотреть файл

@ -1,29 +0,0 @@
DMGOBJS=dmg.o base64.o resources.o checksum.o udif.o partition.o io.o filevault.o dmgfile.o dmglib.o zlib-1.2.3/libz.a 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
COMMONOBJS=../common/abstractfile.o
CFLAGS=-D_FILE_OFFSET_BITS=64 -DHAVE_CRYPT
LIBRARIES=`if $(CC) win32test.c -o /dev/null 2>/dev/null ; then echo ""; else echo "-lgdi32"; fi`
INCLUDES=-I../includes -Izlib-1.2.3 -Iopenssl-0.9.8g/include
all: dmg
dmg: $(DMGOBJS) $(HFSOBJS) $(COMMONOBJS)
$(CC) $(CFLAGS) $(DMGOBJS) $(HFSOBJS) $(LIBRARIES) $(COMMONOBJS) -o dmg
%.o: %.c
$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@
zlib-1.2.3/Makefile:
cd zlib-1.2.3; ./configure
zlib-1.2.3/libz.a: zlib-1.2.3/Makefile
cd zlib-1.2.3; make
openssl-0.9.8g/libcrypto.a:
touch openssl-0.9.8g/Makefile
cd openssl-0.9.8g/crypto; make
clean:
-rm *.o
-rm dmg
-rm dmg.exe

Просмотреть файл

@ -1,31 +0,0 @@
UTILOBJS=hdutil.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/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
COMMONOBJS=../common/abstractfile.o
CFLAGS=-D_FILE_OFFSET_BITS=64 -DHAVE_CRYPT
LIBRARIES=`if $(CC) win32test.c -o /dev/null 2>/dev/null ; then echo ""; else echo "-lgdi32"; fi`
INCLUDES=-I ../includes -I../dmg/zlib-1.2.3 -I../dmg/openssl-0.9.8g/include
all: util
util: $(DMGOBJS) $(HFSOBJS) $(UTILOBJS) $(COMMONOBJS)
$(CC) $(CFLAGS) $(DMGOBJS) $(HFSOBJS) $(UTILOBJS) $(COMMONOBJS) $(LIBRARIES) -o hdutil
%.o: %.c
$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@
../dmg/zlib-1.2.3/Makefile:
cd ../dmg/zlib-1.2.3; ./configure
../dmg/zlib-1.2.3/libz.a: ../dmg/zlib-1.2.3/Makefile
cd ../dmg/zlib-1.2.3; make
../dmg/openssl-0.9.8g/libcrypto.a:
touch ../dmg/openssl-0.9.8g/Makefile
cd ../dmg/openssl-0.9.8g/crypto; make
clean:
-rm *.o
-rm hdutil
-rm hdutil.exe

Просмотреть файл

@ -1,18 +0,0 @@
HFSPLUSOBJS=btree.o catalog.o extents.o flatfile.o rawfile.o volume.o utility.o hfs.o fastunicodecompare.o hfslib.o
COMMONOBJS=../common/abstractfile.o
CFLAGS=-D_FILE_OFFSET_BITS=64 -O3
INCLUDES=-I../includes
all: hfsplus
hfsplus: $(HFSPLUSOBJS) $(COMMONOBJS)
$(CC) $(CFLAGS) $(HFSPLUSOBJS) $(COMMONOBJS) -o hfsplus
%.o: %.c
$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@
clean:
-rm *.o
-rm hfsplus
-rm hfsplus.exe

Просмотреть файл

@ -586,6 +586,13 @@ void hfs_untar(Volume* volume, AbstractFile* tarFile) {
if(fileName[0] == '\0')
break;
if(fileName[0] == '.' && fileName[1] == '/') {
fileName += 2;
}
if(fileName[0] == '\0')
goto loop;
if(fileName[strlen(fileName) - 1] == '/')
fileName[strlen(fileName) - 1] = '\0';

Просмотреть файл

@ -13,7 +13,7 @@ typedef int (*SeekFunc)(AbstractFile* file, off_t offset);
typedef off_t (*TellFunc)(AbstractFile* file);
typedef void (*CloseFunc)(AbstractFile* file);
typedef off_t (*GetLengthFunc)(AbstractFile* file);
typedef void (*SetKeyFunc)(AbstractFile2* file, const uint8_t* key, const uint8_t* iv);
typedef void (*SetKeyFunc)(AbstractFile2* file, const unsigned int* key, const unsigned int* iv);
typedef enum AbstractFileType {
AbstractFileTypeFile,

Просмотреть файл

@ -37,7 +37,7 @@ extern "C" {
#endif
AbstractFile* createAbstractFileFromIBootIM(AbstractFile* file);
AbstractFile* duplicateIBootIMFile(AbstractFile* file, AbstractFile* backing);
void* replaceBootImage(AbstractFile* imageWrapper, AbstractFile* png, size_t *fileSize);
void* replaceBootImage(AbstractFile* imageWrapper, const unsigned int* key, const unsigned int* iv, AbstractFile* png, size_t *fileSize);
#ifdef __cplusplus
}
#endif

Просмотреть файл

@ -10,9 +10,9 @@
extern "C" {
#endif
AbstractFile* openAbstractFile(AbstractFile* file);
AbstractFile* openAbstractFile2(AbstractFile* file, const uint8_t* key, const uint8_t* iv);
AbstractFile* openAbstractFile2(AbstractFile* file, const unsigned int* key, const unsigned int* iv);
AbstractFile* duplicateAbstractFile(AbstractFile* file, AbstractFile* backing);
AbstractFile* duplicateAbstractFile2(AbstractFile* file, AbstractFile* backing, const uint8_t* key, const uint8_t* iv, AbstractFile* certificate);
AbstractFile* duplicateAbstractFile2(AbstractFile* file, AbstractFile* backing, const unsigned int* key, const unsigned int* iv, AbstractFile* certificate);
#ifdef __cplusplus
}
#endif

Просмотреть файл

@ -10,7 +10,7 @@ extern "C" {
#endif
int patch(AbstractFile* in, AbstractFile* out, AbstractFile* patch);
Dictionary* parseIPSW(const char* inputIPSW, const char* bundleRoot, char** bundlePath, OutputState** state);
int doPatch(StringValue* patchValue, StringValue* fileValue, const char* bundlePath, OutputState** state, uint8_t* key, uint8_t* iv);
int doPatch(StringValue* patchValue, StringValue* fileValue, const char* bundlePath, OutputState** state, unsigned int* key, unsigned int* iv);
void doPatchInPlace(Volume* volume, const char* filePath, const char* patchPath);
void fixupBootNeuterArgs(Volume* volume, char unlockBaseband, char selfDestruct, char use39, char use46);
#ifdef __cplusplus

Просмотреть файл

@ -1,45 +0,0 @@
RANLIB ?= ranlib
PCHOBJS=main.o
XPWNOBJS=plist.o pwnutil.o outputstate.o nor_files.o 8900.o img2.o img3.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
COMMONOBJS=../common/abstractfile.o
CFLAGS=-D_FILE_OFFSET_BITS=64 -DHAVE_CRYPT -g
STATIC_LIBRARIES=../dmg/zlib-1.2.3/libz.a ../dmg/openssl-0.9.8g/libcrypto.a ../dmg/openssl-0.9.8g/libcrypto.a bzip2-1.0.5/libbz2.a libpng-1.2.28/libpng.a
LIBRARIES=`if $(CC) win32test.c -o /dev/null 2>/dev/null ; then echo ""; else echo "-lgdi32"; fi` -lm
INCLUDES=-I../includes -Ilibpng-1.2.28 -I../dmg/zlib-1.2.3 -I../dmg/openssl-0.9.8g/include -Ibzip2-1.0.5
all: pch
pch: $(DMGOBJS) $(HFSOBJS) $(XPWNOBJS) $(PCHOBJS) $(COMMONOBJS) $(STATIC_LIBRARIES)
$(CC) $(CFLAGS) $(DMGOBJS) $(HFSOBJS) $(XPWNOBJS) $(PCHOBJS) $(COMMONOBJS) $(STATIC_LIBRARIES) $(LIBRARIES) -o pch
libxpwn.a: libxpwn.o $(DMGOBJS) $(HFSOBJS) $(XPWNOBJS) $(COMMONOBJS) $(STATIC_LIBRARIES)
$(LD) libxpwn.o $(DMGOBJS) $(HFSOBJS) $(XPWNOBJS) $(COMMONOBJS) $(STATIC_LIBRARIES) -r -o libxpwnbuild.o
ar rc libxpwn.a libxpwnbuild.o
ranlib libxpwn.a
%.o: %.c
$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@
../dmg/zlib-1.2.3/Makefile:
cd ../dmg/zlib-1.2.3; ./configure
../dmg/zlib-1.2.3/libz.a: ../dmg/zlib-1.2.3/Makefile
cd ../dmg/zlib-1.2.3; make
../dmg/openssl-0.9.8g/libcrypto.a:
touch ../dmg/openssl-0.9.8g/Makefile
cd ../dmg/openssl-0.9.8g/crypto; make
bzip2-1.0.5/libbz2.a:
cd bzip2-1.0.5; make
libpng-1.2.28/libpng.a:
cd libpng-1.2.28; make
clean:
-rm *.o
-rm pch
-rm pch.exe
-rm libxpwn.a

Просмотреть файл

@ -206,7 +206,7 @@ int patch(AbstractFile* in, AbstractFile* out, AbstractFile* patch) {
closeBZStream(dpfbz2);
closeBZStream(epfbz2);
out->seek(out, 0);
if(out->write(out, newBuffer, newsize) != newsize)
return -9;
out->close(out);

Двоичные данные
ipsw-patch/bundles/logo.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 20 KiB

Двоичные данные
ipsw-patch/bundles/recovery.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 43 KiB

Просмотреть файл

@ -195,7 +195,7 @@ void pngError(png_structp png_ptr, png_const_charp error_msg) {
exit(0);
}
void* replaceBootImage(AbstractFile* imageWrapper, AbstractFile* png, size_t *fileSize) {
void* replaceBootImage(AbstractFile* imageWrapper, const unsigned int* key, const unsigned int* iv, AbstractFile* png, size_t *fileSize) {
AbstractFile* imageFile;
unsigned char header[8];
InfoIBootIM* info;
@ -255,7 +255,7 @@ void* replaceBootImage(AbstractFile* imageWrapper, AbstractFile* png, size_t *fi
printf("notice: attempting to expand palette into full rgb\n");
}
png_set_expand(png_ptr);
png_set_expand(png_ptr);
png_set_strip_16(png_ptr);
png_set_bgr(png_ptr);
png_set_add_alpha(png_ptr, 0xff, PNG_FILLER_AFTER);
@ -295,13 +295,17 @@ void* replaceBootImage(AbstractFile* imageWrapper, AbstractFile* png, size_t *fi
row_pointers[i] = imageBuffer + (info_ptr->rowbytes * i);
}
png_read_image(png_ptr, row_pointers);
png_read_image(png_ptr, row_pointers);
png_read_end(png_ptr, end_info);
buffer = malloc(1);
*fileSize = 0;
imageFile = duplicateAbstractFile(imageWrapper, createAbstractFileFromMemoryFile((void**)&buffer, fileSize));
if(key != NULL) {
imageFile = duplicateAbstractFile2(imageWrapper, createAbstractFileFromMemoryFile((void**)&buffer, fileSize), key, iv, NULL);
} else {
imageFile = duplicateAbstractFile(imageWrapper, createAbstractFileFromMemoryFile((void**)&buffer, fileSize));
}
info = (InfoIBootIM*) (imageFile->data);
info->header.width = (uint16_t) info_ptr->width;

Просмотреть файл

@ -83,13 +83,19 @@ void closeImg3(AbstractFile* file) {
free(file);
}
void setKeyImg3(AbstractFile2* file, const uint8_t* key, const uint8_t* iv) {
void setKeyImg3(AbstractFile2* file, const unsigned int* key, const unsigned int* iv) {
Img3Info* info = (Img3Info*) file->super.data;
AES_set_encrypt_key(key, 128, &(info->encryptKey));
AES_set_decrypt_key(key, 128, &(info->decryptKey));
int i;
uint8_t bKey[16];
memcpy(info->iv, iv, 16);
for(i = 0; i < 16; i++) {
bKey[i] = key[i] & 0xff;
info->iv[i] = iv[i] & 0xff;
}
AES_set_encrypt_key(bKey, 128, &(info->encryptKey));
AES_set_decrypt_key(bKey, 128, &(info->decryptKey));
if(!info->encrypted) {
uint8_t ivec[16];
@ -194,22 +200,18 @@ void writeImg3Root(AbstractFile* file, Img3Element* element) {
}
void writeImg3Default(AbstractFile* file, Img3Element* element) {
const char zeros[0x10] = {0};
file->write(file, element->data, element->header->dataSize);
if((element->header->size - sizeof(AppleImg3Header)) > element->header->dataSize) {
file->write(file, zeros, (element->header->size - sizeof(AppleImg3Header)) - element->header->dataSize);
}
}
void writeImg3Element(AbstractFile* file, Img3Element* element) {
off_t curPos;
char zero;
zero = '\0';
curPos = file->tell(file);
file->seek(file, curPos + element->header->size - 1);
file->write(file, &zero, 1);
file->seek(file, curPos);
flipAppleImg3Header(element->header);
file->write(file, element->header, sizeof(AppleImg3Header));
flipAppleImg3Header(element->header);

Просмотреть файл

@ -45,6 +45,10 @@ int main(int argc, char* argv[]) {
size_t rootSize;
char* ramdiskFSPathInIPSW;
unsigned int ramdiskKey[16];
unsigned int ramdiskIV[16];
unsigned int* pRamdiskKey = NULL;
unsigned int* pRamdiskIV = NULL;
io_func* ramdiskFS;
Volume* ramdiskVolume;
@ -61,31 +65,27 @@ int main(int argc, char* argv[]) {
void* imageBuffer;
size_t imageSize;
AbstractFile* bootloader39;
AbstractFile* bootloader46;
AbstractFile* applelogo;
AbstractFile* recoverymode;
AbstractFile* bootloader39 = NULL;
AbstractFile* bootloader46 = NULL;
AbstractFile* applelogo = NULL;
AbstractFile* recoverymode = NULL;
char noWipe = FALSE;
char unlockBaseband;
char selfDestruct;
char use39;
char use46;
char doBootNeuter;
char noBB;
char unlockBaseband = FALSE;
char selfDestruct = FALSE;
char use39 = FALSE;
char use46 = FALSE;
char doBootNeuter = FALSE;
applelogo = NULL;
recoverymode = NULL;
bootloader39 = NULL;
bootloader46 = NULL;
unsigned int key[16];
unsigned int iv[16];
unlockBaseband = FALSE;
selfDestruct = FALSE;
use39 = FALSE;
use46 = FALSE;
doBootNeuter = FALSE;
unsigned int* pKey = NULL;
unsigned int* pIV = NULL;
if(argc < 3) {
printf("usage %s <input.ipsw> <target.ipsw> [-b <bootimage.png>] [-r <recoveryimage.png>] [-e \"<action to exclude>\"] [[-unlock] [-use39] [-use46] [-cleanup] -3 <bootloader 3.9 file> -4 <bootloader 4.6 file>] <package1.tar> <package2.tar>...\n", argv[0]);
printf("usage %s <input.ipsw> <target.ipsw> [-b <bootimage.png>] [-r <recoveryimage.png>] [-nowipe] [-e \"<action to exclude>\"] [[-unlock] [-use39] [-use46] [-cleanup] -3 <bootloader 3.9 file> -4 <bootloader 4.6 file>] <package1.tar> <package2.tar>...\n", argv[0]);
return 0;
}
@ -103,6 +103,10 @@ int main(int argc, char* argv[]) {
break;
}
if(strcmp(argv[i], "-nowipe") == 0) {
noWipe = TRUE;
}
if(strcmp(argv[i], "-e") == 0) {
removeKey(firmwarePatches, argv[i + 1]);
i++;
@ -195,34 +199,42 @@ int main(int argc, char* argv[]) {
while(patchDict != NULL) {
fileValue = (StringValue*) getValueByKey(patchDict, "File");
if(strcmp(patchDict->dValue.key, "Restore Ramdisk") == 0) {
ramdiskFSPathInIPSW = fileValue->value;
}
StringValue* keyValue = (StringValue*) getValueByKey(patchDict, "Key");
StringValue* ivValue = (StringValue*) getValueByKey(patchDict, "IV");
uint8_t key[16];
uint8_t iv[16];
uint8_t* pKey = NULL;
uint8_t* pIV = NULL;
pKey = NULL;
pIV = NULL;
if(keyValue) {
sscanf(keyValue->value, "%2hhx%2hhx%2hhx%2hhx%2hhx%2hhx%2hhx%2hhx%2hhx%2hhx%2hhx%2hhx%2hhx%2hhx%2hhx%2hhx",
sscanf(keyValue->value, "%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x",
&key[0], &key[1], &key[2], &key[3], &key[4], &key[5], &key[6], &key[7], &key[8],
&key[9], &key[10], &key[11], &key[12], &key[13], &key[14], &key[15]);
pKey = key;
}
if(ivValue) {
sscanf(ivValue->value, "%2hhx%2hhx%2hhx%2hhx%2hhx%2hhx%2hhx%2hhx%2hhx%2hhx%2hhx%2hhx%2hhx%2hhx%2hhx%2hhx",
sscanf(ivValue->value, "%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x",
&iv[0], &iv[1], &iv[2], &iv[3], &iv[4], &iv[5], &iv[6], &iv[7], &iv[8],
&iv[9], &iv[10], &iv[11], &iv[12], &iv[13], &iv[14], &iv[15]);
pIV = iv;
}
if(strcmp(patchDict->dValue.key, "Restore Ramdisk") == 0) {
ramdiskFSPathInIPSW = fileValue->value;
if(pKey) {
memcpy(ramdiskKey, key, sizeof(key));
memcpy(ramdiskIV, iv, sizeof(iv));
pRamdiskKey = ramdiskKey;
pRamdiskIV = ramdiskIV;
} else {
pRamdiskKey = NULL;
pRamdiskIV = NULL;
}
}
patchValue = (StringValue*) getValueByKey(patchDict, "Patch2");
if(patchValue) {
if(!noBB) {
if(noWipe) {
printf("%s: ", patchDict->dValue.key); fflush(stdout);
doPatch(patchValue, fileValue, bundlePath, &outputState, pKey, pIV);
patchDict = (Dictionary*) patchDict->dValue.next;
@ -238,13 +250,13 @@ int main(int argc, char* argv[]) {
if(strcmp(patchDict->dValue.key, "AppleLogo") == 0 && applelogo) {
printf("replacing %s\n", fileValue->value); fflush(stdout);
ASSERT((imageBuffer = replaceBootImage(getFileFromOutputState(&outputState, fileValue->value), applelogo, &imageSize)) != NULL, "failed to use new image");
ASSERT((imageBuffer = replaceBootImage(getFileFromOutputState(&outputState, fileValue->value), pKey, pIV, applelogo, &imageSize)) != NULL, "failed to use new image");
addToOutput(&outputState, fileValue->value, imageBuffer, imageSize);
}
if(strcmp(patchDict->dValue.key, "RecoveryMode") == 0 && recoverymode) {
printf("replacing %s\n", fileValue->value); fflush(stdout);
ASSERT((imageBuffer = replaceBootImage(getFileFromOutputState(&outputState, fileValue->value), recoverymode, &imageSize)) != NULL, "failed to use new image");
ASSERT((imageBuffer = replaceBootImage(getFileFromOutputState(&outputState, fileValue->value), pKey, pIV, recoverymode, &imageSize)) != NULL, "failed to use new image");
addToOutput(&outputState, fileValue->value, imageBuffer, imageSize);
}
@ -298,13 +310,23 @@ int main(int argc, char* argv[]) {
}
for(; mergePaths < argc; mergePaths++) {
printf("merging %s\n", argv[mergePaths]);
AbstractFile* tarFile = createAbstractFileFromFile(fopen(argv[mergePaths], "rb"));
hfs_untar(rootVolume, tarFile);
tarFile->close(tarFile);
}
if(doBootNeuter) {
ramdiskFS = IOFuncFromAbstractFile(openAbstractFile(getFileFromOutputState(&outputState, ramdiskFSPathInIPSW)));
if(pRamdiskKey) {
printf("%p: %02hhx%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx\n",
pRamdiskKey, pRamdiskKey[0], pRamdiskKey[1], pRamdiskKey[2], pRamdiskKey[3], pRamdiskKey[4], pRamdiskKey[5], pRamdiskKey[6], pRamdiskKey[7],
pRamdiskKey[8], pRamdiskKey[9], pRamdiskKey[10], pRamdiskKey[11], pRamdiskKey[12], pRamdiskKey[13], pRamdiskKey[14], pRamdiskKey[15]);
ramdiskFS = IOFuncFromAbstractFile(openAbstractFile2(getFileFromOutputState(&outputState, ramdiskFSPathInIPSW), pRamdiskKey, pRamdiskIV));
} else {
printf("unencrypted ramdisk\n");
ramdiskFS = IOFuncFromAbstractFile(openAbstractFile(getFileFromOutputState(&outputState, ramdiskFSPathInIPSW)));
}
ramdiskVolume = openVolume(ramdiskFS);
firmwarePatches = (Dictionary*)getValueByKey(info, "BasebandPatches");
if(firmwarePatches != NULL) {

Просмотреть файл

@ -67,7 +67,7 @@ AbstractFile* duplicateAbstractFile(AbstractFile* file, AbstractFile* backing) {
}
}
AbstractFile* openAbstractFile2(AbstractFile* file, const uint8_t* key, const uint8_t* iv) {
AbstractFile* openAbstractFile2(AbstractFile* file, const unsigned int* key, const unsigned int* iv) {
uint32_t signatureBE;
uint32_t signatureLE;
@ -98,7 +98,7 @@ AbstractFile* openAbstractFile2(AbstractFile* file, const uint8_t* key, const ui
}
}
AbstractFile* duplicateAbstractFile2(AbstractFile* file, AbstractFile* backing, const uint8_t* key, const uint8_t* iv, AbstractFile* certificate) {
AbstractFile* duplicateAbstractFile2(AbstractFile* file, AbstractFile* backing, const unsigned int* key, const unsigned int* iv, AbstractFile* certificate) {
uint32_t signatureBE;
uint32_t signatureLE;
AbstractFile* orig;

Просмотреть файл

@ -114,7 +114,7 @@ Dictionary* parseIPSW(const char* inputIPSW, const char* bundleRoot, char** bund
return info;
}
int doPatch(StringValue* patchValue, StringValue* fileValue, const char* bundlePath, OutputState** state, uint8_t* key, uint8_t* iv) {
int doPatch(StringValue* patchValue, StringValue* fileValue, const char* bundlePath, OutputState** state, unsigned int* key, unsigned int* iv) {
char* patchPath;
size_t bufferSize;
void* buffer;
@ -137,12 +137,22 @@ int doPatch(StringValue* patchValue, StringValue* fileValue, const char* bundleP
bufferSize = 0;
if(key != NULL) {
printf("\n%p: %02hhx%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx\n",
key, key[0], key[1], key[2], key[3], key[4], key[5], key[6], key[7], key[8], key[9], key[10], key[11], key[12], key[13], key[14], key[15]);
printf("%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx\n",
iv[0], iv[1], iv[2], iv[3], iv[4], iv[5], iv[6], iv[7], iv[8], iv[9], iv[10], iv[11], iv[12], iv[13], iv[14], iv[15]);
}
if(key != NULL) {
printf("encrypted input... ");
out = duplicateAbstractFile2(getFileFromOutputState(state, fileValue->value), createAbstractFileFromMemoryFile((void**)&buffer, &bufferSize), key, iv, NULL);
} else {
out = duplicateAbstractFile(getFileFromOutputState(state, fileValue->value), createAbstractFileFromMemoryFile((void**)&buffer, &bufferSize));
}
if(key != NULL) {
printf("encrypted output... ");
file = openAbstractFile2(getFileFromOutputState(state, fileValue->value), key, iv);
} else {
file = openAbstractFile(getFileFromOutputState(state, fileValue->value));
@ -224,7 +234,7 @@ void doPatchInPlace(Volume* volume, const char* filePath, const char* patchPath)
}
void fixupBootNeuterArgs(Volume* volume, char unlockBaseband, char selfDestruct, char use39, char use46) {
char bootNeuterPlist[] = "/System/Library/LaunchDaemons/com.devteam.bootneuter.auto.plist";
const char bootNeuterPlist[] = "/System/Library/LaunchDaemons/com.devteam.bootneuter.auto.plist";
AbstractFile* plistFile;
char* plist;
Dictionary* info;

Двоичные данные
ipsw-patch/retroapple.png

Двоичный файл не отображается.

До

Ширина:  |  Высота:  |  Размер: 9.2 KiB

Просмотреть файл

@ -16,8 +16,8 @@ int main(int argc, char* argv[]) {
AbstractFile* template = NULL;
AbstractFile* certificate = NULL;
uint8_t key[16];
uint8_t iv[16];
int key[16];
int iv[16];
int hasKey = FALSE;
int hasIV = FALSE;
@ -40,14 +40,14 @@ int main(int argc, char* argv[]) {
}
if(strcmp(argv[argNo], "-k") == 0 && (argNo + 1) < argc) {
sscanf(argv[argNo + 1], "%2hhx%2hhx%2hhx%2hhx%2hhx%2hhx%2hhx%2hhx%2hhx%2hhx%2hhx%2hhx%2hhx%2hhx%2hhx%2hhx",
sscanf(argv[argNo + 1], "%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x",
&key[0], &key[1], &key[2], &key[3], &key[4], &key[5], &key[6], &key[7], &key[8],
&key[9], &key[10], &key[11], &key[12], &key[13], &key[14], &key[15]);
hasKey = TRUE;
}
if(strcmp(argv[argNo], "-iv") == 0 && (argNo + 1) < argc) {
sscanf(argv[argNo + 1], "%2hhx%2hhx%2hhx%2hhx%2hhx%2hhx%2hhx%2hhx%2hhx%2hhx%2hhx%2hhx%2hhx%2hhx%2hhx%2hhx",
sscanf(argv[argNo + 1], "%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x",
&iv[0], &iv[1], &iv[2], &iv[3], &iv[4], &iv[5], &iv[6], &iv[7], &iv[8],
&iv[9], &iv[10], &iv[11], &iv[12], &iv[13], &iv[14], &iv[15]);
hasIV = TRUE;

Просмотреть файл

@ -1,165 +0,0 @@
# CMAKE generated file: DO NOT EDIT!
# Generated by "Unix Makefiles" Generator, CMake Version 2.4
# Default target executed when no arguments are given to make.
default_target: all
#=============================================================================
# Special targets provided by cmake.
# Disable implicit rules so canoncical targets will work.
.SUFFIXES:
.SUFFIXES: .hpux_make_needs_suffix_list
# Suppress display of executed commands.
$(VERBOSE).SILENT:
# A target that is always out of date.
cmake_force:
#=============================================================================
# Set environment variables for the build.
# The shell in which to execute make rules.
SHELL = /bin/sh
# The CMake executable.
CMAKE_COMMAND = /usr/bin/cmake
# The command to remove a file.
RM = /usr/bin/cmake -E remove -f
# The program to use to edit the cache.
CMAKE_EDIT_COMMAND = /usr/bin/ccmake
# The top-level source directory on which CMake was run.
CMAKE_SOURCE_DIR = /home/david/libdmg-hfsplus
# The top-level build directory on which CMake was run.
CMAKE_BINARY_DIR = /home/david/libdmg-hfsplus
# Include the progress variables for this target.
include CMakeFiles/progress.make
#=============================================================================
# Targets provided globally by CMake.
# Special rule for the target edit_cache
edit_cache:
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake cache editor..."
cd /home/david/libdmg-hfsplus/minizip && /usr/bin/ccmake -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)
# Special rule for the target edit_cache
edit_cache/fast: edit_cache
# Special rule for the target rebuild_cache
rebuild_cache:
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake to regenerate build system..."
cd /home/david/libdmg-hfsplus/minizip && /usr/bin/cmake -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)
# Special rule for the target rebuild_cache
rebuild_cache/fast: rebuild_cache
# The main all target
all: cmake_check_build_system
cd /home/david/libdmg-hfsplus && $(CMAKE_COMMAND) -E cmake_progress_start /home/david/libdmg-hfsplus/CMakeFiles $(CMAKE_ALL_PROGRESS)
cd /home/david/libdmg-hfsplus && $(MAKE) -f CMakeFiles/Makefile2 minizip/all
$(CMAKE_COMMAND) -E cmake_progress_start /home/david/libdmg-hfsplus/CMakeFiles 0
# The main clean target
clean:
cd /home/david/libdmg-hfsplus && $(MAKE) -f CMakeFiles/Makefile2 minizip/clean
# The main clean target
clean/fast: clean
# Prepare targets for installation.
preinstall: all
cd /home/david/libdmg-hfsplus && $(MAKE) -f CMakeFiles/Makefile2 minizip/preinstall
# Prepare targets for installation.
preinstall/fast:
cd /home/david/libdmg-hfsplus && $(MAKE) -f CMakeFiles/Makefile2 minizip/preinstall
# clear depends
depend:
$(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 1
# Convenience name for target.
minizip/CMakeFiles/minizip.dir/rule:
cd /home/david/libdmg-hfsplus && $(MAKE) -f CMakeFiles/Makefile2 minizip/CMakeFiles/minizip.dir/rule
# Convenience name for target.
minizip: minizip/CMakeFiles/minizip.dir/rule
# fast build rule for target.
minizip/fast:
cd /home/david/libdmg-hfsplus && $(MAKE) -f minizip/CMakeFiles/minizip.dir/build.make minizip/CMakeFiles/minizip.dir/build
# target to build an object file
ioapi.o:
cd /home/david/libdmg-hfsplus && $(MAKE) -f minizip/CMakeFiles/minizip.dir/build.make minizip/CMakeFiles/minizip.dir/ioapi.o
# target to preprocess a source file
ioapi.i:
cd /home/david/libdmg-hfsplus && $(MAKE) -f minizip/CMakeFiles/minizip.dir/build.make minizip/CMakeFiles/minizip.dir/ioapi.i
# target to generate assembly for a file
ioapi.s:
cd /home/david/libdmg-hfsplus && $(MAKE) -f minizip/CMakeFiles/minizip.dir/build.make minizip/CMakeFiles/minizip.dir/ioapi.s
# target to build an object file
unzip.o:
cd /home/david/libdmg-hfsplus && $(MAKE) -f minizip/CMakeFiles/minizip.dir/build.make minizip/CMakeFiles/minizip.dir/unzip.o
# target to preprocess a source file
unzip.i:
cd /home/david/libdmg-hfsplus && $(MAKE) -f minizip/CMakeFiles/minizip.dir/build.make minizip/CMakeFiles/minizip.dir/unzip.i
# target to generate assembly for a file
unzip.s:
cd /home/david/libdmg-hfsplus && $(MAKE) -f minizip/CMakeFiles/minizip.dir/build.make minizip/CMakeFiles/minizip.dir/unzip.s
# target to build an object file
zip.o:
cd /home/david/libdmg-hfsplus && $(MAKE) -f minizip/CMakeFiles/minizip.dir/build.make minizip/CMakeFiles/minizip.dir/zip.o
# target to preprocess a source file
zip.i:
cd /home/david/libdmg-hfsplus && $(MAKE) -f minizip/CMakeFiles/minizip.dir/build.make minizip/CMakeFiles/minizip.dir/zip.i
# target to generate assembly for a file
zip.s:
cd /home/david/libdmg-hfsplus && $(MAKE) -f minizip/CMakeFiles/minizip.dir/build.make minizip/CMakeFiles/minizip.dir/zip.s
# Help Target
help::
@echo "The following are some of the valid targets for this Makefile:"
@echo "... all (the default if no target is provided)"
@echo "... clean"
@echo "... depend"
@echo "... edit_cache"
@echo "... minizip"
@echo "... rebuild_cache"
@echo "... ioapi.o"
@echo "... ioapi.i"
@echo "... ioapi.s"
@echo "... unzip.o"
@echo "... unzip.i"
@echo "... unzip.s"
@echo "... zip.o"
@echo "... zip.i"
@echo "... zip.s"
#=============================================================================
# Special targets to cleanup operation of make.
# Special rule to run CMake to check the build system integrity.
# No rule that depends on this can have commands that come from listfiles
# because they might be regenerated.
cmake_check_build_system:
cd /home/david/libdmg-hfsplus && $(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 0

Просмотреть файл

@ -1,43 +0,0 @@
#
# Simple make for ibooter/libibooter
#
CFLAGS=-O3
LIBUSB=`if $(CC) ../win32test.c -o /dev/null 2>/dev/null ; then echo "../libusb-0.1.12/.libs/libusb.a"; else echo "../libusb-win32/libusb.a"; fi`
LIBUSBH=`if $(CC) win32test.c -o /dev/null 2>/dev/null ; then echo "-I./libusb-0.1.12/"; else echo "-I./libusb-win32/src/"; fi`
INC=-I./include/ $(LIBUSBH) -I../includes
SRCDIR=src
OBJDIR=build
OBJS=xpwn.o
LIBOBJS=libibooter.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/img3.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`
COMMONOBJS=../../common/abstractfile.o
all: prepare xpwn
VPATH=$(SRCDIR)
$(OBJDIR)/%.o: %.cpp
$(CXX) $(CFLAGS) -c $< $(INC) -o $@
../ipsw-patch/pch:
cd ../ipsw-patch; make
xpwn: $(OBJDIR)/$(OBJS) $(OBJDIR)/$(LIBOBJS) $(COMMONOBJS) ../ipsw-patch/pch libusb
cd $(OBJDIR); $(CXX) $(LDFLAGS) $(IPSWOBJS) $(IMGOBJS) $(OBJS) $(LIBOBJS) $(LIBUSB) $(HFSOBJS) $(COMMONOBJS) $(LIBRARIES) -o $@
libusb:
if $(CC) win32test.c -o /dev/null 2>/dev/null ; then cd libusb-0.1.12; ./configure; make; else cd libusb-win32; make; fi
prepare:
mkdir -p $(OBJDIR)
clean:
rm -rf $(OBJDIR)

Просмотреть файл

@ -138,14 +138,14 @@ int main(int argc, char *argv[])
if(applelogo) {
fileValue = (StringValue*) getValueByKey((Dictionary*)getValueByKey((Dictionary*)getValueByKey(info, "FirmwarePatches"), "AppleLogo"), "File");
printf("replacing %s\n", fileValue->value); fflush(stdout);
ASSERT((imageBuffer = replaceBootImage(getFileFromOutputState(&ipswContents, fileValue->value), applelogo, &imageSize)) != NULL, "failed to use new image");
ASSERT((imageBuffer = replaceBootImage(getFileFromOutputState(&ipswContents, fileValue->value), NULL, NULL, applelogo, &imageSize)) != NULL, "failed to use new image");
add_hfs(ramdiskVolume, createAbstractFileFromMemory(&imageBuffer, imageSize), "/ipwner/logo.img2");
}
if(recoverymode) {
fileValue = (StringValue*) getValueByKey((Dictionary*)getValueByKey((Dictionary*)getValueByKey(info, "FirmwarePatches"), "RecoveryMode"), "File");
printf("replacing %s\n", fileValue->value); fflush(stdout);
ASSERT((imageBuffer = replaceBootImage(getFileFromOutputState(&ipswContents, fileValue->value), recoverymode, &imageSize)) != NULL, "failed to use new image");
ASSERT((imageBuffer = replaceBootImage(getFileFromOutputState(&ipswContents, fileValue->value), NULL, NULL, recoverymode, &imageSize)) != NULL, "failed to use new image");
add_hfs(ramdiskVolume, createAbstractFileFromMemory(&imageBuffer, imageSize), "/ipwner/recovery.img2");
}