一道算法题
本文为看雪论坛文章
看雪论坛作者ID:GitRoy
0x1 通过JEB分析APK
0x2 查看so
0x3 构建自己的思路
0x4 执行自己的思路
function call_fun() {
Java.perform(function () {
var main = Java.use('com.kanxue.ollvm_ndk.MainActivity')
// main.UUIDCheckSum.implementation = function(arg1){
// console.log('java input is',arg1);
// return main.UUIDCheckSum(arg1);
// }
var res = main.UUIDCheckSum('vm8MRDk58srS2jDoRAIswzJU0ALS0z2P50lK');
console.log('java res is: ', res);
})
}
针对交叉引用进行hook:
function hook_native() {
var libBase = Module.getBaseAddress('libnative-lib.so');
var inputStr;
Interceptor.attach(libBase.add(0xFCB4), {
onEnter: function (args) {
// console.log('0xFCB4 Enter');
// console.log(hexdump(args[0]));
// inputStr = args[0];
// console.log(args[1]);
}, onLeave: function () {
// console.log('0xFCB4 onleave');
// console.log(hexdump(inputStr));
}
})
var inputStr2c;
var intpuStrIn;
Interceptor.attach(libBase.add(0x1029C), {
onEnter: function (args) {
inputStr2c = args[0]
// console.log(Memory.readUtf8String(args[1]));
}, onLeave: function (retval) {
// console.log(hexdump(inputStr2c);
// console.log(hexdump(intpuStrIn));
}
})
//nl9LSEj4-rsR3-4nS@-rv{K1-@MR1{3Q412b
Interceptor.attach(libBase.add(0xF9B8), {
onEnter: function (args) {
// console.log(hexdump(args[]));
// console.log(args[2]);
}, onLeave: function (retval) {
// console.log(retval);
}
})
Interceptor.attach(libBase.add(0xF04C), {
onEnter: function (args) {
// console.log(hexdump(args[0]));
// console.log(hexdump(args[]));
// console.log(args[1]);
}, onLeave: function (retval) {
// console.log(hexdump(retval));
}
})
Interceptor.attach(libBase.add(0xF270), {
onEnter: function (args) {
// console.log(hexdump(args[0]));
// console.log(hexdump(args[]));
// console.log(args[1]);
}, onLeave: function (retval) {
// console.log(hexdump(retval));
console.log(Memory.readUtf8String(retval.add(1)));
}
})
}
0x5 第一个算法Trace FCB4
int main() {
using namespace std;
//vm8MRDk58srS2jDoRAIswzJU0ALS0z2P50lK
std::cout << "Hello, World!" << std::endl;
char *input = "vm8MRDk58srS2jDoRAIswzJU0ALS0z2P50lK";
char encode_input[strlen(input)];
int v14 = 0xFF;
int v16 = 0;
int key[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
for (int i = 0; i < strlen(input) - 2; ++i) {
char s = input[i] ^1;
bool v10 = i == 8 || i == 13;
bool v11 = i == 14;
bool v12 = i == 18;
bool v13 = i == 24;
if (v10 || i == 14 || i == 18 || i == 24) {
if (v10 || v12 || v13) {
s = '-';
encode_input[i] = s;
continue;
}
}
if (v11) {
s = 0x34;
encode_input[i] = s;
continue;
}
if (i == 23) {
s = input[i + 1] ^ 1;
}
//这里等于24的时候有特殊处理,v14和v16不做重新赋值,保留当前状态
if (i != 24) {
if (i != 23) {
v14 = v14 ^ input[i];
v16 = v16 + input[i];
} else {
v14 = v14 ^ input[i + 1];
v16 = v16 + input[i + 1];
}
}
encode_input[i] = s;
}
encode_input[34] = key[v16 - (v16 & 0xFFFFFFF0)];
encode_input[35] = key[v14 & 0xf];
std::cout << encode_input << std::endl;
return 0;
}
input:wl9LSEj4-rsR3-4nS@-rv{K1-@MR1{3Q4192
0x6 第二个算法 F404C
#include <iostream>
using namespace std;
void result(char **m_result, char word) {
**m_result = word;
// printf("%x\n", *m_result);
// printf("%s\n", **m_result);
*m_result = *m_result + 1;
}
int main() {
//vm8MRDk58srS2jDoRAIswzJU0ALS0z2P50lK
std::cout << "Hello, World!" << std::endl;
//第一个算法
char *input = "vm8MRDk58srS2jDoRAIswzJU0ALS0z2P50lK";
char encode_input[strlen(input)];
int v14 = 0xFF;
int v16 = 0;
int key[] = {0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x2D, 0x5F, 0x61, 0x62, 0x63, 0x64, 0x65,
0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C,
0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78,
0x79, 0x7A, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A,
0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56,
0x57, 0x58, 0x59, 0x5A};
for (int i = 0; i < strlen(input) - 2; ++i) {
char s = input[i] ^1;
bool v10 = i == 8 || i == 13;
bool v11 = i == 14;
bool v12 = i == 18;
bool v13 = i == 24;
if (v10 || i == 14 || i == 18 || i == 24) {
if (v10 || v12 || v13) {
s = '-';
encode_input[i] = s;
continue;
}
}
if (v11) {
s = 0x34;
encode_input[i] = s;
continue;
}
if (i == 23) {
s = input[i + 1] ^ 1;
}
if (i != 24) {
if (i != 23) {
v14 = v14 ^ input[i];
v16 = v16 + input[i];
} else {
v14 = v14 ^ input[i + 1];
v16 = v16 + input[i + 1];
}
}
encode_input[i] = s;
}
encode_input[34] = key[v16 - (v16 & 0xFFFFFFF0)];
encode_input[35] = key[v14 & 0xf];
std::cout << encode_input << std::endl;
//第二个算法
//最终的
char *c = (char *) malloc(100);
char *f_result = c;
int m_index = 0;
int m_index_ = 1;
int v10 = 0;
int v11 = 0;
int v12 = 0;
for (; m_index < strlen(encode_input); m_index++) {
result(&f_result, key[*(encode_input + m_index) >> 2]);
v10 = 0x10LL * (*(encode_input + m_index) & 3);
if (m_index_ >= strlen(encode_input)) {
result(&f_result, key[v10]);
result(&f_result, 0x3Du);
result(&f_result, 0x3Du);
} else {
result(&f_result, key[v10 | (*(encode_input + m_index_) >> 4)]);
v11 = m_index_ + 1;
v12 = 4LL * (*(encode_input + m_index_) & 0xF);
if (v11 >= strlen(encode_input)) {
result(&f_result, key[v12]);
result(&f_result, 0x3Du);
} else {
result(&f_result, key[v12 | (*(encode_input + v11) >> 6)]);
result(&f_result, key[*(encode_input + v11) & 0x3F]);
}
}
m_index = m_index_ + 2;
m_index_ += 3;
}
std::cout << c << std::endl;
return 0;
}
看雪ID:GitRoy
https://bbs.pediy.com/user-home-762912.htm
# 往期推荐
球分享
球点赞
球在看
点击“阅读原文”,了解更多!
[广告]赞助链接:
关注数据与安全,洞悉企业级服务市场:https://www.ijiandao.com/
让资讯触达的更精准有趣:https://www.0xu.cn/
关注KnowSafe微信公众号
随时掌握互联网精彩
随时掌握互联网精彩
- GeoTrust 等通用品牌证书提交流程
- LeaferJS:革新级图形引擎,前端开发的新利器!
- 原美团联合创始人欲打造中国版 OpenAI ;ChatGPT 爆红惊动谷歌退隐创始人布林;Gradle 8.0 发布|极客头条
- 价值近千万美元数字资产失窃,亚洲最大加密货币钱包BitKeep遭网络攻击
- 第三代骁龙8cx计算平台:高效强大,刷新PC体验
- 全新一代骁龙8移动平台:AI加持,超凡影像触手可得
- 美国学区网络保险费用上涨至去年三倍多
- 一见倾“芯”!骁龙技术峰会旗舰大赏
- 在看 | 一周网安回顾(2021.11.06-11.12)
- 跨界造芯片成潮流,微软被传自研SoC处理器
- 春季招聘,职等你来
- 把斯坦福大学土地租出去?特曼坦言:目的就是赚钱
赞助链接