侧边栏壁纸
  • 累计撰写 7 篇文章
  • 累计创建 1 个标签
  • 累计收到 0 条评论

目 录CONTENT

文章目录

闲鱼App逆向2:接口参数分析

Faithlv
2023-10-28 / 0 评论 / 3 点赞 / 1379 阅读 / 3445 字 / 正在检测是否收录...

接口分析

以搜索闲鱼接口为例 https://g-acs.m.goofish.com/gw/mtop.taobao.idlemtopsearch.search/1.0/

模拟器内用闲鱼多次请求一个接口,在Charles中比较请求头不同,发现x-sgext、x-mini-wua、x-c-traceid、x-t、x-umt、x-sign变化

只要找到找到构造这些参数的方法,就可以模拟闲鱼app发起请求

其中x-t是时间戳,x-c-traceid不带也能正常请求,所以只需要知道x-sgext、x-mini-wua、x-umt、x-sign即可。

App逆向

在知道需要那些参数后,再就是从app源码中找到构造这些参数的方法

首先需要拿到app的源码,使用jadx逆向app,这步就是拿到app代码,jadex github地址https://github.com/skylot/jadx/releases ,下载后把app扔进去就行。

加密方法定位

从app代码中找到上面x-sgext、x-mini-wua、x-umt、x-sign的构造方法

定位到 mtopsdk.security.InnerSignImpl类下面的getUnifiedSign方法,该方法就是构造上面加密参数。

定位加密方法可以通过全局搜索,以x-sign为例,全局搜索字符串x-sign,找到那些看起来像是加密的方法,然后用frida hook方法,验证入参和出参,基本就能判断是不是加密方法。

firda hook代码

import frida, sys

jscode = '''
    Java.perform(
    function(){
            function javaMapToJsObject(map){
                //遍历保存为js对象
                var res = {};
                var keySet = map.keySet();
                var it = keySet.iterator();
                while(it.hasNext()){
                    var key = it.next().toString();
                    var value = map.get(key);
                    if(value == null){
                        res[key] = null;
                    }else{
                        res[key] = value.toString();
                    }
                }
                return res;
            }
            
            console.log("############################ Frida 开启 ############################");
            var InnerSignImpl = Java.use("mtopsdk.security.InnerSignImpl");
            if(InnerSignImpl != undefined){
                console.log("############################ 定位到类 InnerSignImpl ############################");
                InnerSignImpl.getUnifiedSign.implementation = function(map1, map2, string1, string2,bool,string3){
                    console.log("############################ my打印入参 ############################");
                    console.log("map1: " + JSON.stringify(javaMapToJsObject(map1)));
                    console.log("map2: " + JSON.stringify(javaMapToJsObject(map2)));
                    console.log("string1: " + string1);
                    console.log("string2: " + string2);
                    console.log("bool: " + bool);
                    console.log("string3: " + string3);

                    var ret = this.getUnifiedSign(map1,map2,string1,string2,bool,string3);
                    console.log("############################ my打印返参 ############################");
                    console.log("ret " + ret);
                    
                    return ret;
            }
            }

    }
)
'''


def on_message(message, data):
    print("[%s] => %s" % (message, data))


device = frida.get_usb_device(1000)
process = device.attach("闲鱼")
script = process.create_script(jscode)

script.on('message', on_message)
script.load()
sys.stdin.read()

3
  • ${post.likes!0}

评论区