All Projects → Simp1er → AndroidSec

Simp1er / AndroidSec

Licence: other
记录一些我自己在学习Android逆向过程中的有意思的东西

Programming Languages

javascript
184084 projects - #8 most used programming language
python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to AndroidSec

Fridacontainer
FridaContainer 整合了网上流行的和自己编写的常用的 frida 脚本,为逆向工作提效之用。 frida 脚本模块化,Java & Jni Trace。
Stars: ✭ 190 (-66.37%)
Mutual labels:  hook, frida
Fridaandroidtracer
A runnable jar that generate Javascript hook script to hook Android classes.
Stars: ✭ 114 (-79.82%)
Mutual labels:  hook, frida
Dexcalibur
[Official] Android reverse engineering tool focused on dynamic instrumentation automation. Powered by Frida. It disassembles dex, analyzes it statically, generates hooks, discovers reflected methods, stores intercepted data and does new things from it. Its aim is to be an all-in-one Android reverse engineering platform.
Stars: ✭ 512 (-9.38%)
Mutual labels:  hook, frida
Frida Skeleton
基于frida的安卓hook框架,提供了很多frida自身不支持的功能,将hook安卓变成简单便捷,人人都会的事情
Stars: ✭ 222 (-60.71%)
Mutual labels:  hook, frida
nxdk-rdt
Remote Dev Tool is a tool to remote control an Xbox using memory access and RPC
Stars: ✭ 23 (-95.93%)
Mutual labels:  hook
frida-screenshot
Grab screenshots using Frida.
Stars: ✭ 35 (-93.81%)
Mutual labels:  frida
resize-observer-hook
⚛️ A React Hook to monitor changes in the size of an element using native ResizeObserver API 🔍
Stars: ✭ 45 (-92.04%)
Mutual labels:  hook
messier
Messier is an app for tracing objective-c methods in an iOS app.
Stars: ✭ 72 (-87.26%)
Mutual labels:  hook
storken
🦩 Storken is a React State Manager. Simple as `useState`.
Stars: ✭ 22 (-96.11%)
Mutual labels:  hook
BaiDuYunCrack
iOS百度云盘 破解速度限制、去广告、去更新 无需越狱~
Stars: ✭ 82 (-85.49%)
Mutual labels:  hook
KeyBoardTool
Keyboard key detection software realized by Qt(Qt实现的键盘按键检测软件)
Stars: ✭ 35 (-93.81%)
Mutual labels:  hook
riru MPH
Hook android system prop function to add properties
Stars: ✭ 23 (-95.93%)
Mutual labels:  hook
svg-to-swiftui-core
Headless package for converting SVG to SwiftUI
Stars: ✭ 25 (-95.58%)
Mutual labels:  hook
iosHookViewId
A solution for ios hook view id(给iOS应用自动生成控件id)
Stars: ✭ 44 (-92.21%)
Mutual labels:  hook
react-hook-videojs
Easy React integration of Video.js using hooks.
Stars: ✭ 37 (-93.45%)
Mutual labels:  hook
react-use-downloader
Creates a download handler function and gives progress information
Stars: ✭ 65 (-88.5%)
Mutual labels:  hook
objects-hooks-remover
Package to remove WordPress hook callbacks that uses object methods or closures.
Stars: ✭ 44 (-92.21%)
Mutual labels:  hook
klyva
A state management library that follows the React component model
Stars: ✭ 53 (-90.62%)
Mutual labels:  hook
ARMStrong
A fast and simple ARM Simulator made for education based upon Unicorn and Keystone engines
Stars: ✭ 99 (-82.48%)
Mutual labels:  unicorn
usehooks-ts
React hook library, ready to use, written in Typescript.
Stars: ✭ 2,873 (+408.5%)
Mutual labels:  hook

AndroidSec

1. Dalvik下DexClassLoader动态加载关键函数链(基于Android4.4)

2. Art下DexClassLoader动态加载关键函数链(基于Android8.0)

3. Art下InMemoryDexClassLoader动态加载关键函数链(基于Android8.0)

4. Dalvik下RegisterNatives动态注册关键函数链(基于Android4.4)

4. Art下RegisterNatives动态注册关键函数链(基于Android8.1)

2020-07-08 新增dex2apk.py

一个用于将脱壳下来的众多dex重新组装成apk的脚本,免去Android安全测试人员在逆向过程中不停grep的操作

  • usage: python dex2apk.py [-h] -a APK_PATH -i DEX_PATH [-o OUTPUT]

将重新组合的apk拖入jadxjeb,展示结果如下:

2020-09-19 将自己之前改的的DumpApkInfo工具引入

DumpApkInfo可以用来dump加壳信息、签名信息、APK包名等等功能,具体参见子模块readme

2020-10-09 增加unicorn trace arm64的基本代码

大概效果如下

image-20201009105052076

基于unicorn和capstone来trace函数执行流程并记录寄存器信息,具体自己看代码吧,只是一个demo

2020-10-10 增加一个byte数组转hexString的dex

手动封装了okio.ByteString的函数,并打包成dex,避免frida在hook APP时无法使用ByteString的转hex方法,frida使用方式

首先将dex push进/data/local/tmp/目录下,然后chmod给予dex执行权限,frida调用时

 Java.perform(function (){
 			 var okio = Java.openClassFile("/data/local/tmp/okio.dex")
       okio.load()
   			var ByteString  = Java.use("com.Simp1er.okio.ByteString")
         ByteString.$new(key_bytes).hex()// 其实接下来就是ByteString的函数调用了
 })

参考: ByteString.java

2020-10-31 增加hook_init_array代码

通过hooklinkercall_array函数,hook得到init_array地址,在Android8.1 64位程序和32为程序上都测试成功,其他的请自己测试更改。

2020-11-02 增加hook_constructors代码

通过hooklinkerasync_safe_format_log函数,hook得到init_array以及.init_proc地址,在Android8.1 64位程序和32为程序上都测试成功,其他的请自己测试更改。 64位效果如下: image-20201102192311913.png 32位效果如下: image-20201102192324644.png

2021-03-31 增加主动获取context方法

利用ActivityThread的单例模式获取到应用的上下文Context用于后续利用

效果如下 image-20210331.png

2021-04-06 增加hook RegisterNative函数的脚本

由于jni函数无论是动态注册或者静态注册的函数都会在加载过程中都会调用RegisterNative函数注册JNI函数最终函数地址,因此可以通过hook RegisterNative函数获取JNI函数最终地址以及函数实现所在模块,最终效果如下:

image-20210406.png

注意:仅在Android 8.1.0_r1下测试成功,其他版本可能失效

20210730补充:更新由于可能存在匿名内存块的情况导致无法通过ModuleMap找到相应模块的情况处理

2021-04-14 增加在native层遍历HashMap代码

native层遍历HashMapkeyvalue类型都为String的脚本

传入一个JNIEnvHashMap的对象即可 最终效果如下

xxx => azU7Bc002xAAJ9QEYW1mGJrO8f0Ed9QH0FqzYdOlL8/Md/QHpENnwiLJhCBZB5mhQtIXdU8Pnw43BRB7hD6QY3VDdZfUF9QH1BfUB9
bbbb => HHnB_FCRa80QdwWegx+jn98jVfguVXqGwR3kh9ROtBHavXaYZV+qLX+lUnG4LVQfyqsJ/zFo0JH2gRVVSi98GPkuj9GWADR18oS+VyJ2XhLUQYev/wQDCMFWSAYaGABE2SOBT
cccc => JAE5zHBA7W55NB1VcTLaT8wI/An8Ae8A+wn5Gvsa7wj6CPQN/Qv6CPg=
dddd => hwIABwRLPF9s5QJ40ATaaW1cNymwhLCe

2021-04-17 get到一个新姿势:更改进程名

android.os.Process中的setArgV0()函数可用于改变APP的进程名。感谢卓桐大佬!!Android修改进程名

注意:这里由于Java.lang.Process类是默认导入的包,因此在使用时需要单独import导入android.os.Process类。

import android.os.Process;

try {
    // https://bbs.pediy.com/thread-253676.htm
    Method setArgV0 = Process.class.getDeclaredMethod("setArgV0", String.class);
    setArgV0.setAccessible(true);
    setArgV0.invoke(null,"com.tencent.mm");

} catch (Throwable e) {
    // java.lang.NoSuchMethodException: setArgV0 [class java.lang.String]
    e.printStackTrace();
    Log.i("nicai", "onCreate: ");
} 

这里测试APP的包名为com.test.changeprocessname但是当使用ps -e命令查看进程会发现找不到这个进程,最终效果如下

2021-04-24 又找到一个anti-frida的方式

frida在注入进程后如果脚本中使用registerClass这个API,在内存空间中会出现frida为前缀的vdex/odex,即使frida退出后,本次进程的内存空间仍旧还存在这样的痕迹。

展示如下图

anti-anti的方式是在调用registerClass这个API之前执行以下语句

Java.classFactory.tempFileNaming.prefix = "onetwothree"
..
Java.registerClass(...)

自定义后效果

2021-05-23 frida hook enum class 的方式

hookEnum.js

hook Enum类时,this指针就是Enum类中具体成员的值。

比如我这里写了一个枚举类,代码如下

public enum enumClazz {
    OAID("QAID"),TOKEN("TOKEN"), VIP("1");

    private String value;
     enumClazz(String value){
        this.value = value;
    }

    public String getValue(){
        return this.value;
    }
    public void setValue(String value){
        this.value = value;
        Log.e("enum", "className: " + this );
    }
}

在调用时使用方法像这样

enumClazz.OAID.setValue("OAID_value");
enumClazz.TOKEN.setValue("TOKEN_value");
enumClazz.VIP.setValue("VIP_value");

此时调用setValue(String)函数打印出来的日志如下

2021-05-23 16:24:31.258 26207-26207/com.simp1er.enumdemo E/enum: className: OAID
2021-05-23 16:24:31.262 26207-26207/com.simp1er.enumdemo E/enum: className: TOKEN
2021-05-23 16:24:31.265 26207-26207/com.simp1er.enumdemo E/enum: className: VIP

可以发现其实对应的this指针就是对应调用的枚举成员。

最终使用frida进行hook时,主要代码如下

function hook(){
    Java.perform(function(){
        var enumClazz = Java.use('com.simp1er.enumdemo.enumClazz')
    enumClazz.setValue.implementation = function(){
        var value = arguments[0];
        console.log('class =>',this,", value =>",value) // this即代表enum类的对象名称。
      //  console.log('class =>',this.getString())
        return this.setValue(value)
    }
    });
}

效果如下

class => OAID , value => OAID_value
class => TOKEN , value => TOKEN_value
class => VIP , value => VIP_value

但是参考中的this.getString()方法并没有成功。

参考:https://bbs.pediy.com/thread-258772.htm#enum%E6%B5%8B%E8%AF%95

2021-06-03 frida 无法hook上函数总结

如果函数hook不到,

  • 首先,想想这个函数是不是真的执行到了;
  • 其次,想想函数所在类是不是接口类、是不是抽象类(检查方法可以通过Objection-WallBreaker搜索是否有对应实例或者直接看官方文档,如果是抽象类要找对应继承类中是否有对应函数的实现、如果是接口类找对应implements)
  • 再次,可以试试Java.deoptimizeEverything()函数

-- 记一次hook不到有感

Hooking to Context doesn't work

Context类

2021-07-28 将注册的类加入双亲委派链

hook代码

将通过Java.registerClass() API注册的类所在的dexclassLoader加入系统classLoader双亲委派链中,保证能够Class.forName函数调用注册的函数时能够成功。

2021-11-10 增加两个打印java调用栈的frida脚本

hook代码

参考今天早上看到的一个repoXposed打印调用栈的方式,写出对应的frida脚本。

Stargazers over time

Stargazers over time

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].