Skip to content

Commit 8b19a0c

Browse files
authored
Add files via upload
1 parent 761c636 commit 8b19a0c

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed

Dexprotector.js

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
var Location = "libdexprotector.";
2+
var FileLoaded = 0;
3+
var gpid = Get();
4+
var Pro = ProcessName();
5+
6+
function Get() {
7+
var getpd = new NativeFunction(Module.findExportByName("libc.so", "getpid"), 'int', []);
8+
return getpd();
9+
}
10+
11+
function ProcessName() {
12+
var openPtr = Module.getExportByName('libc.so', 'open');
13+
var open = new NativeFunction(openPtr, 'int', ['pointer', 'int']);
14+
var readPtr = Module.getExportByName('libc.so', 'read');
15+
var read = new NativeFunction(readPtr, 'int', ['int', 'pointer', 'int']);
16+
var closePtr = Module.getExportByName('libc.so', 'close');
17+
var close = new NativeFunction(closePtr, 'int', ['int']);
18+
var path = Memory.allocUtf8String('/proc/self/cmdline');
19+
var fd = open(path, 0);
20+
if (fd != -1) {
21+
var buffer = Memory.alloc(0x1000);
22+
var result = read(fd, buffer, 0x1000);
23+
close(fd);
24+
result = ptr(buffer).readCString();
25+
return result;
26+
}
27+
return -1;
28+
}
29+
Interceptor.attach(Module.findExportByName(null, 'android_dlopen_ext'), {
30+
onEnter: function(args) {
31+
var library_path = Memory.readCString(args[0])
32+
if (library_path.indexOf(Location) >= 0) {
33+
console.warn("Loading library : " + library_path)
34+
FileLoaded = 1;
35+
}
36+
},
37+
onLeave: function(retVal) {
38+
if (FileLoaded == 1) {
39+
var LibName = Location + gpid + ".so";
40+
var libso = Process.findModuleByName(LibName);
41+
var theDate = new Date();
42+
var hour = theDate.getHours();
43+
var minute = theDate.getMinutes();
44+
var second = theDate.getSeconds();
45+
var mSecond = theDate.getMilliseconds()
46+
hour < 10 ? hour = "0" + hour : hour;
47+
minute < 10 ? minute = "0" + minute : minute;
48+
second < 10 ? second = "0" + second : second;
49+
mSecond < 10 ? mSecond = "00" + mSecond : mSecond < 100 ? mSecond = "0" + mSecond : mSecond;
50+
var time = hour + ":" + minute + ":" + second + ":" + mSecond;
51+
console.log("[name]:", libso.name);
52+
console.log("[base]:", libso.base);
53+
console.log("[size]:", ptr(libso.size));
54+
console.log("[path]:", libso.path);
55+
var file_path = "/data/data/" + Pro + "/" + libso.name + "_" + libso.base + "_" + ptr(libso.size) + time + ".so";
56+
var file_handle = new File(file_path, "wb");
57+
if (file_handle && file_handle != null) {
58+
Memory.protect(ptr(libso.base), libso.size, 'rwx');
59+
var libso_buffer = ptr(libso.base).readByteArray(libso.size);
60+
file_handle.write(libso_buffer);
61+
file_handle.flush();
62+
file_handle.close();
63+
console.log("[dump]:", file_path);
64+
}
65+
}
66+
}
67+
})

0 commit comments

Comments
 (0)