Skip to content

Add support for hooking all methods of a class #22

@cpholguera

Description

@cpholguera

Feature Description

Add the ability to hook all methods of a class by specifying only the class field in the hook configuration, without needing to enumerate individual methods.

Motivation

When analyzing apps, it's often useful to monitor all activity on a specific class without knowing all its methods in advance. Previously, users had to either:

  • Manually list all methods using the methods array
  • Hook specific methods individually

This was tedious and error-prone, especially for classes with many methods.

Implementation

The feature has been implemented in frooky/android/base_script.js by enhancing the buildHookOperations function to:

  1. Detect when only class is specified (no method or methods)
  2. Use Java reflection to enumerate all declared methods of the class
  3. Automatically hook all overloads of each method found
  4. Skip methods that cannot be hooked (e.g., synthetic methods, constructors)

Usage

Simply specify the class without any method fields:

{
  "category": "STORAGE",
  "hooks": [
    {
      "class": "android.app.SharedPreferencesImpl$EditorImpl"
    }
  ]
}

This will hook all methods such as:

  • putString
  • putInt
  • putBoolean
  • apply
  • commit
  • And all other methods in the class

Example Output

When running with a class-only hook, the summary shows all methods that were hooked:

{
  "type": "summary",
  "hooks": [...13 methods hooked...],
  "totalHooks": 13,
  "errors": [],
  "totalErrors": 0
}

Documentation

Documentation has been updated in docs/usage.md to explain this feature.

Benefits

  • Comprehensive coverage: Capture all method calls on a class
  • Less maintenance: No need to update hook files when methods are added
  • Discovery: Helps identify which methods are actually being called
  • Convenience: Simpler hook configurations for exploratory analysis

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions