MCPcopy
hub / github.com/AloneMonkey/frida-ios-dump / dumpModule

Function dumpModule

dump.js:193–314  ·  view source on GitHub ↗
(name)

Source from the content-addressed store, hash-verified

191}
192
193function dumpModule(name) {
194 if (modules == null) {
195 modules = getAllAppModules();
196 }
197
198 var targetmod = null;
199 for (var i = 0; i < modules.length; i++) {
200 if (modules[i].path.indexOf(name) != -1) {
201 targetmod = modules[i];
202 break;
203 }
204 }
205 if (targetmod == null) {
206 console.log("Cannot find module");
207 return;
208 }
209 var modbase = modules[i].base;
210 var modsize = modules[i].size;
211 var newmodname = modules[i].name;
212 var newmodpath = getDocumentDir() + "/" + newmodname + ".fid";
213 var oldmodpath = modules[i].path;
214
215
216 if(!access(allocStr(newmodpath),0)){
217 remove(allocStr(newmodpath));
218 }
219
220 var fmodule = open(newmodpath, O_CREAT | O_RDWR, 0);
221 var foldmodule = open(oldmodpath, O_RDONLY, 0);
222
223 if (fmodule == -1 || foldmodule == -1) {
224 console.log("Cannot open file" + newmodpath);
225 return;
226 }
227
228 var is64bit = false;
229 var size_of_mach_header = 0;
230 var magic = getU32(modbase);
231 var cur_cpu_type = getU32(modbase.add(4));
232 var cur_cpu_subtype = getU32(modbase.add(8));
233 if (magic == MH_MAGIC || magic == MH_CIGAM) {
234 is64bit = false;
235 size_of_mach_header = 28;
236 }else if (magic == MH_MAGIC_64 || magic == MH_CIGAM_64) {
237 is64bit = true;
238 size_of_mach_header = 32;
239 }
240
241 var BUFSIZE = 4096;
242 var buffer = malloc(BUFSIZE);
243
244 read(foldmodule, buffer, BUFSIZE);
245
246 var fileoffset = 0;
247 var filesize = 0;
248 magic = getU32(buffer);
249 if(magic == FAT_CIGAM || magic == FAT_MAGIC){
250 var off = 4;

Callers 1

handleMessageFunction · 0.85

Calls 8

getAllAppModulesFunction · 0.85
getDocumentDirFunction · 0.85
allocStrFunction · 0.85
openFunction · 0.85
getU32Function · 0.85
mallocFunction · 0.85
swap32Function · 0.85
putU64Function · 0.85

Tested by

no test coverage detected