While the CLI tools like frida, frida-trace, etc., are quite useful, there might be times when you’d like to build your own tools harnessing the powerful Frida APIs.

Frida API

console.log("[+] Running Frida Script")
console.log("[+] The android version is: " + Java.androidVersion)

Java.enumerateLoadedClasses({
    "onMatch": function(name){
        if(name.includes("com.apphacking.certificatepinning")){
            console.log(name)
        }
    },
    "onComplete": function(){
        console.log("[+] Done")
    },
})

For running the script:

frida -U -f com.apphacking.certificatepinning -l .\\enumLoadedClasses.js --no-pause

-f → Specify the target package. it’s run the apk. If you don’t specify this option, you should manually run this apk. In case of you don’t want to target application pause, you can use --no-pause switch.

-U → Connect to frida server with USB connection.

-l → Load JavaScript script

console.log("[+] Running Frida Script")
console.log("[+] The android version is: " + Java.androidVersion)

Java.enumerateClassLoaders({
    "onMatch": function(loader){
        console.log("Loader: " + loader)
    },
    "onComplete": function(){
        console.log("[+] Done")
    },
})