Skip to content

Instantly share code, notes, and snippets.

@MrPowerGamerBR
Created March 21, 2018 23:41
Show Gist options
  • Save MrPowerGamerBR/69bd49ed92a517c78ff90493bf3abecc to your computer and use it in GitHub Desktop.
Save MrPowerGamerBR/69bd49ed92a517c78ff90493bf3abecc to your computer and use it in GitHub Desktop.
console.log("Script loaded successfully ");
console.log(Java.available)
Java.perform(function() {
console.log("Let's go!");
var PhotoManager = Java.use("com.narvii.photos.PhotoManager");
var ApiService = Java.use("com.narvii.util.http.ApiService");
var WsService = Java.use("com.narvii.util.ws.WsService");
var WebSocketListener = Java.use("okhttp3.WebSocketListener")
var RealWebSocket = Java.use("okhttp3.internal.ws.RealWebSocket")
// console.log(ApiService.userAgent("wow"))
PhotoManager.importPhoto.implementation = function(dir, uri) {
send("importPhoto() got called! Let's call the original implementation");
send(dir)
send(uri)
return this.importPhoto(dir, uri);
};
ApiService.userAgent.implementation = function(ctx) {
send("userAgent() got called! Let's call the original implementation");
send(ctx)
return this.userAgent(ctx);
};
WsService.getWsUrl.implementation = function() {
send("getWsUrl() got called! Let's call the original implementation");
var url = this.getWsUrl();
send(url)
return url;
}
WsService.updateWs.implementation = function(forceConnect) {
send("updateWs() got called! Let's call the original implementation");
return this.updateWs(forceConnect);
}
RealWebSocket.onReadMessage.overload("java.lang.String").implementation = function(text) {
// send("onMessage() got called! Let's call the original implementation");
console.log("received: " + text)
return this.onReadMessage(text);
}
RealWebSocket.onReadMessage.overload("okio.ByteString").implementation = function(text) {
// send("onMessage() got called! Let's call the original implementation");
console.log("received: " + text)
return this.onReadMessage(text);
}
WebSocketListener.onMessage.overload("okhttp3.WebSocket", "okio.ByteString").implementation = function(webSocket, bytes) {
send("onMessage() got called! Let's call the original implementation");
send("received: " + bytes)
return this.onMessage(webSocket, bytes);
}
WebSocketListener.onOpen.implementation = function(webSocket, response) {
send("onOpen() got called! Let's call the original implementation");
return this.onOpen(webSocket, response);
}
WebSocketListener.onOpen.implementation = function(webSocket, response) {
console.log("onOpen() got called! Let's call the original implementation");
return this.onOpen(webSocket, response);
}
RealWebSocket.send.overload("java.lang.String").implementation = function(text) {
console.log("sending: " + text)
return this.send(text);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment