send

  1. # -*- coding: UTF-8 -*-
  2. import frida
  3. import sys
  4. jsCode = """
  5. Java.perform(function(){
  6. var RequestUtil = Java.use('com.dodonew.online.http.RequestUtil');
  7. RequestUtil.encodeDesMap.overload('java.lang.String', 'java.lang.String', 'java.lang.String').implementation = function(a, b, c){
  8. console.log('data: ', a);
  9. console.log('desKey: ', b);
  10. console.log('desIV: ', c);
  11. var retval = this.encodeDesMap(a, b, c);
  12. send( retval);
  13. return retval;
  14. }
  15. var Utils = Java.use('com.dodonew.online.util.Utils');
  16. Utils.md5.implementation = function(a){
  17. console.log('MD5 string: ', a);
  18. var retval = this.md5(a);
  19. send( retval);
  20. return retval;
  21. }
  22. });
  23. """
  24. def message_1(message, data):
  25. print(message)
  26. if message["type"] == 'send':
  27. print(u"[*] {0}".format(message['payload']))
  28. else:
  29. print(message)
  30. process = frida.get_device_manager().add_remote_device('IP:8888').attach('com.dodonew.online')
  31. script = process.create_script(jsCode)
  32. script.load()
  33. print("开始运行")
  34. script.on('message', message_1)
  35. sys.stdin.read()

send的作用就是把js的处理结果发送回Python端,实现交互;
注意,send传入的参数只能是一个;

post/recv

这两个的作用就是把Python的处理结果发送给js,实现交互;

  1. # -*- coding: UTF-8 -*-
  2. import frida
  3. import sys
  4. jsCode = """
  5. Java.perform(function(){
  6. var RequestUtil = Java.use('com.dodonew.online.http.RequestUtil');
  7. RequestUtil.encodeDesMap.overload('java.lang.String', 'java.lang.String', 'java.lang.String').implementation = function(a, b, c){
  8. console.log('data: ', a);
  9. console.log('desKey: ', b);
  10. console.log('desIV: ', c);
  11. var retval = this.encodeDesMap(a, b, c);
  12. send( retval);
  13. return retval;
  14. }
  15. var Utils = Java.use('com.dodonew.online.util.Utils');
  16. Utils.md5.implementation = function(a){
  17. console.log('MD5 string: ', a);
  18. var retval = this.md5(a);
  19. send( retval);
  20. recv(function(obj){retval =obj.data}).wait();
  21. return retval;
  22. }
  23. });
  24. """
  25. def message_1(message, data):
  26. print(message)
  27. if message["type"] == 'send':
  28. print(u"[*] {0}".format(message['payload']))
  29. script.post({'data': "测试文本"})
  30. else:
  31. print(message)
  32. process =frida.get_usb_device().attach('com.dodonew.online')
  33. script = process.create_script(jsCode)
  34. script.load()
  35. script.on('message', message_1)
  36. print("开始运行")
  37. sys.stdin.read()

这里1我们把 “测试文本”四个字作为sign的返回值拿给js处理,成功的实现了交互image.png