【发布时间】:2022-12-25 22:02:43
【问题描述】:
我有这样的代码:
class CURLNetRequest : public CNetRequestBase
{
DEFINE_LOGCLASS;
struct ProxySettings
{
void initFromConfig();
String host;
int port;
String username;
String password;
};
struct AuthSettings
{
AuthSettings( AuthMethod m, const String& u, const String& p )
: method(m)
, user(u)
, password(p)
{}
const AuthMethod method;
const String user;
const String password;
};
...
我想使用 frida 连接 structure 成员,即 user 和 password。到目前为止,我确实喜欢以下内容:
const some_func_pointer = Module.getExportByName('librhodes.so', '_ZN3rho3net14CURLNetRequest10CURLHolder11set_optionsEPKcRKNSt6__ndk
112basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEESD_PNS0_11IRhoSessionEPNS_9HashtableISB_SB_EERKNS1_13ProxySettingsERKNS1_12AuthSettingsE');
const some_func = new NativeFunction(some_func_pointer, "void", ["int", "pointer"]);
Interceptor.replace(some_func_pointer, new NativeCallback(function (size, data) {
console.log(size)
console.log(data.readUtf8String())
some_func(size, data);
}, "void", ["int", "pointer"]));
在这种情况下,我只能得到 AuthMethod m,它可以是 POST 或 GET。我怎样才能吸引其他人,比如username和password。
仅供参考,这是rhomobile构建的应用程序,上面的sn-p取自open source code,所以显然反编译librhodes.so会产生一些剥离的功能等。
请帮我解决一下这个。
【问题讨论】:
-
由于代码是 C++,我假设
String类型实际上是 C++ 类型std::string。如果是这样,那么您将无法使用readUtf8String()读取字符串内容。相反,您需要通过调用std::string::c_str将字符串转换为 C 字符串。 -
console.log(data.std::string::c_str)这是正确的语法吗? -
不,你不能直接从 frida 中调用 c++ 函数。您首先必须获取函数的
NativePointer,然后才能调用它。 -
那么我怎样才能得到函数的
NativePointer。我是这里的菜鸟。 -
@Robert 好吧,我试过这样的事情:
console.log(Module.getExportByName('librhodes.so', '_ZN3rho3net14CURLNetRequest10CURLHolder11set_ optionsEPKcRKNSt6__ndk112basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEESD_PNS0_11IRhoSessionEPNS_9HashtableISB _SB_EERKNS1_13ProxySettingsERKNS1_12AuthSettingsE'))返回function address,例如0xc4d755d4,我使用NativePointer作为var memAddr = new NativePointer('0xc4d755d4');,然后从memAddr.readU32();读取它。此输出随机数的整数。