android intercept libc#open example
This commit is contained in:
parent
7208fc7793
commit
8658889847
31
README.md
31
README.md
@ -67,27 +67,28 @@ An example for intercepting `libc#open` & logging backtrace if specific file was
|
|||||||
|
|
||||||
```js
|
```js
|
||||||
Interceptor.attach(Module.findExportByName("/system/lib/libc.so", "open"), {
|
Interceptor.attach(Module.findExportByName("/system/lib/libc.so", "open"), {
|
||||||
onEnter: function(args) {
|
onEnter: function(args) {
|
||||||
// debug only the intended calls
|
this.flag = false;
|
||||||
this.flag = false;
|
var filename = Memory.readCString(ptr(args[0]));
|
||||||
var filename = Memory.readCString(ptr(args[0]));
|
console.log('filename =', filename)
|
||||||
if (filename.indexOf("something") != -1) {
|
if (filename.endsWith(".xml")) {
|
||||||
this.flag = true;
|
this.flag = true;
|
||||||
var backtrace = Thread.backtrace(this.context, Backtracer.ACCURATE).map(DebugSymbol.fromAddress).join("\n\t");
|
var backtrace = Thread.backtrace(this.context, Backtracer.ACCURATE).map(DebugSymbol.fromAddress).join("\n\t");
|
||||||
console.log("file name [ " + Memory.readCString(ptr(args[0])) + " ]\nBacktrace:" + backtrace);
|
console.log("file name [ " + Memory.readCString(ptr(args[0])) + " ]\nBacktrace:" + backtrace);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onLeave: function(retval) {
|
onLeave: function(retval) {
|
||||||
if (this.flag) // passed from onEnter
|
if (this.flag) // passed from onEnter
|
||||||
console.warn("\nretval: " + retval);
|
console.warn("\nretval: " + retval);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
<summary>Output example</summary>
|
<summary>Output example</summary>
|
||||||
|
Intecepting `com.android.chrome`
|
||||||
|

|
||||||
|
|
||||||
TODO
|
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user