简体   繁体   English

如何识别 .smali 文件中声明的方法?

[英]How I can identify methods declared in .smali file?

I want to extracts method from all .smalli file .我想从所有 .smalli 文件中提取方法。
Is there any format to declare methods(API Functions) in .smalli file so i can easily extract it using python script.是否有任何格式可以在 .smalli 文件中声明方法(API 函数),以便我可以使用 python 脚本轻松提取它。 I am looking for concept so I can identify how 1. User-define function 2. API function 3. API call sequence are defined and declared .I want to print only API functions and API call sequence using python .我正在寻找概念,所以我可以确定如何 1. 用户定义函数 2. API 函数 3. API 调用序列是定义和声明的。我只想使用 python 打印 API 函数和 API 调用序列。

The question asks about parsing smali files, but that is unlikely to be what you actually want.该问题询问解析 smali 文件,但这不太可能是您真正想要的。 Assuming your goal is to analyze Android applications, you need to parse dex files.假设您的目标是分析 Android 应用程序,您需要解析dex文件。 Luckily, there is a tool written in Python called Enjarify that contains a dex parser.幸运的是,有一个用 Python 编写的名为Enjarify的工具,其中包含一个 dex 解析器。 It's not designed to be used as a library, so it will take a little bit of work to integrate, but you should be able to figure it out pretty easily.它不是为用作库而设计的,因此集成需要一些工作,但您应该能够很容易地弄清楚它。 You can start by looking at parsedex.py .您可以从查看parsedex.py开始。

Assuming that you really do want to parse smali files for some reason, things are a lot harder, as smali is a file format defined by the smali tool, which is written in Java.假设您出于某种原因确实想解析 smali 文件,事情会困难得多,因为 smali 是由 smali 工具定义的文件格式,它是用 Java 编写的。 However, you could use Jython to call it from Python.但是,您可以使用 Jython 从 Python 调用它。

Following is Syntax that is used to identify .Smali Function calls以下是用于识别 .Smali 函数调用的语法

  1. invoke-super vx, vy, : invokes the parent classes method in object vx, passing in parameter(s) vy. invoke-super vx, vy, : 调用对象 vx 中的父类方法,传入参数 vy。
  2. invoke-direct vx, vy : invokes a method in object vx with parameters vy, … without the virtual method resolution. invoke-direct vx, vy :调用对象 vx 中的方法,参数为 vy, ... 没有虚方法解析。
  3. invoke-virtual vx, vy : invokes the virtual method in object vx, passing in parameters vy. invoke-virtual vx, vy :调用对象vx中的虚方法,传入参数vy。

Following links provide good source to start with .smalli file https://apkudo.com/?p=775以下链接提供了从 .smalli 文件开始的良好来源https://apkudo.com/?p=775

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM