/
/
-
-
-
-
Main
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
/
/
iphone8 ios
13.4
kernel
int
main() {
kernel_task_init();
uint64_t kb
=
kernel_base_init();
for
(size_t i
=
0
; i <
8
; i
+
+
) {
printf(
"%016llx\n"
, kernel_read64(kb
+
8
*
i));
}
uint64_t versionstraddr
=
kb
+
0x2FB64
;
char versionstr[
256
];
if
(kernel_read(versionstraddr, (void
*
)&versionstr, sizeof(versionstr)))
{
printf(
"%s\n"
, versionstr);
if
(strcmp(TARGET_KERNELCACHE_VERSION_STRING,versionstr)
=
=
0
)
{
printf(
"kernel cache hit\n"
);
/
/
226AF60
kernproc
uint64_t kernel_proc0
=
kernel_read64(kb
+
0x226AF60
);
struct proc
*
proc0
=
(void
*
)malloc(sizeof(struct proc));
if
(!kernel_read(kernel_proc0, (void
*
)proc0, sizeof(struct proc)))
{
printf(
"proc0 read failed\n"
);
return
-
1
;
}
printf(
"uniqueid offset 0x%llx comm offset 0x%llx \n"
,(int64_t)&(proc0
-
>p_uniqueid)
-
(int64_t)proc0, (int64_t)&(proc0
-
>p_comm)
-
(int64_t)proc0);
struct proc
*
proc1
=
(struct proc
*
)malloc(sizeof(struct proc));
uint64_t preptr
=
(uint64_t)(proc0
-
>p_list.le_prev);
while
(preptr){
if
(!kernel_read(preptr, (void
*
)proc1, sizeof(struct proc)))
{
printf(
"procnext read failed\n"
);
return
-
1
;
}
else
{
if
(proc1
-
>p_list.le_prev
=
=
0
)
{
printf(
"proc1->p_list.le_prev == 0\n"
);
break
;
}
int64_t lflagoffset
=
(int64_t)&(proc1
-
>p_lflag)
-
(int64_t)proc1;
int
lflagvalue
=
proc1
-
>p_lflag;
printf(
"(%llu)%s proc = 0x%llx lflag = 0x%x lflag offset = 0x%llx"
,proc1
-
>p_uniqueid,
proc1
-
>p_comm,
/
/
(char
*
)((int64_t)proc1
+
0x258
),
preptr,lflagvalue,lflagoffset);
if
(ISSET(lflagvalue, P_LNOATTACH))
{
printf(
" !!!P_LNOATTACH set"
);
CLR(lflagvalue, P_LNOATTACH);
KERNEL_WRITE32(preptr
+
lflagoffset, lflagvalue);
}
printf(
"\n"
);
preptr
=
(uint64_t)(proc1
-
>p_list.le_prev);
}
}
printf(
"end\n"
);
free(proc0);
free(proc1);
}
else
{
printf(
"kernel cache version mismatch\n"
);
}
}
else
{
printf(
"failed to read kernel version string\n"
);
}
return
0
;
}