最近做淘宝客,然后逐步也转到现在更火的抖音,然后就进入到了需要获取抖音视频商品信息,于是就跟大家一样陷入了xgorgon算法。
从上周五研究了一天,最终了解全貌后卡在这个算法上,后面就一直没管这块内容了,赶一些维护项目,今天抽空又找了找方案,于是找到这个项目:AndroidNativeEmu。
  经过调研,其实最终是卡libcms.so里面的leviathan函数上。某雪论坛上有大神找到不用破解libcms.so直接调用的方法,并且给出了实例。本次就该项目调试的问题,说下解决方法

安装依赖问题

1、keystone-engine依赖引起的错误

项目要求 python3.7+
但是安装的依赖为
unicorn==1.0.1
pyelftools==0.24
hexdump==3.3
keystone-engine==0.9.1.post3

使用python的3.7
keystone-engine这个包的错误,可以通过升级新版本解决,我使用
keystone-engine==0.9.2-rc1.post2

2、unicorn依赖问题

该包更新已经是2017年,之后一直未更新,此包线上安装基本无解,会报一个错误

Installing collected packages: unicorn, pwntools
  Running setup.py install for unicorn ... error
    ERROR: Complete output from command /usr/local/opt/python/bin/python3.7 -u -c 'import setuptools, tokenize;__file__='"'"'/private/var/folders/qv/chchcb394sv7nckc8tqhkhyh0000gn/T/pip-install-n4aggx21/unicorn/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/qv/chchcb394sv7nckc8tqhkhyh0000gn/T/pip-record-d97wwxhx/install-record.txt --single-version-externally-managed --compile:
    ERROR: running install
    running build
    Building C extensions
    cd qemu && \
    	./configure --cc="cc" --extra-cflags="-DUNICORN_HAS_X86 -DUNICORN_HAS_ARM -DUNICORN_HAS_ARMEB -DUNICORN_HAS_M68K -DUNICORN_HAS_ARM64 -DUNICORN_HAS_MIPS -DUNICORN_HAS_MIPSEL -DUNICORN_HAS_MIPS64 -DUNICORN_HAS_MIPS64EL -DUNICORN_HAS_SPARC -fPIC -fvisibility=hidden -m32 -arch i386 -m64 -arch x86_64" --target-list="x86_64-softmmu, arm-softmmu, armeb-softmmu, m68k-softmmu, aarch64-softmmu, mips-softmmu, mipsel-softmmu, mips64-softmmu, mips64el-softmmu, sparc-softmmu,sparc64-softmmu,"

    ERROR: pthread check failed
           Make sure to have the pthread libs and headers installed.

    make: *** [qemu/config-host.h-timestamp] Error 1
    error: [Errno 2] No such file or directory: 'libunicorn.dylib'

此依赖解决方法暂时只能通过下载源码编译的方案
下载后

tar -zxf unicorn-1.0.1.tar.gz
cd unicorn-1.0.1
cp /usr/local/opt/unicorn/lib/lib* ./prebuilt
python3 setup.py install
使用该方法安装成功

3、执行python文件的问题

到了此步就比较简单了,处理一下samples引入

from samples import debug_utils

samples下面没有引用,可以直接

import debug_utils

其他引入牵涉到目录的,更换成,如下(不限于以下地方)

emulator.load_library("samples/example_binaries/libdl.so")
emulator.load_library("samples/example_binaries/libc.so")

换成

emulator.load_library("example_binaries/libdl.so")
emulator.load_library("example_binaries/libc.so")

4、解决如上问题,执行已经没有问题了

1592401411633.jpg
但是最大的问题来了,示例中使用的包已经是19年的,03开头的xgorgon码,现在已经升级到04开头的码,然后我更换了libcms.so包后执行就错误了,这就牵涉到了对新apk的调用栈的研究和相关依赖的研究了,今天花了半天时间,弄好整套代码,跟朋友咨询了一下,明天再做进一步研究了……

参考链接

https://bbs.pediy.com/thread-252562.htm
https://bbs.pediy.com/thread-254799.htm
https://www.cnblogs.com/flatcc/p/11991917.html
还有更多相关的,比较浅显,自行查找吧