0

I want to pass dict to RPC, here is my agent.js:

rpc.exports = {
    signrequesturlwithparameters: function (param_dict,secret,signMethod) { 
    var result=ObjC.classes.GSNetworkUtils.signRequestUrlWithParameters_secret_signMethod_(param_dict,secret,signMethod);
    return String(ObjC.classes.NSString.stringWithString_(result));
    }
};

RPC invoke example;

script.load()
signrequesturlwithparameters= getattr(script.exports, 'signrequesturlwithparameters')
_dict={"imsi":"46001","device_model":"iPhone7,2"}
secret="93AA27467E8"; 
signMethod="md5";
a=signrequesturlwithparameters(_dict,secret,signMethod)
print(a)

There is an error, can I pass a dict from Python to JavaSript RPC function? How should I modify the Python or JavaScript code to make it work?

Update: I tried JSON.parse,but it seems frida's javascript cannot use JSON.Another issue is when I want to pass a variable parameter dict to a=signrequesturlwithparameters(_dict,secret,signMethod),how should I use setObject_forKey_("key1","value1")? I think I should resolve the variable parameter dict in frida javascript,then I tried to pass str(dict) from python to frida javascript and tried to resolve the string dict to dict in frida javascript with ObjC.classes.NSJSONSerialization,more details is here,but still fail,can you help me?

4

1 回答 1

1

您可以json.dumps在 py 端和JSON.parseJS 端使用,但我认为您的问题是 @signRequestUrlWithParameters_secret_signMethod_我不认为它期望 JSON 而是NSDictionary类似的东西。

var NSDict = ObjC.classes.NSMutableDictionary.alloc().init();   
NSDict.setObject_forKey_("key1", "value1");     
NSDict.setObject_forKey_("key2", "value2");
signRequestUrlWithParameters_secret_signMethod_(NSDict, ...);
于 2019-08-13T10:27:32.280 回答