首页 > 系统服务 > 详细

mac使用frida

时间:2019-06-20 10:07:02      阅读:446      评论:0      收藏:0      [点我收藏+]

mac使用frida

安装

https://github.com/frida/frida/releases

根据手机的cpu的版本,选择相应的文件,一般通过手机信息可以看到
我这里是frida-server-12.6.7-android-arm64.xz

解压frida-server-12.6.7-android-arm64.xz,然后把解压后的文件重命名
执行命令frida-server。
依次执行下面命令

$ adb push frida-server /data/local/tmp/ 
$ adb shell "chmod 755 /data/local/tmp/frida-server"
$ adb shell "/data/local/tmp/frida-server &"

然后在电脑上测试手机是否连通

$ adb devices -l

测试frida配置启动成功

frida-ps -U

看到类似的结果

  PID  Name
-----  -----------------------------------------------------------------
 2681  .dataservices
  835  ATFWD-daemon
12174  adbd
  844  adsprpcd
  845  adsprpcd
  745  android.hardware.audio@2.

即可。

插曲okttp3

okhttp3没混淆的hook

try {

    var CertificatePinner = Java.use('okhttp3.CertificatePinner');

    quiet_send('OkHTTP 3.x Found');

    CertificatePinner.check.overload('java.lang.String', 'java.util.List').implementation = function () {

        quiet_send('OkHTTP 3.x check() called. Not throwing an exception.');
    }

} 

okhttp3混淆的话
改为混淆的名字我这里是d.k.a,
Java.use表示使用d包的k类,然后后面CertificatePinner.a.overload
表示hook a方法

/*** okhttp3.x unpinning ***/

// Wrap the logic in a try/catch as not all applications will have
// okhttp as part of the app.
try {
    var CertificatePinner = Java.use('d.k');

    quiet_send('OkHTTP 3.x Found');

    CertificatePinner.a.overload('java.lang.String', 'java.util.List').implementation = function () {

        quiet_send('OkHTTP 3.x check() called. Not throwing an exception.');
    }

} catch (err) {

    // If we dont have a ClassNotFoundException exception, raise the
    // problem encountered.
    if (err.message.indexOf('ClassNotFoundException') === 0) {

        throw new Error(err);
    }
}

application脚本

# -*- coding: utf-8 -*-
import frida, sys, re, sys, os
from subprocess import Popen, PIPE, STDOUT
import codecs, time 

if (len(sys.argv) > 1):
    APP_NAME = str(sys.argv[1])
else:
    APP_NAME = "com.loco.example.OkHttp3SSLPinning"

def sbyte2ubyte(byte):
    return (byte % 256)

def print_result(message):
    print ("[!] Received: [%s]" %(message))

def on_message(message, data):
    if 'payload' in message:
        data = message['payload']
        if type(data) is str:
            print_result(data)
        elif type(data) is list:
            a = data[0]
            if type(a) is int:
                hexstr = "".join([("%02X" % (sbyte2ubyte(a))) for a in data])
                print_result(hexstr)
                print_result(hexstr.decode('hex'))
            else:
                print_result(data)
                print_result(hexstr.decode('hex'))
        else:
            print_result(data)
    else:
        if message['type'] == 'error':
            print (message['stack'])
        else:
            print_result(message)


def kill_process():
    cmd = "adb shell pm clear {} 1> /dev/null".format(APP_NAME)
    os.system(cmd)

#kill_process()

try:
    with codecs.open("hooks.js", 'r', encoding='utf8') as f:
        jscode  = f.read()
        device  = frida.get_usb_device(timeout=5)
        #pid     = device.spawn([APP_NAME])
        session = device.attach("com.loco.example.OkHttp3SSLPinning")
        script  = session.create_script(jscode)
        #device.resume(APP_NAME)
        script.on('message', on_message)
        print ("[*] Intercepting on {} ...".format(APP_NAME))
        script.load()
        sys.stdin.read()
except KeyboardInterrupt:
        print ("[!] Killing app...")
        kill_process()
        time.sleep(1)
        kill_process()

mac使用frida

原文:https://www.cnblogs.com/c-x-a/p/11056627.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!