其他
Android某社区加密参数分析
The following article is from 2h0n9 Author 2h0n9.2ck
用到的工具有这些:frida、ida、jeb
var CoolMarket = Java.use('com.coolapk.market.CoolMarketApplication');
CoolMarket.onLog.implementation = function() {
var deviceId = Java.use('com.coolapk.market.util.SystemUtils').getDeviceId(this);
console.log('Device Id: ', deviceId);
var app_token = Java.use('com.coolapk.market.util.AuthUtils').getAS(this, deviceId);
console.log('App Token: ', app_token);
console.log('----------');
return 1;
}
})
但是我在 Function Window 瞎翻想找一些我能看得懂的方法名时看到了这个。
f2c29a109fde487e9350d3e6b881036a
8513efac-09ea-3709-b214-95b366f1a185
0x5d024391
var JNI_LOAD_POINTER = Module.getExportByName('libnative-lib.so', 'JNI_OnLoad'); // 首先拿到 JNI_OnLoad方法的地址
// 这里减去的是从so中得到的JNI_OnLoad的地址 0x31A04
var BASE_ADDR = parseInt(JNI_LOAD_POINTER) - parseInt('0x31A04'); // 用程序运行中JNI_OnLoad的绝对地址减去它的相对地址得到基址
// MD5::MD5
Java.perform(function() {
// 然后用基址 + 要hook的方法的相对地址就得到了绝对地址
var hookpointer = '0x' + parseInt(BASE_ADDR + parseInt('0x32168')).toString(16) // 获取要hook方法的地址
var pointer = new NativePointer(hookpointer) // 根据方法地址构建NativePointer
console.log('[MD5::MD5] hook pointer: ', pointer)
var arg0, arg1, arg2, arg3
Interceptor.attach(pointer, {
onEnter: function(args) {
arg0 = args[0]
arg1 = args[1]
console.log('\n')
console.log('=====> [MD5::MD5] -> [方法调用前]')
console.log('参数1: {0} => {1}'.format(arg0, Memory.readCString(arg0))) // Memory.readCString 是读取地址为字符串,类似的还有readUtf8String、readUtf16String等
console.log('参数2: {0} => {1}'.format(arg1, Memory.readCString(arg1)))
console.log('\n')
},
onLeave: function(retval) {
console.log('\n')
console.log('=====> [MD5::MD5] -> [方法调用后]:')
console.log('返回值: ', retval)
console.log('参数1: {0} => {1}'.format(arg0, Memory.readCString(arg0)))
console.log('参数2: {0} => {1}'.format(arg1, Memory.readCString(arg1)))
console.log('\n')
}
}
)
})
// MD5::update
Java.perform(function() {
var hookpointer = '0x' + parseInt(BASE_ADDR + parseInt('0x329AC')).toString(16) // 获取要hook方法的地址
var pointer = new NativePointer(hookpointer) // 根据方法地址构建NativePointer
console.log('[MD5::update] hook pointer: ', pointer)
var arg0, arg1, arg2, arg3
Interceptor.attach(pointer, {
onEnter: function(args) {
arg0 = args[0]
arg1 = args[1]
arg2 = args[2]
console.log('\n')
console.log('=====> [MD5::update] -> [方法调用前]')
console.log('参数1: {0} => {1}'.format(arg0, Memory.readCString(arg0)))
console.log('参数2: {0} => {1}'.format(arg1, Memory.readCString(arg1)))
console.log('参数3: {0} => {1}'.format(arg2, Memory.readCString(arg2)))
console.log('\n')
},
onLeave: function(retval) {
console.log('\n')
console.log('=====> [MD5::update] -> [方法调用后]:')
console.log('返回值: ', retval)
console.log('参数1: {0} => {1}'.format(arg0, Memory.readCString(arg0)))
console.log('参数2: {0} => {1}'.format(arg1, Memory.readCString(arg1)))
console.log('参数3: {0} => {1}'.format(arg2, Memory.readCString(arg2)))
console.log('\n')
}
}
)
})
// MD5::finalize
Java.perform(function() {
var hookpointer = '0x' + parseInt(BASE_ADDR + parseInt('0x321C4')).toString(16) // 获取要hook方法的地址
var pointer = new NativePointer(hookpointer) // 根据方法地址构建NativePointer
console.log('[MD5::finalize] hook pointer: ', pointer)
var arg0, arg1, arg2, arg3
Interceptor.attach(pointer, {
onEnter: function(args) {
arg0 = args[0]
arg1 = args[1]
arg2 = args[2]
arg3 = args[3]
console.log('\n')
console.log('=====> [MD5::finalize] -> [方法调用前]')
console.log('参数1: {0} => {1}'.format(arg0, Memory.readCString(arg0)))
console.log('参数2: {0} => {1}'.format(arg1, Memory.readCString(arg1)))
console.log('参数3: {0} => {1}'.format(arg2, Memory.readCString(arg2)))
console.log('参数4: {0} => {1}'.format(arg3, Memory.readCString(arg3)))
console.log('\n')
},
onLeave: function(retval) {
console.log('\n')
console.log('=====> [MD5::finalize] -> [方法调用后]:')
console.log('返回值: ', retval)
console.log('参数1: {0} => {1}'.format(arg0, Memory.readCString(arg0)))
console.log('参数2: {0} => {1}'.format(arg1, Memory.readCString(arg1)))
console.log('参数3: {0} => {1}'.format(arg2, Memory.readCString(arg2)))
console.log('参数4: {0} => {1}'.format(arg3, Memory.readCString(arg3)))
console.log('\n')
}
}
)
})
token://com.coolapk.market/c67ef5943784d09750dcfbb31020f0ab?
3823215d91d29d9887ebc05f0d7fd30d
$
8513efac-09ea-3709-b214-95b366f1a185
&
com.coolapk.market
import time
import hashlib
import base64
DEVICE_ID = "8513efac-09ea-3709-b214-95b366f1a185"
def get_app_token():
t = int(time.time())
hex_t = hex(t)
# 时间戳加密
md5_t = hashlib.md5(str(t).encode('utf-8')).hexdigest()
# 不知道什么鬼字符串拼接
a = 'token://com.coolapk.market/c67ef5943784d09750dcfbb31020f0ab?{}${}&com.coolapk.market' \
.format(md5_t, DEVICE_ID)
# 不知道什么鬼字符串拼接 后的字符串再次加密
md5_a = hashlib.md5(base64.b64encode(a.encode('utf-8'))).hexdigest()
token = '{}{}{}'.format(md5_a, DEVICE_ID, hex_t)
print(token)
return token
def request():
url = "https://api.coolapk.com/v6/main/indexV8?page=1"
headers = {
"User-Agent": "Dalvik/2.1.0 (Linux; U; Android 9; MI 8 SE MIUI/9.5.9) (#Build; Xiaomi; MI 8 SE; PKQ1.181121.001; 9) +CoolMarket/9.2.2-1905301"
}
headers = {
"User-Agent": "Dalvik/2.1.0 (Linux; U; Android 9; MI 8 SE MIUI/9.5.9) (#Build; Xiaomi; MI 8 SE; PKQ1.181121.001; 9) +CoolMarket/9.2.2-1905301",
"X-App-Id": "com.coolapk.market",
"X-Requested-With": "XMLHttpRequest",
"X-Sdk-Int": "28",
"X-Sdk-Locale": "zh-CN",
"X-Api-Version": "9",
"X-App-Version": "9.2.2",
"X-App-Code": "1903501",
"X-App-Device": "QRTBCOgkUTgsTat9WYphFI7kWbvFWaYByO1YjOCdjOxAjOxEkOFJjODlDI7ATNxMjM5MTOxcjMwAjN0AyOxEjNwgDNxITM2kDMzcTOgsTZzkTZlJ2MwUDNhJ2MyYzM",
"Host": "api.coolapk.com",
"X-Dark-Mode": "0",
"X-App-Token": get_app_token(),
}
resp = requests.get(url, headers=headers)
print(resp.text)
if __name__ == '__main__':
request()
代码啥的都提交到Github了,CoolapkTokenCrack
看雪ID:zckuna
https://bbs.pediy.com/user-753570.htm
推荐文章++++
进阶安全圈,不得不读的一本书