1. Java.perform(function () {
    2. console.log("start hooking...");
    3. function showstack() {
    4. var log = Java.use("android.util.Log");
    5. var Throwable = Java.use("java.lang.Throwable");
    6. console.log(log.getStackTraceString(Throwable.$new()))
    7. }
    8. var stringBuilder = Java.use("java.lang.StringBuilder");
    9. stringBuilder.toString.implementation = function () {
    10. var result = this.toString.apply(this, arguments);
    11. // if(result == "username=18888888888"){
    12. showstack();
    13. console.log("stringBuilder.toString is called!", result);
    14. // }
    15. return result;
    16. }
    17. })

    值得注意的是,我们打印堆栈的时候,不能一上来就直接打印,Frida容易挂掉;
    需要过滤再进行打印