1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
| print('----- Script created by Eiffel2018 -----')
info = send_dbg_command('get info') infoheader, dummy, infobody = info.partition('\nLayout:\n') layout, dummy, modules = infobody.partition('\nModules:\n') regions = ida_idd.meminfo_vec_t() for region in layout.splitlines(): name, start, end = re.split('[:|-]',region.replace(' ', '')) if (name=='Alias' or name=='Heap' or name=='Stack'): print(name, start, hex(int(end,16)+1)) info = ida_idd.memory_info_t() info.name = name.lower() info.start_ea = int(start,16) info.end_ea = int(end,16)+1 info.sclass = 'DATA' info.sbase = 0 info.bitness = 1 info.perm = 6 regions.push_back(info) lastend=0 lastbase=0 lastname='' for region in modules.splitlines(): start, end, name = region.strip().replace(' - ', ' ').split(' '); name, dummy, ext = name.partition('.'); if (ext=='nss'): name='main' if (ext=='nrs.elf'): name='nro' if (lastend>0): info = ida_idd.memory_info_t() info.name = lastname + '-data' info.start_ea = lastend info.end_ea = int(start,16) info.sclass = 'DATA' info.sbase = 0 info.bitness = 1 info.perm = 6 regions.push_back(info) print(lastname + '-data', hex(lastend), start) lastend=0 if (name=='saltysd_core' or name=='saltysd_core-data'): continue if (name=='' or name=='-data'): continue print(name, start, hex(int(end,16)+1)) info = ida_idd.memory_info_t() info.name = name info.start_ea = int(start,16) info.end_ea = int(end,16)+1 info.sclass = 'CODE' info.sbase = 0 if (name=='main'): info.sbase = int(start[:-1],16) info.bitness = 1 info.perm = 5 regions.push_back(info) lastend=info.end_ea lastbase=info.sbase lastname=info.name if (ext=='nrs.elf'): mapping = send_dbg_command('get mapping '+hex(int(end,16)+1)) start, end, dummy, nextName, dummy = mapping.replace(' - ', ' ').split(' ', 4); if (nextName=='AliasCode'): name='nro-static' print(name, start, hex(int(end,16)+1)) info = ida_idd.memory_info_t() info.name = name info.start_ea = int(start,16) info.end_ea = int(end,16)+1 info.sclass = 'DATA' info.sbase = 0 info.bitness = 1 info.perm = 4 regions.push_back(info) lastend=info.end_ea lastbase=info.sbase lastname=info.name mapping = send_dbg_command('get mapping '+hex(int(end,16)+1)) start, end, dummy, nextName, dummy = mapping.replace(' - ', ' ').split(' ', 4); if (nextName=='AliasCodeData'): name='nro-data' mapping = send_dbg_command('get mapping '+hex(int(end,16)+1)) start2, end2, dummy, nextName2, dummy = mapping.replace(' - ', ' ').split(' ', 4); if (nextName2=='AliasCodeData'): end = end2 mapping = send_dbg_command('get mapping '+hex(int(end,16)+1)) start2, end2, dummy, nextName2, dummy = mapping.replace(' - ', ' ').split(' ', 4); if (nextName2=='AliasCodeData'): end = end2 print(name, start, hex(int(end,16)+1)) info = ida_idd.memory_info_t() info.name = name info.start_ea = int(start,16) info.end_ea = int(end,16)+1 info.sclass = 'DATA' info.sbase = 0 info.bitness = 1 info.perm = 6 regions.push_back(info) lastend=info.end_ea lastbase=info.sbase lastname=info.name mapping = send_dbg_command('get mapping '+hex(int(end,16)+1)) start, end, dummy, nextName, dummy = mapping.replace(' - ', ' ').split(' ', 4); lastend=0 ida_dbg.set_manual_regions(regions) ida_dbg.enable_manual_regions(0) ida_dbg.refresh_debugger_memory() ida_dbg.enable_manual_regions(1) ida_dbg.refresh_debugger_memory() ida_dbg.edit_manual_regions() pc = idaapi.get_reg_val('PC') ida_kernwin.jumpto(pc) ida_kernwin.refresh_idaview_anyway()
|