最近,我开始使用Frida,并使用一些本地的方法。但是我对basic_string
的阅读价值有问题
下面是我所勾引的方法:
下面是用于钩子方法的JavaScript代码:
Interceptor.attach(Module.getExportByName('libsigning.so', '_ZN8Security4signEP7_JNIEnvP6rsa_stRKNSt6__ndk112basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEE'), {
onEnter: function (args) {
console.log("RSA.sign()")
console.log(Memory.readCString(args[2]))
},
onLeave: function (retval) {
// simply replace the value to be returned with 0
return retval
}
});
我得到了输出!字而非实值
怎样才是正确的方法呢?
发布于 2021-07-04 16:40:04
使用此frida代码解决了问题:
function readStdString (str) {
const isTiny = (str.readU8() & 1) === 0;
if (isTiny) {
return str.add(1).readUtf8String();
}
return str.add(2 * Process.pointerSize).readPointer().readUtf8String();
}
来源:https://codeshare.frida.re/@oleavr/read-std-string/
最后工作守则:
Interceptor.attach(Module.getExportByName('libsigning.so', '_ZN8Security4signEP7_JNIEnvP6rsa_stRKNSt6__ndk112basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEE'), {
onEnter: function (args) {
console.log("RSA.sign()")
console.log(readStdString(args[2]))
},
onLeave: function (retval) {
// simply replace the value to be returned with 0
return retval
}
});
https://stackoverflow.com/questions/68243063
复制相似问题