function read_std_string(str) {
const isTiny = (str.readU8() & 1) === 0;
if (isTiny) { return str.add(1).readUtf8String(); }
return str.add(2 * Process.pointerSize).readPointer().readUtf8String();
}
function ptr_distance(beg, end) {
return end.sub(beg).toInt32();
}
function read_between(beg, end) {
let data_length = ptr_distance(beg, end);
return beg.readByteArray(data_length);
}
var hextabs = [
'0', '1', '2', '3',
'4', '5', '6', '7',
'8', '9', 'a', 'b',
'c', 'd', 'e', 'f'
];
var asciitabs = [
' ', '!', '"', '#',
'$', '%', '&', "\\'",
'(', ')', '*', '+',
',', '-', '.', '/',
'0', '1', '2', '3',
'4', '5', '6', '7',
'8', '9', ':', ';',
'<', '=', '>', '?',
'@', 'A', 'B', 'C',
'D', 'E', 'F', 'G',
'H', 'I', 'J', 'K',
'L', 'M', 'N', 'O',
'P', 'Q', 'R', 'S',
'T', 'U', 'V', 'W',
'X', 'Y', 'Z', '[',
'\\\\', ']', '^', '_',
'`', 'a', 'b', 'c',
'd', 'e', 'f', 'g',
'h', 'i', 'j', 'k',
'l', 'm', 'n', 'o',
'p', 'q', 'r', 's',
't', 'u', 'v', 'w',
'x', 'y', 'z', '{',
'|', '}', '~'
];
function hexify_byte(b) {
return hextabs[b >>> 4] + hextabs[b & 0xF];
}
function dump_buffer_as_pybstr(buf) {
let ptr = buf.unwrap();
let repr_str = '';
for (let i = 0; i < buf.byteLength; ++i) {
let b = ptr.add(i).readU8();
let brepr = (b >= 32 && b < 127)
? asciitabs[b - 32]
: ('\\x' + hexify_byte(b));
repr_str += brepr;
}
return 'b\'' + repr_str + '\'';
}
setImmediate(function () {
let sha_symbol = "_ZN8picosha218hash256_hex_stringINSt6__ndk111__wrap_iterIPKhEEEEvT_S6_RNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE";
let sha_funcptr = Module.findExportByName("libAMapSDK_Location_v6_6_0.so", sha_symbol);
if (sha_funcptr === null) {
console.log("PicoSHA2 function not found ...");
}
else {
Interceptor.attach(sha_funcptr, {
onEnter: function (args) {
this.args = [args[0], args[1], args[2]];
},
onLeave: function (retval) {
let args = this.args;
let [input_it_beg, input_it_end, out_string_ptr] = args;
let data = read_between(input_it_beg, input_it_end);
let data_repr = (data === null) ? "<NULL>" : dump_buffer_as_pybstr(data);
let result_cstr = read_std_string(out_string_ptr) || "<NULL>";
console.log(`thread#${this.threadId} SHA256 called! data: ${data_repr}, result: ${result_cstr}`);
},
});
}
});
[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课