天天看點

Android Hook-Frida架構-在python腳本中調用frida子產品

首當其沖,了解你的裝置資訊。-----箴言-----

Frida 體驗筆記二:

官網:

https://frida.re/docs/home/

https://www.frida.re/docs/javascript-api/

實踐内容:在python腳本中調用frida提供的函數。

1. 擷取device資訊:device.py:(1)python腳本:device.py:

import frida
import sys


#擷取裝置資訊
rdev = frida.get_remote_device()
print (rdev)

usb = frida.get_usb_device()  #test ok
print (usb)

ldev =  frida.get_local_device()
print (ldev)
           

(2)運作:

aaaaa:test_code$ python device.py 
           

(3)結果:

Device(id="socket", name="Local Socket", type='remote')

Device(id="emulator-5554", name="Android Emulator 5554", type='usb')

Device(id="local", name="Local System", type='local')

2. 擷取前台程序資訊:

(1)python腳本:get_process.py:

import frida
import sys

#擷取裝置資訊

rdev = frida.get_usb_device()
print (rdev)

#test ok,如果用rdev就出錯
#process = rdev.enumerate_processes() 
#print(process)


#擷取在前台運作的APP
#test ok, 如果用rdev就出錯
front_app = rdev.get_frontmost_application()
print (front_app)
           

(2)運作:

aaaaa:test_code$ python get_process.py 
           

(3)結果:

Device(id="emulator-5554", name="Android Emulator 5554", type='usb')

Application(identifier="com.example.myapplication3", name="MyApp3", pid=2281)

3. 擷取程序資訊:

(1)python代碼: 同上get_process.py。

運作結果:

aaaaa:test_code$python get_process.py 

Device(id="emulator-5554", name="Android Emulator 5554", type='usb')

[Process(pid=1, name="init"), Process(pid=108, name="ueventd"), Process(pid=110, name="ueventd"), Process(pid=114, name="logd"), Process(pid=222, name="vold"),......

繼續閱讀