抖音資料采集教程,unicorn 解決 OLLVM 字串混淆通用方法
短視頻、直播資料實時采集介面,請查看檔案: TiToData
免責宣告:本檔案僅供學習與參考,請勿用于非法用途!否則一切后果自負,
雖然是通用方法,但是要了解 so 加載流程、匯編基礎、java基礎才可以使用哦~
這里用的基于 unicorn 的 androidEmu
AndroidNativeEmu 在面對沒有加殼的 so 還是挺好用的,不過遇到加殼的 so,就會力不從心的,需要 dbg 才行,
解決字串混淆思路,其實和 frida 讀取混淆字串方法一樣,在記憶體中字串是被解密狀態的,所以在記憶體中拿就可以了, 而且
Unicorn提供了unicorn.UC_HOOK_MEM_WRITE來 hook 操作記憶體中的資料
干貨代碼如下:
import logging
import sys
import os
import unicorn
import struct
from androidemu.emulator import Emulator
sys.path.append(os.path.abspath(os.path.dirname(os.path.dirname(__file__))))
logging.basicConfig(
stream=sys.stdout,
level=logging.DEBUG,
format="%(asctime)s %(levelname)7s %(name)34s | %(message)s"
)
logger = logging.getLogger(__name__)
emulator = Emulator(vfp_inst_set=True) # 初始化模擬器
# 字串解密
so_file = "test/test.so"
modify_map = {} # 接收字典
def UC_HOOK_MEM_WRITE(mu, _type, address, size, _value, user_data):
byte_array = struct.pack("I", value)[:size]
modify_map[address] = byte_array
return
# 加載預設 so
emulator.load_library("example_binaries/libdl.so", do_init=False)
emulator.load_library("example_binaries/libc.so", do_init=False)
emulator.load_library("example_binaries/libstdc++.so", do_init=False)
emulator.load_library("example_binaries/libm.so", do_init=False)
lib_module = emulator.load_library(so_file, do_init=True) # do_init 需要設定為 true
emulator.mu.hook_add(unicorn.UC_HOOK_MEM_WRITE, UC_HOOK_MEM_WRITE) # 準備 UC_HOOK_MEM_WRITE 回呼解決字串加密
"""
讀出代碼,并將被加密的字串修改回去
"""
with open(so_file, 'rb') as f:
content = f.read()
print(modify_map)
for i in modify_map:
value = https://www.cnblogs.com/titodata/archive/2021/01/30/modify_map[i]
base = lib_module.base # 加載基質
if base <= i <= (base + lib_module.size): # 利用加載地址判斷
offset = i - base - 0x1000 # 并不是連續加載,是檔案中的偏移
content = content[:offset] + value + content[offset + len(value):]
down_file = so_file +".fix"
with open(down_file, 'wb') as df:
df.write(content)
print('寫出完畢', down_file)
**
修改 so_file = so檔案地址 運行后就會匯出解密后的 so
注意事項:
- 有的時候so有交叉呼叫,無法直接解密,需要hook住呼叫函式,來解決例外
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/254756.html
標籤:其他
上一篇:Redis-第六章節-事務
