Skip to main content
Glama
renef-mcp
by Ahmeth4n

renef_hook_java

Installs Java/ART method hooks on Android to intercept calls, skip original methods, and override return values for runtime analysis or SSL pinning checks.

Instructions

Install a Java/ART method hook (Android 12+ safe JNI twin engine; fallback on older Android).

Java hook argument layout in Lua callbacks:

  • Instance methods: args[0] = ArtMethod* (internal), args[1] = this, args[2] = arg1, ...

  • Static methods: args[0] = ArtMethod*, args[1] = arg1, ...

  • skip_original=True sets args.skip = true in onEnter (CRITICAL for bypassing void methods like SSL pinning checks without triggering exceptions).

  • return_value overrides the return value in onLeave: e.g. "false", "true", "0", "42", or 'JNI.string("HOOKED")'.

  • When signature is omitted, discovers all declared overloads of method_name via Java reflection and installs the hook on each overload.

  • Java hooks appear in renef_hooks_list() as [j0], [j1], ... and can be removed with renef_unhook("j0") or renef_unhook("all").

Args: class_name: Class name (dots or slashes accepted, normalized to "com/example/Main") method_name: Java method name (e.g., "isRooted", "checkServerTrusted") signature: Optional JNI signature (e.g., "()Z", "(Ljava/lang/String;)Ljava/lang/String;"). Leave empty to discover and hook all declared overloads via reflection. on_enter: Optional Lua body for onEnter (args in scope) on_leave: Optional Lua body for onLeave (retval in scope) skip_original: If True, sets args.skip = true in onEnter to skip calling the original method return_value: Optional Lua expression returned from onLeave (e.g., "false", 'JNI.string("ok")')

Returns: JSON status confirming installation

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "class_name": "<class_name>",
      "method_name": "<method_name>"
    },
    "name": "renef_hook_java"
  }
}

Input Schema

NameRequiredDescriptionDefault
on_enterNo
on_leaveNo
signatureNo
class_nameYes
method_nameYes
return_valueNo
skip_originalNo

Output Schema

NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.4.0

TDQS

A4/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations present, the description carries the full burden and delivers real behavioral detail: the Android 12+ JNI twin-engine mechanism with fallback, reflection-based overload discovery when signature is omitted, hook registry naming as [j0], [j1], and removal semantics via renef_unhook('j0') or 'all'. It stops short of stating prerequisites (e.g., needing an attached target process) or failure behavior, which keeps it from a 5.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The purpose is front-loaded in the first line, then organized into callback layout, semantics, resolution behavior, lifecycle, and a formal Args list. Some redundancy exists between the prose bullets and the Args section (skip_original and return_value are described twice), but the content is dense and task-relevant rather than padded.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a 7-parameter mutation-style tool with an output schema, the definition covers installation semantics, callback contract, overload resolution, and cleanup paths, which is substantially complete. It omits preconditions such as requiring an attached process and any indication of what happens on a missing class or unresolvable method, which an agent would still need.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0% for 7 parameters, and the description compensates fully: it documents class_name normalization (dots or slashes to com/example/Main), method_name with concrete examples, the JNI signature format with sample strings, the Lua scope of on_enter/on_leave (args vs retval), the precise effect of skip_original, and accepted return_value literal forms including JNI.string(...). It also explains the callback argument layout (args[0] = ArtMethod*, args[1] = this for instance methods), which is meaning no schema field conveys.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb and resource: install a hook on a Java/ART method, with an explicit implementation note (JNI twin engine, Android 12+ safe, fallback on older Android). The word 'Java/ART' implicitly separates it from a native hook, but no sibling such as renef_hook_native or renef_interceptor is named to make the boundary unambiguous.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Use context is implied through examples ('CRITICAL for bypassing void methods like SSL pinning checks') and through the lifecycle note that hooks appear in renef_hooks_list and can be removed with renef_unhook. However, there is no explicit when-to-use/when-not guidance relative to the native or interceptor hook tools, so the agent must infer selection from the tool name alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.