-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[HOTFIX] RPC hook suggestions + Bug Fix (#2301)
* String compare script improvements * Fix iOS Frida script bugs * Added RPC helpers for hook suggestion (TODO:Expose to UI) * Code QA
- Loading branch information
1 parent
b668ee8
commit d3b0214
Showing
24 changed files
with
446 additions
and
362 deletions.
There are no files selected for viewing
40 changes: 31 additions & 9 deletions
40
mobsf/DynamicAnalyzer/tools/frida_scripts/android/auxiliary/string_compare.js
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 |
---|---|---|
@@ -1,15 +1,37 @@ | ||
//https://github.com/iddoeldor/frida-snippets#reveal-native-methods | ||
//String comparison | ||
Java.perform(function () { | ||
send('[AUXILIARY] [String Compare] capturing all string comparisons') | ||
var str = Java.use('java.lang.String'), objectClass = 'java.lang.Object'; | ||
str.equals.overload(objectClass).implementation = function (obj) { | ||
var response = str.equals.overload(objectClass).call(this, obj); | ||
if (obj) { | ||
if (obj.toString().length > 5) { | ||
send('[AUXILIARY] [String Compare] ' + str.toString.call(this) + ' == ' + obj.toString() + ' ? ' + response); | ||
} | ||
let Exception = Java.use('java.lang.Exception'); | ||
let javaString = Java.use('java.lang.String') | ||
let objectClass = 'java.lang.Object'; | ||
var skiplist = ['android.app.SystemServiceRegistry.getSystemService'] | ||
javaString.equals.overload(objectClass).implementation = function (obj) { | ||
var response = javaString.equals.overload(objectClass).call(this, obj); | ||
if (obj && obj.toString().length > 5) { | ||
var stack = []; | ||
var calledFrom = Exception.$new().getStackTrace().toString().split(','); | ||
// Otherwise capture string comparisons | ||
let i = 0; | ||
do { | ||
i = i + 1; | ||
stack.push(calledFrom[i]); | ||
} while (i <= 5); | ||
var skipClass, skipMethod = false; | ||
skiplist.forEach(function (toSkip) { | ||
if (calledFrom[4].includes(toSkip)) | ||
skipClass = true; | ||
}); | ||
if (!skipClass) { | ||
var data = { | ||
caller: stack, | ||
string1: javaString.toString.call(this), | ||
string2: obj.toString(), | ||
return: response, | ||
} | ||
send('[AUXILIARY] [String Compare] ' + JSON.stringify(data, null, 2)); | ||
} | ||
} | ||
return response; | ||
} | ||
}); | ||
}); | ||
|
60 changes: 31 additions & 29 deletions
60
mobsf/DynamicAnalyzer/tools/frida_scripts/android/default/dump_clipboard.js
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 |
---|---|---|
@@ -1,40 +1,42 @@ | ||
// Based on https://github.com/sensepost/objection/blob/f8e78d8a29574c6dadd2b953a63207b45a19b1cf/objection/hooks/android/clipboard/monitor.js | ||
var ActivityThread = Java.use('android.app.ActivityThread'); | ||
var ClipboardManager = Java.use('android.content.ClipboardManager'); | ||
var CLIPBOARD_SERVICE = 'clipboard'; | ||
|
||
var currentApplication = ActivityThread.currentApplication(); | ||
var context = currentApplication.getApplicationContext(); | ||
|
||
var clipboard_handle = context.getApplicationContext().getSystemService(CLIPBOARD_SERVICE); | ||
var clipboard = Java.cast(clipboard_handle, ClipboardManager); | ||
|
||
// Variable used for the current string data | ||
var string_data; | ||
|
||
function check_clipboard_data() { | ||
|
||
Java.perform(function () { | ||
|
||
var primary_clip = clipboard.getPrimaryClip(); | ||
|
||
// If we have managed to get the primary clipboard and there are | ||
// items stored in it, process an update. | ||
if (primary_clip != null && primary_clip.getItemCount() > 0) { | ||
|
||
var data = primary_clip.getItemAt(0).coerceToText(context).toString(); | ||
|
||
// If the data is the same, just stop. | ||
if (string_data == data) { | ||
return; | ||
var ActivityThread = Java.use('android.app.ActivityThread'); | ||
var ClipboardManager = Java.use('android.content.ClipboardManager'); | ||
var CLIPBOARD_SERVICE = 'clipboard'; | ||
|
||
var currentApplication = ActivityThread.currentApplication(); | ||
var context = currentApplication.getApplicationContext(); | ||
|
||
var clipboard_handle = context.getApplicationContext().getSystemService(CLIPBOARD_SERVICE); | ||
var clipboard = Java.cast(clipboard_handle, ClipboardManager); | ||
|
||
setInterval(function(){ | ||
|
||
var primary_clip = clipboard.getPrimaryClip(); | ||
|
||
// If we have managed to get the primary clipboard and there are | ||
// items stored in it, process an update. | ||
if (primary_clip != null && primary_clip.getItemCount() > 0) { | ||
|
||
var data = primary_clip.getItemAt(0).coerceToText(context).toString(); | ||
|
||
// If the data is the same, just stop. | ||
if (string_data == data) { | ||
return; | ||
} | ||
|
||
// Update the data with the new string and report back. | ||
string_data = data; | ||
send('mobsf-android-clipboard:' + data); | ||
} | ||
|
||
// Update the data with the new string and report back. | ||
string_data = data; | ||
send('mobsf-android-clipboard:' + data); | ||
} | ||
// Poll every 5 seconds | ||
}, 1000 * 5); | ||
}); | ||
} | ||
|
||
// Poll every 5 seconds | ||
setInterval(check_clipboard_data, 1000 * 5); | ||
check_clipboard_data(); |
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
Oops, something went wrong.