Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified codelib.apk
Binary file not shown.
4 changes: 4 additions & 0 deletions src/codelib.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand All @@ -40,6 +42,8 @@ const string StethoCodeLib::_C_JAVA_LANG_STRING =
unordered_set<string> &StethoCodeLib::getMethods() const {
static unordered_set<string> 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;
}
Expand Down
2 changes: 2 additions & 0 deletions src/codelib.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 //////////////////////////////////
Expand Down
2 changes: 1 addition & 1 deletion src/module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ shared_ptr<const CodeLib> TemplateModule::createCodeLib() const {

unique_ptr<Filter> TemplateModule::getMethodFilter() const {
// we are only interested in context objects, so we use this cheap heuristic for now
const vector<const string> ui = {"onCreate("};
const vector<const string> ui = {"onCreate(", "void okhttp3.OkHttpClient.<init>(okhttp3.OkHttpClient$Builder)", "com.squareup.okhttp.OkHttpClient.networkInterceptors"};
return unique_ptr<Filter>(new MethodNameWhitelist(ui, false, true));
}

Expand Down
51 changes: 30 additions & 21 deletions src/stetho_pass.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<art::HInstruction *> 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<art::HInstruction *> 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
}

}