如果我正确理解您的问题,您想更改v
内部函数中的参数 , 。对?如果是这种情况,您就已经可以访问v
内部函数中的参数了。所以你可以做的是这样的:
Java.perform(function () {
// Function to hook is defined here
var SpeedometerView = Java.use('adL');
// Whenever button is clicked
SpeedometerView.a.overload('float').implementation = function (v) {
// Show a message to know that the function got called
send('Speed showing');
old_param_value = v;
new_param_value = 100.00;
// Call the original onClick handler
x = this.a(new_param_value);
};
});
此外,假设您想将 param 的值从任何退出更改为 100.00 return x 如果需要。
但是,如果您希望在运行时动态执行此操作,例如基于用户输入等,我不知道该怎么做。事实上,如果有人回答这个问题,我会留意它!
事实上,我尝试过这样的事情:
s4.js
Java.perform(
function()
{
var item = Java.use("java.util.Random");
console.log("Found random loaded");
item.nextInt.overload("int").implementation = function(a)
{
var ret = this.nextInt(a);
send("[*] The random no " + ret.toString());
recv(function (received_json_object) {
cheat_num = received_json_object.my_data
console.log("[*] Cheated bot number received " + cheat_num);
}).wait();
return cheat_num;
}
}
);
not_working.py
import time
import frida
def my_message_handler(message, payload):
print message.get('payload')
if message["type"] == "send":
print "in here"
place_bot_chic_at = raw_input("Give the index where bot chicken should be placed ")
print "bot chick will be placed at " + str(place_bot_chic_at)
# script.post({"my_data": 7331}) # This works perfectly fine.
script.post({"my_data": place_bot_chic_at}) # This gives error as :
print "Bot chick position sent"
device = frida.get_device_manager().enumerate_devices()[-1]
pid = device.spawn(["chicken.wars.main"])
device.resume(pid)
time.sleep(1)
session = device.attach(pid)
with open("s4.js") as f:
jss = f.read()
script = session.create_script(jss)
script.on("message", my_message_handler) #register the message handler
script.load()
raw_input()
但是当我运行那个 python 时,我收到以下错误:
lib/python2.7/site-packages/frida/core.py", line 298, in _on_message
callback(message, data)
File "not_working.py", line 12, in my_message_handler
script.post({"my_data": place_bot_chic_at}) # This gives error as :
AttributeError: 'NoneType' object has no attribute 'post'
另外,奇怪的是,在in here
打印字符串后的那一刻,我期待接下来执行用户输入行。但这不会发生,除非我按回车键。一旦我按下回车键,用户输入行place_bot_chic_at = raw_input("Give the index where bot chicken should be placed ")
就会被执行。我给出一个值并输入,这就是发生上述错误的时候。我不知道出了什么问题。如果有人这样做,请帮助理解我哪里出错了。