Early hooking on Android
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 30/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- android, javascript, python
Hướng nghiên cứu
Bắt đầu với android-hook.py và JavaScript được inject, sau đó xem xét hai issue liên quan đến hành vi spawn, attach, script loading và RPC lifecycle của Frida. Tái hiện lệnh gọi onResume đầu tiên bị bỏ lỡ và trường hợp Promise bị hủy cùng với script; được xem là hoàn tất khi cách tiếp cận được ghi lại cài đặt các hook sớm một cách đáng tin cậy trước khi tiếp tục tiến trình Android và giữ cho script tồn tại.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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
- Ngôn ngữ chính
- Python
- Star
- 873
- Fork
- 173
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của frida/frida-python
-
Custom agent with Java bridge Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
frida/frida-python#265 · 2 bình luận ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
frida/frida-python#262 · 1 bình luận ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
frida/frida-python#247 · 2 bình luận · 2 reaction ·
-
After a long period of hooking applications on Ubuntu, Python and JavaScript are unable to interact. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
frida/frida-python#246 ·
-
How can I connect to Ipv6? Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 20/100
frida/frida-python#243 ·
Tất cả issue của frida/frida-python
Issue tương tự
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
xinnan-tech/xiaozhi-fde-talk#263 ·
-
rules
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
huggingface/Repo2RLEnv#163 · 1 bình luận ·
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 95/100
huggingface/sentence-transformers#4074 ·
-
comp/dashboard invalid P3
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
NousResearch/hermes-agent#121143 ·