-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split up DownloadLogger component into more generic CallLogger and St…
…reamLogger components
- Loading branch information
Showing
12 changed files
with
442 additions
and
266 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
sdk=/path/to/android/sdk | ||
input=game.apk | ||
output=game-instrumented.apk | ||
keystore=debug.jks | ||
keypass=123456 | ||
|
||
CallLogger.enabled = true | ||
CallLogger.java.net.URL\:openConnection = URLConnection {result:%x}: opened for URL {this:%s} (method {method:%s}) | ||
CallLogger.java.net.URLConnection\:addRequestProperty(java.lang.String,java.lang.String) = URLConnection {this:%x}: added request header {arg0:%s}: {arg1:%s} (method {method:%s}) | ||
CallLogger.java.net.URLConnection\:connect() = URLConnection {this:%x}: connected (method {method:%s}) | ||
CallLogger.java.net.URLConnection\:getContentLength() = URLConnection {this:%x}: response content length is {result:%i} (method {method:%s}) | ||
CallLogger.java.net.URLConnection\:getContentType() = URLConnection {this:%x}: response content type is {result:%s} (method {method:%s}) | ||
CallLogger.java.net.URLConnection\:getHeaderField(java.lang.String) = URLConnection {this:%x}: header {arg0:%s} value is {result:%s} (method {method:%s}) | ||
CallLogger.java.net.URLConnection\:setRequestProperty(java.lang.String,java.lang.String) = URLConnection {this:%x}: set request header {arg0:%s}: {arg1:%s} (method {method:%s}) | ||
CallLogger.java.net.HttpURLConnection\:getResponseCode() = URLConnection {this:%x}: response code is {result:%i} (method {method:%s}) | ||
CallLogger.java.net.HttpURLConnection\:setRequestMethod(java.lang.String) = URLConnection {this:%x}: request method set to {arg0:%s} (method {method:%s}) | ||
|
||
StreamLogger.enabled = true | ||
StreamLogger.java.net.URL\:openStream = URL {this:%s} response (requested by method {method:%s}) | ||
StreamLogger.java.net.URLConnection\:getInputStream = URLConnection {this:%x}: response (requested by method {method:%s}) | ||
StreamLogger.java.net.URLConnection\:getOutputStream = URLConnection {this:%x}: request body (requested by method {method:%s}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* This Source Code is subject to the terms of the Mozilla Public License | ||
* version 2.0 (the "License"). You can obtain a copy of the License at | ||
* http://mozilla.org/MPL/2.0/. | ||
*/ | ||
|
||
package info.palant.apkInstrumentation; | ||
|
||
import java.util.Map; | ||
import java.util.Properties; | ||
|
||
import soot.Body; | ||
import soot.SootMethod; | ||
import soot.Unit; | ||
import soot.BodyTransformer; | ||
|
||
public class CallLogger extends BodyTransformer | ||
{ | ||
private final Filter filter; | ||
private String tag; | ||
private MethodConfig methodConfig; | ||
|
||
public CallLogger(Properties config) | ||
{ | ||
String filterSpec = config.getProperty("CallLogger.filter"); | ||
if (filterSpec != null) | ||
this.filter = new Filter(filterSpec); | ||
else | ||
this.filter = null; | ||
|
||
this.tag = config.getProperty("CallLogger.tag"); | ||
if (tag == null) | ||
this.tag = "CallLogger"; | ||
|
||
this.methodConfig = new MethodConfig(config, "CallLogger."); | ||
} | ||
|
||
@Override | ||
protected void internalTransform(Body body, String phaseName, Map<String, String> options) | ||
{ | ||
if (this.filter != null && !this.filter.matches(body)) | ||
return; | ||
|
||
for (Unit unit: body.getUnits().toArray(new Unit[0])) | ||
{ | ||
SootMethod method = UnitParser.getInvocationMethod(unit); | ||
if (method == null) | ||
continue; | ||
|
||
String formatString = this.methodConfig.get(method); | ||
if (formatString == null) | ||
continue; | ||
|
||
UnitSequence units = new UnitSequence(body); | ||
units.log(this.tag, units.extendedFormat( | ||
formatString, | ||
UnitParser.getAssignmentTarget(unit), | ||
UnitParser.getInvocationBase(unit), | ||
UnitParser.getInvocationArgs(unit) | ||
)); | ||
units.insertAfter(unit); | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.