Radare2 และ Frida ดีขึ้นด้วยกัน

ปลั๊กอินที่มีอยู่ในตัวเองสำหรับ radare2 ที่จัดส่ง Frida และอนุญาตให้ใช้เครื่องมือในท้องถิ่นหรือกระบวนการระยะไกลโดยใช้คำสั่ง R2 แทน (แต่ไม่ จำกัด เพียง) สคริปต์ Frida
โครงการ Radare ให้บริการเครื่องมือที่สมบูรณ์สำหรับวิศวกรรมย้อนกลับมันได้รับการดูแลอย่างแข็งขันและให้บริการที่ได้รับการดูแลอย่างดีและขยายคุณสมบัติด้วยภาษาและเครื่องมือการเขียนโปรแกรมอื่น ๆ
Frida เป็นชุดเครื่องมือเครื่องมือวัดแบบไดนามิกที่ทำให้ง่ายต่อการตรวจสอบและจัดการกระบวนการทำงานโดยการฉีดจาวาสคริปต์ของคุณเองและเลือกสื่อสารกับสคริปต์ของคุณด้วย
:. ):db APIr_fs API วิธีที่แนะนำในการติดตั้ง R2Frida คือผ่าน R2PM:
$ r2pm -ci r2frida การสร้างไบนารีที่ไม่ต้องการการรวบรวมจะได้รับการสนับสนุนใน r2pm และ r2env ในไม่ช้า ในขณะเดียวกันอย่าลังเลที่จะดาวน์โหลดบิลด์สุดท้ายจากหน้าเผยแพร่
ใน GNU/Debian คุณจะต้องติดตั้งแพ็คเกจต่อไปนี้:
$ sudo apt install -y make gcc libzip-dev nodejs npm curl pkg-config git $ git clone https://github.com/nowsecure/r2frida.git
$ cd r2frida
$ make
$ make user-install
radare2 (แทนที่จะเป็น radare2-xyz)preconfigure.bat )configure.bat แล้ว make.bat สำหรับการทดสอบใช้ r2 frida://0 ซึ่งติดอยู่กับ PID0 ใน Frida เป็นเซสชั่นพิเศษที่ทำงานในท้องถิ่น ตอนนี้คุณสามารถเรียกใช้ :? คำสั่งเพื่อรับรายการคำสั่งที่มีอยู่
$ r2 'frida://?'
r2 frida://[action]/[link]/[device]/[target]
* action = list | apps | attach | spawn | launch
* link = local | usb | remote host:port
* device = '' | host:port | device-id
* target = pid | appname | process-name | program-in-path | abspath
Local:
* frida://? # show this help
* frida:// # list local processes
* frida://0 # attach to frida-helper (no spawn needed)
* frida:///usr/local/bin/rax2 # abspath to spawn
* frida://rax2 # same as above, considering local/bin is in PATH
* frida://spawn/$(program) # spawn a new process in the current system
* frida://attach/(target) # attach to target PID in current host
USB:
* frida://list/usb// # list processes in the first usb device
* frida://apps/usb// # list apps in the first usb device
* frida://attach/usb//12345 # attach to given pid in the first usb device
* frida://spawn/usb//appname # spawn an app in the first resolved usb device
* frida://launch/usb//appname # spawn+resume an app in the first usb device
Remote:
* frida://attach/remote/10.0.0.3:9999/558 # attach to pid 558 on tcp remote frida-server
Environment: (Use the `%` command to change the environment at runtime)
R2FRIDA_SAFE_IO=0|1 # Workaround a Frida bug on Android/thumb
R2FRIDA_DEBUG=0|1 # Used to debug argument parsing behaviour
R2FRIDA_COMPILER_DISABLE=0|1 # Disable the new frida typescript compiler (`:. foo.ts`)
R2FRIDA_AGENT_SCRIPT=[file] # path to file of the r2frida agent
$ r2 frida://0 # same as frida -p 0, connects to a local session คุณสามารถแนบวางไข่หรือเปิดตัวโปรแกรมใด ๆ ด้วยชื่อหรือ PID บรรทัดต่อไปนี้จะแนบกับกระบวนการแรกที่ชื่อ rax2 (เรียกใช้ rax2 - ในเทอร์มินัลอื่นเพื่อทดสอบบรรทัดนี้)
$ r2 frida://rax2 # attach to the first process named `rax2`
$ r2 frida://1234 # attach to the given pidการใช้เส้นทางที่สมบูรณ์ของไบนารีเพื่อวางไข่จะวางไข่กระบวนการ:
$ r2 frida:///bin/ls
[0x00000000] > :dc # continue the execution of the target programยังทำงานร่วมกับข้อโต้แย้ง:
$ r2 frida:// " /bin/ls -al " สำหรับ USB Debugging แอพ iOS/Android ใช้การกระทำเหล่านี้ โปรดทราบว่า spawn สามารถแทนที่ด้วย launch หรือ attach และชื่อกระบวนการสามารถเป็น BundleID หรือ PID
$ r2 frida://spawn/usb/ # enumerate devices
$ r2 frida://spawn/usb// # enumerate apps in the first iOS device
$ r2 frida://spawn/usb//Weather # Run the weather app นี่เป็นคำสั่งที่พบบ่อยที่สุดดังนั้นคุณต้องเรียนรู้และต่อท้ายด้วย ? เพื่อขอความช่วยเหลือจากคำสั่งย่อย
:i # get information of the target (pid, name, home, arch, bits, ..)
.:i* # import the target process details into local r2
:? # show all the available commands
:dm # list maps. Use ':dm|head' and seek to the program base address
:iE # list the exports of the current binary (seek)
:dt fread # trace the 'fread' function
:dt-* # delete all traces
ปลั๊กอิน R2Frida ทำงานในด้านตัวแทนและลงทะเบียนกับ r2frida.pluginRegister API
ดู plugins/ ไดเรกทอรีสำหรับสคริปต์ปลั๊กอินตัวอย่างเพิ่มเติม
[ 0x00000000 ] > cat example . js
r2frida . pluginRegister ( 'test' , function ( name ) {
if ( name === 'test' ) {
return function ( args ) {
console . log ( 'Hello Args From r2frida plugin' , args ) ;
return 'Things Happen' ;
}
}
} ) ;
[ 0x00000000 ] > : . example . js # load the plugin script :. คำสั่งทำงานเหมือน . คำสั่ง แต่ทำงานภายในตัวแทน
:. a.js # run script which registers a plugin
:. # list plugins
:.-test # unload a plugin by name
:.. a.js # eternalize script (keeps running after detach) หากคุณยินดีที่จะติดตั้งและใช้ R2Frida บน Android ผ่าน Termux มีคำเตือนบางอย่างที่มีการพึ่งพาห้องสมุดเนื่องจากความละเอียดของสัญลักษณ์บางอย่าง วิธีการทำงานนี้คือการขยายสภาพแวดล้อม LD_LIBRARY_PATH เพื่อชี้ไปที่ไดเรกทอรีระบบ ก่อน คำสั่ง libdir
$ LD_LIBRARY_PATH=/system/lib64:$LD_LIBRARY_PATH r2 frida://...
ตรวจสอบให้แน่ใจว่าคุณใช้ R2 รุ่นทันสมัย (ควรเปิดตัวครั้งสุดท้ายหรือ GIT)
เรียกใช้ r2 -L | grep frida เพื่อตรวจสอบว่าปลั๊กอินถูกโหลดหรือไม่หากไม่มีการพิมพ์ใด ๆ ให้ใช้ตัวแปรสภาพแวดล้อม R2_DEBUG=1 เพื่อรับข้อความการดีบักบางอย่างเพื่อค้นหาเหตุผล
หากคุณมีปัญหาในการรวบรวม R2Frida คุณสามารถใช้ r2env หรือดึงข้อมูลการสร้างจากหน้า GitHub Releases โปรดทราบว่ามีเพียง Major.minor รุ่นเท่านั้นที่ต้องตรงกันนี่คือ R2-5.7.6 สามารถโหลดปลั๊กอินใด ๆ ที่รวบรวมไว้ในรุ่นใด ๆ ระหว่าง 5.7.0 และ 5.7.8
+---------+
| radare2 | The radare2 tool, on top of the rest
+---------+
:
+----------+
| io_frida | r2frida io plugin
+----------+
:
+---------+
| frida | Frida host APIs and logic to interact with target
+---------+
:
+-------+
| app | Target process instrumented by Frida with Javascript
+-------+
ปลั๊กอินนี้ได้รับการพัฒนาโดย Pancake aka Sergi Alvarez (ผู้เขียน Radare2) สำหรับ Nowsecure
ฉันขอขอบคุณ Ole Andréสำหรับการเขียนและบำรุงรักษา Frida รวมถึงใจดีที่จะแก้ไขข้อบกพร่องเชิงรุกและหารือเกี่ยวกับรายละเอียดทางเทคนิคเกี่ยวกับสิ่งที่จำเป็นเพื่อให้สหภาพนี้ทำงาน ความรุ่งโรจน์