首页 > 其他分享 >Frida官方文档-快速入门指南

Frida官方文档-快速入门指南

时间:2023-04-25 10:05:39浏览次数:38  
标签:function 入门 args recvfrom state 文档 frida Frida log


对于不耐烦的人, 这里是使用Frida进行跟踪的方法

~ $ pip install frida-tools
~ $ frida-trace -i "recv*" -i "read*" *twitter*
recv: Auto-generated handler: …/recv.js
#(snip)
recvfrom: Auto-generated handler: …/recvfrom.js
Started tracing 21 functions. Press Ctrl+C to stop.
    39 ms	recv()
   112 ms	recvfrom()
   128 ms	recvfrom()
   129 ms	recvfrom()

如您所见,Frida将自己注入Twitter,枚举已加载的共享库,并钩住名称以recv或read开头的所有函数。 它还生成了一些样板脚本,用于在函数调用发生时检查它们。 现在,这些脚本只是您要进行编辑以使其具有品味的示例,随着它们在文件系统上的更改,它们将自动重新加载。 默认情况下,它们仅打印函数的名称,如您在上面的输出中所见
现在,让我们看一下生成的recvfrom.js:

/*
 * Auto-generated by Frida. Please modify to match the
 * signature of recvfrom.
 *
 * This stub is somewhat dumb. Future verions of Frida
 * could auto-generate based on OS API references, manpages,
 * etc. (Pull-requests appreciated!)
 *
 * For full API reference, see:
 * http://www.frida.re/docs/javascript-api/
 */

{
    /**
     * Called synchronously when about to call recvfrom.
     *
     * @this {object} - Object allowing you to store state for
     * use in onLeave.
     * @param {function} log - Call this function with a string
     * to be presented to the user.
     * @param {array} args - Function arguments represented as
     * an array of NativePointer objects.
     * For example use args[0].readUtf8String() if the first
     * argument is a pointer to a C string encoded as UTF-8.
     * It is also possible to modify arguments by assigning a
     * NativePointer object to an element of this array.
     * @param {object} state - Object allowing you to keep
     * state across function calls.
     * Only one JavaScript function will execute at a time, so
     * do not worry about race-conditions. However, do not use
     * this to store function arguments across onEnter/onLeave,
     * but instead use "this" which is an object for keeping
     * state local to an invocation.
     */
    onEnter: function onEnter(log, args, state) {
        log("recvfrom()");
    },

    /**
     * Called synchronously when about to return from recvfrom.
     *
     * See onEnter for details.
     *
     * @this {object} - Object allowing you to access state
     * stored in onEnter.
     * @param {function} log - Call this function with a string
     * to be presented to the user.
     * @param {NativePointer} retval - Return value represented
     * as a NativePointer object.
     * @param {object} state - Object allowing you to keep
     * state across function calls.
     */
    onLeave: function onLeave(log, retval, state) {
    }
}

现在,使用下面的代码代替log()

log("recvfrom(socket=" + args[0].toInt32()
    + ", buffer=" + args[1]
    + ", length=" + args[2].toInt32()
    + ", flags=" + args[3]
    + ", address=" + args[4]
    + ", address_len=" + args[5].readPointer().toInt32()
    + ")");

Save the file (it will be reloaded automatically) and perform some action in your Twitter application to trigger some network activity. You should now see something along the lines of:
保存文件(该文件将自动重新加载),然后在您的Twitter应用程序中执行某些操作以触发某些网络活动。 现在,您应该可以看到以下内容:

8098 ms	recvfrom(socket=70,
                         buffer=0x32cc018, length=65536,
                         flags=0x0,
                         address=0xb0420bd8, address_len=16)

That’s nothing, though. The real magic happens when you start building your own tools using the Python API that frida-trace is built on top of.
没什么 当您开始使用在frida-trace构建于Python之上的Python API来构建自己的工具时,真正的魔力就会发生。

这里保留英文,总是不能明确的翻译出意思来。

Q&A

一个小问题的,在使用USb连接手机的时候执行 frida-trace -i “recv*” -i “read*” twitter会出现如下的错误,需要用下面的命令执行
Failed to attach: unable to find process with pid 3308

frida-trace -i "open"  -i "read*"  -U tv.danmaku.bili

修改log()之后出现下面的错误:(不清楚是否和模拟器有关)

{‘type’: ‘error’, ‘description’: ‘Error: access violation accessing 0x0’, ‘stack’: ‘Error: access violation accessing 0x0\n at frida/runtime/core.js:132\n at [anon] (input:28)\n at invokeCallback (/tracer.js:49)\n at /tracer.js:55’, ‘fileName’: ‘frida/runtime/core.js’, ‘lineNumber’: 132, ‘columnNumber’: 1}

标签:function,入门,args,recvfrom,state,文档,frida,Frida,log
From: https://blog.51cto.com/u_16087831/6223425

相关文章

  • 解决企业微信在线文档里的代码复制后不能执行的问题
    【问题】某日帮同事改了个SQL,自己能执行,因为懒得另存为,就直接丢到企业微信发了。企业微信提示因为超长生成了在线文档。同事复制后,执行一直报错,类似下面的情况:【报错】 【能执行】【原因】既然语法正确,那么就把文档下载下来瞅瞅。以下是WPS的检查方法,word检查方法类似。......
  • 接口测试快速入门1简介
    简介本章介绍应用程序编程接口(APIapplicationprogramminginterface)和API测试。API测试是软件测试活动的一个重要方面(在典型的基于服务的软件开发过程中)。它包括测试应用程序的业务组件,通常表示为API,然后再开发UI。一个微服务处理单一需求的API。什么是API测试?API对应用层进......
  • 界面控件DevExtreme使用指南 - 折叠组件快速入门(二)
    DevExtreme拥有高性能的HTML5/JavaScript小部件集合,使您可以利用现代Web开发堆栈(包括React,Angular,ASP.NETCore,jQuery,Knockout等)构建交互式的Web应用程序,该套件附带功能齐全的数据网格、交互式图表小部件、数据编辑器等。请注意:在开始本教程之前,请确保DevExtreme已安装在Angula......
  • P.1-SpringSecurity简介、P.2-入门案例准备、P.3入门案例引入SpringSecurity
    P1.SpringSecurity简介SpringSecurity是Spring家族中的一个安全管理框架。一般Web应用的需要进行认证和授权认证:验证当前访问系统的是否是本系统的用户,并且要确认具体是那个用户授权:经过认证后判断当前用户是否有权限进行某个操作......
  • Rust编程语言入门之高级特性
    高级特性主要内容不安全Rust高级Trait高级类型高级函数和闭包宏一、不安全Rust匹配命名变量隐藏着第二个语言,它没有强制内存安全保证:UnsafeRust(不安全的Rust)和普通的Rust一样,但提供了额外的“超能力”UnsafeRust存在的原因:静态分析是保守的。使用......
  • kettle从入门到精通 第十六课 kettle 映射 (子转换)02
    1、上节讲的子映射里面只有一个转换(类似一个java类里面只有一个公共方法),本次讲解的有两个,实际上可以有任意多个(一个java类里面有多个公共方法)。两个转换分别计算x+y和x*y。 2、命名参数:定义一些变量传递到子转换里面。 3、输入1)Availableinputs可以点击加号增加多个输入,......
  • SpringSecurity从入门到精通:登录接口代码实现&测试接口
    登录接口代码实现 @RestController @RestControllerpublicclassLoginController{@AutowiredprivateLoginServcieloginServcie;@PostMapping("/user/login")publicResponseResultlogin(@RequestBodyUseruser){returnloginServ......
  • ctfshow web入门 sql注入 web 183-186
    web183-web186涉及盲注,不管是时间盲注还是布尔盲注,若用手工,会非常耗时,通常使用脚本重点:​ 1、了解python脚本编写​ 2、了解条件语句(where、having)区别​ 3、了解sql语句位运算符​ 4、了解mysql特性​ 5、扩展了解简单爬虫目录web183web184web185web186web183//拼......
  • 使用Plist编辑器——简单入门指南
     本指南将介绍如何使用Plist编辑器。您将学习如何打开、编辑和保存plist文件,并了解plist文件的基本结构和用途。跟随这个简单的入门指南,您将掌握如何使用Plist编辑器轻松管理您的plist文件。plist文件是一种常见的配置文件格式,用于存储应用程序或系统的设置信息,如键值对、......
  • Perl教程_编程入门自学教程_菜鸟教程-免费教程分享
    教程简介Perl入门教程-从基本到高级概念的简单简单步骤了解Perl,包括简介,环境,语法,数据类型,变量,标量,数组,哈希,IF...ELSE,循环,运算符,日期和时间,子程序,引用,格式,文件I/O,目录,错误处理,特殊变量,编码标准,正则表达式,发送电子邮件,套接字编程,面向对象,数据库访问,CGI编程,包和模块,流程管理,嵌......