Utilisation de l'artefact Frida pour implémenter facilement la méthode hook C / C ++

Objectif: Pour obtenir les paramètres de la méthode correspondante via la méthode native frida hook:

 

Code C ++:

extern  " C " JNIEXPORT jstring JNICALL 
Java_os_sdk_fridademo_MainActivity_stringFromJNI ( 
        JNIEnv * env, 
        jobject / * this * / ) { 
    std :: string hello = " Bonjour de C ++ " ;
    const   char * key = " king " ; 
    jsb_set_key (clé); 
    return env-> NewStringUTF (hello.c_str ()); 
}

Une fois la compilation terminée, exécutez sur l'appareil, j'utilise la machine virtuelle de pile bleue ici:

 

Ouvrez la bibliothèque so correspondante dans ida et recherchez le nom de la méthode exportée,

 

 

 

Écrire le script frida js: frida_native.js

Mettez le nom de la méthode trouvée dans la partie rouge ci-dessous:

setImmediate ( function () { 
Interceptor.attach (Module.findExportByName ( "libnative-lib.so", " _Z11jsb_set_keyPKc " ), { 
    onEnter: function (args) { 
        send ( "ouvert appelé! args [0]", Memory.readByteArray (args [0], 256 )); 
    }, 
    onLeave: fonction (retval) { 

    } 
}) 
});

Écrivez le script python correspondant: load_native.py

import frida, sys, time 

def on_msg (msg, data):
     print (msg)
     print (data) 

device = frida.get_device ( " emulator-5554 " )
 # pid = device.spawn (["packageName"]) 
# device. reprendre (pid) 
time.sleep (1 ) 
session = device.attach ( " packageName " ) 
avec open ( " frida_native.js " ) en tant que f: 
    script = session.create_script (f.read ()) 

script.on ( " message " , on_msg) 
script.load () 
sys.stdin.read ()

 

Après avoir couru

 

 

 

Faites-le facilement.

Tutoriel d'introduction à Amway Wave:

Étude de sécurité des applications Android: https://github.com/r0ysue/AndroidSecurityStudy

Documentation officielle: https://frida.re/docs/javascript-api/

 

Je suppose que tu aimes

Origine www.cnblogs.com/roger-jc/p/12760801.html
conseillé
Classement