diff --git a/codelib.apk b/codelib.apk index 117eb3b..50cf1f0 100644 Binary files a/codelib.apk and b/codelib.apk differ diff --git a/src/codelib.cc b/src/codelib.cc index 9034355..52a6538 100644 --- a/src/codelib.cc +++ b/src/codelib.cc @@ -24,6 +24,8 @@ // METHODS ////////////////////////////////// const string StethoCodeLib::_M_SAARLAND_CISPA_ARTIST_CODELIB_CODELIB__INITSTETHO__L__V = "Lsaarland/cispa/artist/codelib/CodeLib;initStetho(Ljava/lang/Object;)V"; +const string StethoCodeLib::_M_SAARLAND_CISPA_ARTIST_CODELIB_CODELIB__OKHTTP3INTERCEPTOR__L__V("Lsaarland/cispa/artist/codelib/CodeLib;okhttp3interceptor(Ljava/lang/Object;)V"); +const string StethoCodeLib::_M_SAARLAND_CISPA_ARTIST_CODELIB_CODELIB__OKHTTP2INTERCEPTOR__L__V("Lsaarland/cispa/artist/codelib/CodeLib;okhttp2interceptor(Ljava/lang/Object;)V"); // FIELDS /////////////////////////////////// const string StethoCodeLib::_F_CODECLASS_INSTANCE = @@ -40,6 +42,8 @@ const string StethoCodeLib::_C_JAVA_LANG_STRING = unordered_set &StethoCodeLib::getMethods() const { static unordered_set methods({ StethoCodeLib::_M_SAARLAND_CISPA_ARTIST_CODELIB_CODELIB__INITSTETHO__L__V, + StethoCodeLib::_M_SAARLAND_CISPA_ARTIST_CODELIB_CODELIB__OKHTTP3INTERCEPTOR__L__V, + StethoCodeLib::_M_SAARLAND_CISPA_ARTIST_CODELIB_CODELIB__OKHTTP2INTERCEPTOR__L__V, }); return methods; } diff --git a/src/codelib.h b/src/codelib.h index d54d7bd..3f77f07 100644 --- a/src/codelib.h +++ b/src/codelib.h @@ -34,6 +34,8 @@ class StethoCodeLib : public CodeLib { public: // METHODS ////////////////////////////////// static const string _M_SAARLAND_CISPA_ARTIST_CODELIB_CODELIB__INITSTETHO__L__V; + static const string _M_SAARLAND_CISPA_ARTIST_CODELIB_CODELIB__OKHTTP3INTERCEPTOR__L__V; + static const string _M_SAARLAND_CISPA_ARTIST_CODELIB_CODELIB__OKHTTP2INTERCEPTOR__L__V; // FIELDS /////////////////////////////////// static const string _F_CODECLASS_INSTANCE; // CLASSES ////////////////////////////////// diff --git a/src/module.cc b/src/module.cc index 570184a..c684aef 100644 --- a/src/module.cc +++ b/src/module.cc @@ -49,7 +49,7 @@ shared_ptr TemplateModule::createCodeLib() const { unique_ptr TemplateModule::getMethodFilter() const { // we are only interested in context objects, so we use this cheap heuristic for now - const vector ui = {"onCreate("}; + const vector ui = {"onCreate(", "void okhttp3.OkHttpClient.(okhttp3.OkHttpClient$Builder)", "com.squareup.okhttp.OkHttpClient.networkInterceptors"}; return unique_ptr(new MethodNameWhitelist(ui, false, true)); } diff --git a/src/stetho_pass.cc b/src/stetho_pass.cc index c4b0942..94cbbce 100644 --- a/src/stetho_pass.cc +++ b/src/stetho_pass.cc @@ -42,32 +42,41 @@ using art::ArtUtils; using art::Primitive; void HStethoArtist::RunPass() { - const auto eblock = graph_->GetEntryBlock(); - if (eblock != nullptr) { - const auto block = eblock->GetSingleSuccessor(); - if (block != nullptr) { - if (!_method_info.GetParams().empty()) { - HParameterValue *this_instruction = _method_info.GetParams()[0]; - if (_method_info.IsThisParameter(this_instruction)) { - auto cursor = block->GetFirstInstruction(); - auto invoked_signature = StethoCodeLib::_M_SAARLAND_CISPA_ARTIST_CODELIB_CODELIB__INITSTETHO__L__V; - auto codelib_instruction = GetCodeLibInstruction(); - vector params; - params.push_back(codelib_instruction); - params.push_back(this_instruction); - ArtUtils::InjectMethodCall(cursor, invoked_signature, params, this->getCodeLibEnvironment(), - Primitive::Type::kPrimVoid, true); + const auto eblock = graph_->GetEntryBlock(); + if (eblock != nullptr) { + const auto block = eblock->GetSingleSuccessor(); + if (block != nullptr) { + if (!_method_info.GetParams().empty()) { + HParameterValue *this_instruction = _method_info.GetParams()[0]; + if (_method_info.IsThisParameter(this_instruction)) { + auto cursor = block->GetFirstInstruction(); + string invoked_signature; + auto codelib_instruction = GetCodeLibInstruction(); + vector params; + params.push_back(codelib_instruction); + if (_method_info.GetMethodName(true).find("networkInterceptors(") != string::npos) { + invoked_signature = StethoCodeLib::_M_SAARLAND_CISPA_ARTIST_CODELIB_CODELIB__OKHTTP2INTERCEPTOR__L__V; + params.push_back(this_instruction); + } else if (_method_info.GetMethodName(true).find("onCreate(") == string::npos) { + invoked_signature = StethoCodeLib::_M_SAARLAND_CISPA_ARTIST_CODELIB_CODELIB__OKHTTP3INTERCEPTOR__L__V; + params.push_back(_method_info.GetParams()[1]); + } else { + invoked_signature = StethoCodeLib::_M_SAARLAND_CISPA_ARTIST_CODELIB_CODELIB__INITSTETHO__L__V; + params.push_back(this_instruction); + } + ArtUtils::InjectMethodCall(cursor, invoked_signature, params, this->getCodeLibEnvironment(), + Primitive::Type::kPrimVoid, true); + } else { + // 1st parameter is not this + } } else { - // 1st parameter is not this + // no params } } else { - // no params + // no second block } } else { - // no second block + // no entry block } - } else { - // no entry block - } }