Early hooking on Android
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 30/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- android, javascript, python
Direzione di ricerca
Inizia con android-hook.py e il JavaScript iniettato, quindi esamina le due issue correlate al comportamento di spawn, attach, script loading e RPC lifecycle di Frida. Riproduci la prima chiamata a onResume persa e il caso del Promise distrutto insieme allo script; il lavoro è completato quando l'approccio documentato installa in modo affidabile gli hook iniziali prima di riprendere il processo Android e mantiene in vita lo script.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
I'm trying to spawn an Android process and hook all calls to early executing methods like System.loadLibrary and Activity.onResume.
However, either my hooks don't get applied at all, or they get applied too late.
What is the correct way to do this?
My android-hook.py:
import frida
import sys
scriptname = sys.argv[1]
procname = sys.argv[2]
with open(scriptname, "r") as f:
script_content = f.read()
# define callback function to receive and output messages
# received from server
def on_message(message, data):
print(message)
device = frida.get_usb_device(1) # Parameter '1' adds a timeout. Otherwise, frida often raises a frida.TimedOutError
pid = device.spawn([procname])
session = device.attach(pid)
script = session.create_script(script_content)
# setup callback using function defined above
script.on('message', on_message)
# load script into the process
script.load()
# resume process, otherwise nothing will happen
device.resume(pid)
# read from stdin to keep script running
sys.stdin.read()
My injected script:
'use strict';
setImmediate(function() {
console.log('init')
Java.perform(function () {
console.log("hooking");
var activity = Java.use('de.nioncode.fridasample.MainActivity');
activity.onResume.implementation = function () {
send("onResume");
this.onResume();
};
console.log("hooking done");
send("initialized");
});
console.log('init done')
});
This variation performs the hooks too late, thus missing the first 'onResume' call.
I tried to use the rpc mechanism in combination with a Promise to defer the continuation until I call resolve on the Promise. However, this resulted in an frida.InvalidOperationError: script is destroyed error. This was my attempt with the Promise script:
rpc.exports = {
init: function() {
console.log('init')
return new Promise(function(resolve, reject) {
console.log('init2')
Java.perform(function () {
console.log("hooking");
var activity = Java.use('de.nioncode.antidebug.MainActivity');
activity.onResume.implementation = function () {
send("onResume");
this.onResume();
};
console.log("hooking done");
// resolve the Promise, telling Frida to continue executing
resolve();
});
console.log('init2 done')
});
}
};
Related to:
https://github.com/frida/frida-python/issues/50
https://github.com/frida/frida/issues/13
- Lingua principale
- Python
- Stelle
- 873
- Fork
- 173
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di frida/frida-python
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
frida/frida-python#265 · 2 commenti ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
frida/frida-python#262 · 1 commento ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
frida/frida-python#247 · 2 commenti · 2 reazioni ·
-
After a long period of hooking applications on Ubuntu, Python and JavaScript are unable to interact. Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 25/100
frida/frida-python#246 ·
-
How can I connect to Ipv6? Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 20/100
frida/frida-python#243 ·
Tutte le issue di frida/frida-python
Issue simili
-
area: harness bug status: needs-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
Human-Agent-Society/reef#625 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 80/100
learningequality/kolibri#15351 · 2 commenti ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
Name consistency Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
eellak/triplestore#65 · 1 commento ·