Chinaunix首页 | 论坛 | 博客
  • 博客访问: 505154
  • 博文数量: 184
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 1172
  • 用 户 组: 普通用户
  • 注册时间: 2016-06-21 13:40
个人简介

技术改变命运

文章分类

全部博文(184)

文章存档

2020年(16)

2017年(12)

2016年(156)

我的朋友

分类: Android平台

2020-08-02 14:16:37

准备工作

Frida

在对Frida进行了简单的介绍。

设备

设备: Android 10 ROOT

PC: Ubuntu18.04

Python切换

有些时候,需要使用Python的2.x版本,而有些时候又需要使用python的3.x版本,这个时候就需要能够灵活设置python版本 使用下面的命令设置Python2是默认:

  1. sudo update-alternatives --install /usr/bin/python python /usr/bin/python2 100

使用下面的命令设置Python3是默认

  1. sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 150

使用 sudo update-alternatives--config python命令切换到制定的版本 在这里插入图片描述由于Frida建议使用Python3.x,因此这里切换到3的版本。在二进制漏洞中,exploit使用的基本都是Python2.7。

Frida脚本

FRIDA脚本就是利用FRIDA动态插桩框架,使用FRIDA导出的API和方法,对内存空间里的对象方法进行监视、修改或者替换的一段代码。FRIDA的API是使用JavaScript实现的,所以我们可以充分利用JS的匿名函数的优势、以及大量的hook和回调函数的API。

Hello world

Hello world经典的入门程序,frida版本的来一个。

  1. setTimeout(function (){
  2. Java.perform(function (){
  3. console.log("Hello world");
  4. });
  5. });
使用的API

setTimeout(func, delay[, ...parameters]): call func after delay milliseconds, optionally passing it one or more parameters. Returns an id that can be passed to clearTimeout to cancel it.

clearTimeout(id): cancel id returned by call to setTimeout.

Java.perform(fn): ensure that the current thread is attached to the VM and call fn. (This isn’t necessary in callbacks from Java.) Will defer calling fn if the app’s class loader is not available yet. Use Java.performNow() if access to the app’s classes is not needed.

console.log(line), console.warn(line), console.error(line): write line to the console of your Frida-based application.

JavaScript匿名函数

匿名函数:就是没有函数名的函数。这怎么可能,一个函数居然没有函数名,但JavaScript就是支持这种语法的,这和Java等编译型语言又很大的区别。匿名函数最大的用途是创建闭包。闭包是JavaScript的精髓,后续会专门讲解。

阅读(2485) | 评论(0) | 转发(0) |
1

上一篇:fuzz技术和漏洞挖掘

下一篇:Frida之API使用

给主人留下些什么吧!~~