mirror of
https://github.com/radareorg/radare2.git
synced 2025-02-24 16:23:49 +00:00
More fixes for tfp0 and iOS codesign
This commit is contained in:
parent
cb2184912d
commit
3b5f5f3e5d
@ -8,7 +8,9 @@ include ../rules.mk
|
||||
CFLAGS+=-DR2_GITTAP=\"$(GIT_TAP)\"
|
||||
|
||||
sign:
|
||||
ldid -Sradare2.xml radare2
|
||||
xcrun --sdk iphoneos codesign \
|
||||
-s- --entitlements radare2.xml radare2
|
||||
#ldid -Sradare2.xml radare2
|
||||
|
||||
ios_sdk_sign:
|
||||
-codesign -s- --entitlements radare2.xml radare2
|
||||
|
@ -17,43 +17,32 @@ static RList *ios_dbg_maps(RDebug *dbg) {
|
||||
char buf[1024];
|
||||
mach_vm_address_t address = MACH_VM_MIN_ADDRESS;
|
||||
mach_vm_size_t size = (mach_vm_size_t) 0;
|
||||
mach_vm_size_t osize = (mach_vm_size_t) 0;
|
||||
natural_t depth = 0;
|
||||
task_t task = pid_to_task (dbg->tid);
|
||||
RDebugMap *mr = NULL;
|
||||
RList *list = NULL;
|
||||
int i = 0;
|
||||
#if __arm64__ || __aarch64__
|
||||
size = 16384; // acording to frida
|
||||
size = osize = 16384; // acording to frida
|
||||
#else
|
||||
size = 4096;
|
||||
size = osize = 4096;
|
||||
#endif
|
||||
|
||||
kern_return_t kr;
|
||||
while (TRUE) {
|
||||
struct vm_region_submap_info_64 info;
|
||||
mach_msg_type_number_t info_count;
|
||||
kern_return_t kr;
|
||||
|
||||
depth = VM_REGION_BASIC_INFO_64;
|
||||
while (TRUE) {
|
||||
info_count = VM_REGION_SUBMAP_INFO_COUNT_64;
|
||||
memset (&info, 0, sizeof (info));
|
||||
kr = mach_vm_region_recurse (task, &address, &size, &depth,
|
||||
(vm_region_recurse_info_t) &info, &info_count);
|
||||
if (kr != KERN_SUCCESS)
|
||||
break;
|
||||
#if 0
|
||||
if (info.is_submap) {
|
||||
depth++;
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
info_count = VM_REGION_SUBMAP_INFO_COUNT_64;
|
||||
memset (&info, 0, sizeof (info));
|
||||
kr = mach_vm_region_recurse (task, &address, &size, &depth,
|
||||
(vm_region_recurse_info_t) &info, &info_count);
|
||||
if (kr != KERN_SUCCESS) {
|
||||
eprintf ("Cannot kern succ recurse\n");
|
||||
break;
|
||||
}
|
||||
if (kr != KERN_SUCCESS)
|
||||
break;
|
||||
if (info.max_protection == 0) {
|
||||
continue;
|
||||
}
|
||||
if (!list) {
|
||||
list = r_list_new ();
|
||||
//list->free = (RListFree*)r_debug_map_free;
|
||||
@ -72,20 +61,22 @@ static RList *ios_dbg_maps(RDebug *dbg) {
|
||||
}
|
||||
} else contiguous = R_FALSE;
|
||||
oldprot = info.protection;
|
||||
if (!contiguous) {
|
||||
if (info.max_protection!=0 && !contiguous) {
|
||||
char module_name[1024];
|
||||
module_name[0] = 0;
|
||||
int ret = proc_regionfilename (dbg->pid, address, module_name, sizeof (module_name));
|
||||
int ret = proc_regionfilename (dbg->pid, address,
|
||||
module_name, sizeof (module_name));
|
||||
module_name[ret] = 0;
|
||||
#define xwr2rwx(x) ((x&1)<<2) | (x&2) | ((x&4)>>2)
|
||||
// XXX: if its shared, it cannot be read?
|
||||
snprintf (buf, sizeof (buf), "%s %02x %s%s%s%s %s",
|
||||
snprintf (buf, sizeof (buf), "%s %02x %s%s%s%s%s %s (sz=0x%x) (depth=%d)",
|
||||
r_str_rwx_i (xwr2rwx (info.max_protection)), i,
|
||||
unparse_inheritance (info.inheritance),
|
||||
info.user_tag? " user": "",
|
||||
info.is_submap? " sub": "",
|
||||
info.inheritance? " inherit": "",
|
||||
module_name);
|
||||
info.is_submap ? " submap": "",
|
||||
module_name, size, depth);
|
||||
//info.shared ? "shar" : "priv",
|
||||
//info.reserved ? "reserved" : "not-reserved",
|
||||
//""); //module_name);
|
||||
@ -99,8 +90,7 @@ static RList *ios_dbg_maps(RDebug *dbg) {
|
||||
i++;
|
||||
r_list_append (list, mr);
|
||||
}
|
||||
|
||||
if (size<1) size = 1; // fuck
|
||||
if (size<1) size = osize; // fuck
|
||||
address += size;
|
||||
size = 0;
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ typedef struct {
|
||||
extern int errno;
|
||||
|
||||
static task_t pid_to_task(int pid) {
|
||||
task_t task = 0;
|
||||
task_t task = -1;
|
||||
int err = task_for_pid (mach_task_self (), (pid_t)pid, &task);
|
||||
if ((err != KERN_SUCCESS) || !MACH_PORT_VALID (task)) {
|
||||
eprintf ("Failed to get task %d for pid %d.\n", (int)task, (int)pid);
|
||||
@ -61,9 +61,15 @@ static task_t pid_to_task(int pid) {
|
||||
static int __read(RIO *io, RIODesc *fd, ut8 *buf, int len) {
|
||||
vm_size_t size = 0;
|
||||
int blen, err, copied = 0;
|
||||
int blocksize = 16;
|
||||
int blocksize = 32;
|
||||
if (RIOMACH_PID (fd->data) == 0) {
|
||||
if (io->off<4096)
|
||||
return len;
|
||||
}
|
||||
memset (buf, 0xff, len);
|
||||
while (copied<len) {
|
||||
blen = R_MIN ((len-copied), blocksize);
|
||||
//blen = len;
|
||||
err = vm_read_overwrite (RIOMACH_TASK (fd->data),
|
||||
(ut64)io->off+copied, blen, (pointer_t)buf+copied, &size);
|
||||
switch (err) {
|
||||
@ -171,8 +177,10 @@ static int __plugin_open(RIO *io, const char *file, ut8 many) {
|
||||
// s/inferior_task/port/
|
||||
static int debug_attach(int pid) {
|
||||
task_t task = pid_to_task (pid);
|
||||
if (task == -1)
|
||||
if (task == -1) {
|
||||
eprintf ("Got task %d for pid %d\n", task, pid);
|
||||
return -1;
|
||||
}
|
||||
eprintf ("pid: %d\ntask: %d\n", pid, task);
|
||||
#if 0
|
||||
// TODO : move this code into debug
|
||||
@ -250,10 +258,15 @@ static RIODesc *__open(RIO *io, const char *file, int rw, int mode) {
|
||||
riom->pid = pid;
|
||||
riom->task = task;
|
||||
// sleep 1s to get proper path (program name instead of ls) (racy)
|
||||
pidpath = r_sys_pid_to_path (pid);
|
||||
if (pid == 0) {
|
||||
pidpath = strdup ("kernel");
|
||||
} else {
|
||||
pidpath = r_sys_pid_to_path (pid);
|
||||
}
|
||||
ret = r_io_desc_new (&r_io_plugin_mach, riom->pid,
|
||||
pidpath, rw | R_IO_EXEC, mode, riom);
|
||||
free (pidpath);
|
||||
eprintf ("GOT FD %p\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -272,14 +285,21 @@ static int __system(RIO *io, RIODesc *fd, const char *cmd) {
|
||||
RIOMach *riom = (RIOMach*)fd->data;
|
||||
//printf("ptrace io command (%s)\n", cmd);
|
||||
/* XXX ugly hack for testing purposes */
|
||||
if (!strcmp (cmd, "pid")) {
|
||||
if (!strncmp (cmd, "pid", 3)) {
|
||||
const char *pidstr = cmd + 4;
|
||||
int pid = -1;
|
||||
if (!cmd[3]) {
|
||||
int pid = RIOMACH_PID (fd->data);
|
||||
eprintf ("%d\n", pid);
|
||||
return 0;
|
||||
}
|
||||
int pid = atoi (cmd+4);
|
||||
if (pid != 0) {
|
||||
if (!strcmp (pidstr, "0")) {
|
||||
pid = 0;
|
||||
} else {
|
||||
pid = atoi (cmd+4);
|
||||
if (!pid) pid = -1;
|
||||
}
|
||||
if (pid != -1) {
|
||||
task_t task = pid_to_task (pid);
|
||||
if (task != -1) {
|
||||
eprintf ("PID=%d\n", pid);
|
||||
@ -289,7 +309,6 @@ static int __system(RIO *io, RIODesc *fd, const char *cmd) {
|
||||
}
|
||||
}
|
||||
eprintf ("io_mach_system: Invalid pid %d\n", pid);
|
||||
return 1;
|
||||
} else eprintf ("Try: '=!pid'\n");
|
||||
return 1;
|
||||
}
|
||||
|
@ -119,6 +119,7 @@ static int update_self_regions(int pid) {
|
||||
return R_FALSE;
|
||||
#endif
|
||||
}
|
||||
|
||||
static int __plugin_open(RIO *io, const char *file, ut8 many) {
|
||||
return (!strncmp (file, "self://", 7));
|
||||
}
|
||||
@ -180,7 +181,7 @@ static int __close(RIODesc *fd) {
|
||||
static int __system(RIO *io, RIODesc *fd, const char *cmd) {
|
||||
if (!strcmp (cmd, "pid")) {
|
||||
eprintf ("%d\n", fd->fd);
|
||||
}else if (!strcmp (cmd, "maps")) {
|
||||
} else if (!strcmp (cmd, "maps")) {
|
||||
int i;
|
||||
for (i =0; i<self_sections_count ;i++) {
|
||||
eprintf ("0x%08"PFMT64x" - 0x%08"PFMT64x" %s %s\n",
|
||||
|
Loading…
x
Reference in New Issue
Block a user