function
mapsRedirect() {
var
FakeMaps =
"/data/data/com.zj.wuaipojie/maps"
;
const openPtr = Module.getExportByName(
'libc.so'
,
'open'
);
const open =
new
NativeFunction(openPtr,
'int'
, [
'pointer'
,
'int'
]);
var
readPtr = Module.findExportByName(
"libc.so"
,
"read"
);
var
read =
new
NativeFunction(readPtr,
'int'
, [
'int'
,
'pointer'
,
"int"
]);
var
MapsBuffer = Memory.alloc(512);
var
MapsFile =
new
File(FakeMaps,
"w"
);
Interceptor.replace(openPtr,
new
NativeCallback(
function
(pathname, flag) {
var
FD = open(pathname, flag);
var
ch = pathname.readCString();
if
(ch.indexOf(
"/proc/"
) >= 0 && ch.indexOf(
"maps"
) >= 0) {
console.log(
"open : "
, pathname.readCString());
while
(parseInt(read(FD, MapsBuffer, 512)) !== 0) {
var
MBuffer = MapsBuffer.readCString();
MBuffer = MBuffer.replaceAll(
"/data/local/tmp/re.frida.server/frida-agent-64.so"
,
"FakingMaps"
);
MBuffer = MBuffer.replaceAll(
"re.frida.server"
,
"FakingMaps"
);
MBuffer = MBuffer.replaceAll(
"frida-agent-64.so"
,
"FakingMaps"
);
MBuffer = MBuffer.replaceAll(
"frida-agent-32.so"
,
"FakingMaps"
);
MBuffer = MBuffer.replaceAll(
"frida"
,
"FakingMaps"
);
MBuffer = MBuffer.replaceAll(
"/data/local/tmp"
,
"/data"
);
MapsFile.write(MBuffer);
}
var
filename = Memory.allocUtf8String(FakeMaps);
return
open(filename, flag);
}
return
FD;
},
'int'
, [
'pointer'
,
'int'
]));
}