包名附加方式

  1. # -*- coding: UTF-8 -*-
  2. import frida, sys
  3. jsCode = """
  4. Java.perform(function(){
  5. ...
  6. });
  7. """
  8. process =frida.get_usb_device().attach('com.dodonew.online')
  9. script = process.create_script(jsCode)
  10. script.load()
  11. print("开始运行")
  12. sys.stdin.read()

pid附加方式

  1. # -*- coding: UTF-8 -*-
  2. import frida, sys
  3. jsCode = """
  4. Java.perform(function(){
  5. ...
  6. });
  7. """
  8. process =frida.get_usb_device().attach(5678)#5678为目标APPpid
  9. script = process.create_script(jsCode)
  10. script.load()
  11. print("开始运行")
  12. sys.stdin.read()
  13. #frida-U 5678 -l hook.js 命令行方式以pid的方式注入

spawn方式启动

  1. # -*- coding: UTF-8 -*-
  2. import frida, sys,time
  3. jsCode = """
  4. ...
  5. """
  6. #方式一
  7. # device = frida.get_usb_device()
  8. # print("device: ", device)
  9. # pid = device.spawn(["com.dodonew.online"]) # 以挂起方式创建进程
  10. # print("pid: ", pid)
  11. # process = device.attach(pid)
  12. # print("process: ", process)
  13. # script = process.create_script(jsCode)
  14. # script.load()
  15. # device.resume(pid) # 加载完脚本, 恢复进程运行
  16. # print("开始运行")
  17. # sys.stdin.read()
  18. #方式二
  19. device = frida.get_usb_device()
  20. pid = device.spawn(["com.dodonew.online"])
  21. device.resume(pid)
  22. time.sleep(1)
  23. process = device.attach(pid)
  24. print('success')
  25. script = process.create_script(jsCode)
  26. print(pid)
  27. script.load()
  28. print('script loaded')
  29. input()
  30. #如果方式一不行,就用方式二即可;

连接非标准端口和多个设备

image.png

  1. # -*- coding: UTF-8 -*-
  2. import frida, sys,time
  3. jsCode = """
  4. ....
  5. """
  6. process = frida.get_device_manager().add_remote_device('IP:8888').attach('com.dodonew.online')
  7. script = process.create_script(jsCode)
  8. script.load()
  9. print("开始运行")
  10. sys.stdin.read()