sensepost / objection

📱 objection - runtime mobile exploration
GNU General Public License v3.0
7.33k stars 840 forks source link

Feat android enumerate #502

Closed CDuPlooy closed 2 years ago

CDuPlooy commented 2 years ago

Hi I'm opening this a bit earlier to get some feedback. The idea behind this is to expose Java.enumerateMethods() to the Objection agent. This can be used in the REPL via android hooking enumerate $pattern. It supports two flags --json and --quiet

I'm not sure if I need to do some more work to add this to the API or not?

Any feedback is welcome :) Thanks @egeldenhuys for pointing out my typos.

leonjza commented 2 years ago

Nice I think this is going to be super useful. Had thoughts on maybe adding it for iOS as well?

I don't think we'd need to make any changes for the API. Think the caller can decide what they want to do with the data.

CDuPlooy commented 2 years ago

Thanks for the feedback! I had a quick look at how frida-trace does this, it uses an ApiResolver. The cool thing about that is we can then use patterns that match what frida-trace does for both Java and ObjectiveC. I'll add this soon :)

I was also thinking of adding another option to hooking watch, ie pattern. Ideal usage would look something like android hooking watch pattern '*Security*!*toString*'. We can then pass the matching methods to the RPC calls responsible for watching methods including any additional flags like --dump-args etc. I would personally find this very useful, but maybe it'd be more appropriate as a plugin?

leonjza commented 2 years ago

Yeah sounds great!

CDuPlooy commented 2 years ago

I was also thinking of adding another option to hooking watch, ie pattern. Ideal usage would look something like android hooking watch pattern 'Security!toString'. We can then pass the matching methods to the RPC calls responsible for watching methods including any additional flags like --dump-args etc. I would personally find this very useful, but maybe it'd be more appropriate as a plugin?

Managed to add the iOS portion. I think all that's left is to add the above and make sure everything is okay and up to your standards :)

CDuPlooy commented 2 years ago

Hi! I've added the above, you can see it in action here:

asciicast

asciicast

CDuPlooy commented 2 years ago

Hi sorry things have been hectic and my internet is painfully slow. I fixed some bugs and added some new things (also some things to be cleaned up). Once this is merged it should close #477 and #220. Kindly note that as far as I can tell the overload list is also not required when using patterns, as it's possible to use the full method signature in the pattern :) Super excited to work on this some more!

CDuPlooy commented 2 years ago

Closing so I can split this into multiple PRs since it's a bit confusing.