diff --git a/README.md b/README.md index 21fcf21..6733417 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,7 @@ - [Webview URLS](#webview-urls) - [Await for specific module to load](#await-for-condition) - [Android make Toast](#android-make-toast) + - [Hook java io InputStream](#hook-java-io-inputstream) - [TODO list](#todos) #### 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 - Add GIFs & docs - Add links to /scripts