mirror of
https://github.com/sensepost/objection.git
synced 2026-10-12 02:22:18 +00:00
Added --watch and friends to notify (#581)
This commit is contained in:
@@ -64,15 +64,36 @@ const getPatternType = (pattern: string): PatternType => {
|
||||
return PatternType.Klass;
|
||||
};
|
||||
|
||||
export const lazyWatchForPattern = (query: string): void => {
|
||||
export const lazyWatchForPattern = (query: string, watch: boolean, dargs: boolean, dret: boolean, dbt: boolean): void => {
|
||||
// TODO: Use param to control interval
|
||||
let found = false;
|
||||
const job: IJob = {
|
||||
identifier: jobs.identifier(),
|
||||
implementations: [],
|
||||
type: `notify-class for: ${query}`,
|
||||
};
|
||||
|
||||
// This method loops over all enumerate matches and then calls watch
|
||||
// with the arguments specified in the parent function
|
||||
const watchMatches = (matches: Java.EnumerateMethodsMatchGroup[]) => {
|
||||
matches.forEach(match => {
|
||||
match.classes.forEach(_class => {
|
||||
_class.methods.forEach(_method => {
|
||||
watchMethod(_class.name + "." + _method, job, dargs, dbt, dret);
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// Check if the pattern is found before starting an interval
|
||||
javaEnumerate(query).then(matches => {
|
||||
if (matches.length > 0) {
|
||||
found = true;
|
||||
send(`${c.green(query)} is already loaded / available`);
|
||||
if (watch) {
|
||||
watchMatches(matches);
|
||||
jobs.add(job);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -87,6 +108,10 @@ export const lazyWatchForPattern = (query: string): void => {
|
||||
if (!found && matches.length > 0) {
|
||||
send(`${c.green(query)} is now available`);
|
||||
found = true;
|
||||
if (watch) {
|
||||
watchMatches(matches);
|
||||
jobs.add(job);
|
||||
}
|
||||
}
|
||||
|
||||
if (found) clearInterval(interval);
|
||||
|
||||
@@ -58,7 +58,7 @@ export const android = {
|
||||
androidHookingWatch: (pattern: string, watchArgs: boolean, watchBacktrace: boolean, watchRet: boolean): Promise<void> =>
|
||||
hooking.watch(pattern, watchArgs, watchBacktrace, watchRet),
|
||||
androidHookingEnumerate: (query: string): Promise<Java.EnumerateMethodsMatchGroup[]> => hooking.javaEnumerate(query),
|
||||
androidHookingLazyWatchForPattern: (query: string): void => hooking.lazyWatchForPattern(query),
|
||||
androidHookingLazyWatchForPattern: (query: string, watch: boolean, dargs: boolean, dret: boolean, dbt: boolean): void => hooking.lazyWatchForPattern(query, watch, dargs, dret, dbt),
|
||||
|
||||
// android heap methods
|
||||
androidHeapEvaluateHandleMethod: (handle: number, js: string): Promise<void> => heap.evaluate(handle, js),
|
||||
|
||||
@@ -51,6 +51,17 @@ def _should_dump_backtrace(args: list = None) -> bool:
|
||||
return '--dump-backtrace' in args
|
||||
|
||||
|
||||
def _should_watch(args: list = None) -> bool:
|
||||
"""
|
||||
Check if --dump-args is part of the arguments.
|
||||
|
||||
:param args:
|
||||
:return:
|
||||
"""
|
||||
|
||||
return '--watch' in args
|
||||
|
||||
|
||||
def _should_dump_args(args: list = None) -> bool:
|
||||
"""
|
||||
Check if --dump-args is part of the arguments.
|
||||
@@ -207,7 +218,14 @@ def notify(args: list = None) -> None:
|
||||
return
|
||||
|
||||
api = state_connection.get_api()
|
||||
api.android_hooking_lazy_watch_for_pattern(query)
|
||||
should_watch = _should_watch(args)
|
||||
dump_arguments = _should_dump_args(args)
|
||||
dump_backtrace = _should_dump_backtrace(args)
|
||||
dump_return = _should_dump_return_value(args)
|
||||
api.android_hooking_lazy_watch_for_pattern(query,
|
||||
should_watch, dump_arguments,
|
||||
dump_return,
|
||||
dump_backtrace)
|
||||
|
||||
|
||||
def watch(args: list = None) -> None:
|
||||
|
||||
@@ -352,7 +352,9 @@ COMMANDS = {
|
||||
},
|
||||
'notify': {
|
||||
'meta': 'Notify when a class becomes available',
|
||||
'exec': android_hooking.notify
|
||||
'exec': android_hooking.notify,
|
||||
'flags': ['--dump-args', '--dump-return', '--dump-backtrace', '--watch']
|
||||
|
||||
},
|
||||
'generate': {
|
||||
'meta': 'Generate Frida hooks for Android',
|
||||
|
||||
Reference in New Issue
Block a user