FART与frida结合

1、优点:

1、对FART的脱壳能力增强,对主动调用的dex(没有初始函数)进行脱壳

function fartwithClassloader() {
    Java.perform(function () {

        Java.choose("dalvik.system. ", {

            onMatch: function (instance) {
                console.log(instance);

                try {
                    Java.use("android.app.ActivityThread").fartwithClassloader(instance);
                } catch (e) {
                    console.log(e);
                }
            },
            onComplete: function () {
                console.log("heap search complete");
            }

        });
    })


}
//hook DexClassLoader 主动调用 fartwithClassloader 来对主动调用的类进行脱壳

2、控制FART主动调用的范围,比如按需进行类甚至函数的修复

1、只对某个类主动调用加载

//cn.cntv.ui.activity.SpringPlayerActivity

function loadoneclass(classname) {
    Java.perform(function () {
//public static void loadClassAndInvoke
//(ClassLoader appClassloader, String eachclassname, Method dumpMethodCode_method)
//public static ClassLoader getClassloader()
        var appClassloader = Java.use("android.app.ActivityThread").getClassloader();
        console.log("appClassloader->", appClassloader);
        //dumpMethodCode
// private static native void dumpMethodCode(Object m);
        var DexFile = Java.use("dalvik.system.DexFile");
        var Object = Java.use("java.lang.Object");
        var array = Java.array("java.lang.Class", [Object.class]);
        var dumpMethodCode = DexFile.class.getDeclaredMethod("dumpMethodCode", array);
        dumpMethodCode.setAccessible(true);//私有函数无法直接调用,需要设置
        console.log("dumpMethodCode->", dumpMethodCode);
        Java.use("android.app.ActivityThread").loadClassAndInvoke(appClassloader, classname, dumpMethodCode);
    })
}

2、编译时不主动加载fart,使用frida主动调用脱壳线程

function justfart() {
    Java.perform(function () {
         Java.use("android.app.ActivityThread").fartthread();
    })
}

rpc远程调用

rpc.exports = ({

    loadclasslist: function (classname) {
        loadoneclass(classname);
    }

});
import frida
import sys


def on_message(message, data):
    if message['type'] == 'send':
        print("[*] {0}".format(message['payload']))
    else:
        print(message)


device = frida.get_usb_device()
if __name__ == "__main__":
    try:
        session = device.attach("cn.cntv")
        print("[Info] Attach success!")
        with open('fart_frida.js') as f:
            jscode = f.read()
        script = session.create_script(jscode)
        script.on('message', on_message)
        print('[*] Running CTF')
        script.load()
        #Lcom/hpplay/sdk/source/service/e$a;
        content=""
        with open('8848960_classlist_execute.txt','r') as f:
            content=f.read()
            f.close()
        array=content.split("\n")
        for i in array:
            print("classname->"+i)
            #Lcom/hpplay/sdk/source/service/e$a;
            i=i[1:len(i)-1]
            i=i.replace('/','.')
            print("classname->" + i)
            script.exports.loadclasslist(i)
        #script.exports.loadclasslist()
        sys.stdin.read()
    except Exception as e:
        print("[Info] Spawn and attach failed!")
        print(e)

 

 

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值