hook java.io.InputStream, + Performance Tweak
This commit is contained in:
parent
6e2a8ac450
commit
86bf7f4af9
40
README.md
40
README.md
@ -19,6 +19,7 @@
|
|||||||
- [Webview URLS](#webview-urls)
|
- [Webview URLS](#webview-urls)
|
||||||
- [Await for specific module to load](#await-for-condition)
|
- [Await for specific module to load](#await-for-condition)
|
||||||
- [Android make Toast](#android-make-toast)
|
- [Android make Toast](#android-make-toast)
|
||||||
|
- [Hook java io InputStream](#hook-java-io-inputstream)
|
||||||
- [TODO list](#todos)
|
- [TODO list](#todos)
|
||||||
|
|
||||||
#### Intercept and backtrace low level open
|
#### Intercept and backtrace low level open
|
||||||
@ -421,6 +422,45 @@ Java.scheduleOnMainThread(function() {
|
|||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### Hook java io InputStream
|
||||||
|
```
|
||||||
|
function binaryToHexToAscii(array, readLimit) {
|
||||||
|
var result = [];
|
||||||
|
// read 100 bytes #performance
|
||||||
|
readLimit = readLimit || 100;
|
||||||
|
for (var i = 0; i < readLimit; ++i) {
|
||||||
|
result.push(String.fromCharCode( // hex2ascii part
|
||||||
|
parseInt(
|
||||||
|
('0' + (array[i] & 0xFF).toString(16)).slice(-2), // binary2hex part
|
||||||
|
16
|
||||||
|
)
|
||||||
|
));
|
||||||
|
}
|
||||||
|
return result.join('');
|
||||||
|
}
|
||||||
|
|
||||||
|
function hookInputStream() {
|
||||||
|
Java.use('java.io.InputStream')['read'].overload('[B').implementation = function(b) {
|
||||||
|
// execute original and save return value
|
||||||
|
var retval = this.read(b);
|
||||||
|
var resp = binaryToHexToAscii(b);
|
||||||
|
// conditions to not print garbage packets
|
||||||
|
var reExcludeList = new RegExp(['Mmm'/*, 'Ping' /*, ' Yo'*/].join('|'));
|
||||||
|
if ( ! reExcludeList.test(resp) ) {
|
||||||
|
console.log(resp);
|
||||||
|
}
|
||||||
|
var reIncludeList = new RegExp(['AAA', 'BBB', 'CCC].join('|'));
|
||||||
|
if ( reIncludeList.test(resp) ) {
|
||||||
|
send( binaryToHexToAscii(b, 1200) );
|
||||||
|
}
|
||||||
|
return retval;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// Main
|
||||||
|
Java.perform(hookInputStream);
|
||||||
|
```
|
||||||
|
|
||||||
#### TODOs
|
#### TODOs
|
||||||
- Add GIFs & docs
|
- Add GIFs & docs
|
||||||
- Add links to /scripts
|
- Add links to /scripts
|
||||||
|
Loading…
Reference in New Issue
Block a user