Hook

Hook

new Hook(name, src)

Source:

Represente un hook (actif ou non)

Parameters:
Name Type Description
name string

The hook name

src string

The hook script source code

Methods

getID() → {string}

Source:

To get the Unique ID of the hook

Returns:

id The Unique ID of this hook

Type
string

getParentID() → {String}

Source:

To get the parent ID if available, like an HookSet ID.

Returns:

The parent ID

Type
String

isAfter() → {boolean}

Source:
Deprecated:
  • Yes

To check if the hook is called after the hooked function

Returns:

Returns TRUE if the hook is called after the function, else FALSE

Type
boolean

isBefore() → {boolean}

Source:
Deprecated:
  • Yes

To check if the hook is called before the hooked function

Returns:

Returns TRUE if the hook is called before the function, else FALSE

Type
boolean

isIntercept() → {boolean}

Source:

To check if the hook perform an intercept (it modifiy value or execution path)

Returns:

Returns TRUE if the hook is an intercept, else FALSE

Type
boolean

isNative() → {boolean}

Source:

To check if it is a native hook

Returns:

Returns TRUE if it hooks a native function, else FALSE

Type
boolean

makeArgsHelper(args_arr)

Source:

To build the code source corresponding an array of parameters

It builds :

  • Argument part of the signature needed by Frida in order to identtfy good function to overload
  • Source code of the object send by the hook to the frida client
Parameters:
Name Type Description
args_arr ObjectType | BasicType

An array of Types

makeHookFor(method)

Source:

To create the Frida hook script for a specific method. Each token starting and ending by "@@" will be replaced by his value in the final script.

The available tokens are : "@@CLSDEF@@": md5(method.enclosingClass.name), "@@FQCN@@": method.enclosingClass.name, "@@METHDEF@@": md5(method.signature), "@@METHNAME@@": (method.name=='')? '$init' : method.name, "@@METHSIGN@@": method.signature, "@@ARGS@@": "", "@@HOOK_ARGS@@": "", "@@HOOK_ARGS2@@": "", "@@RET@@": "", "@@ARGS_VAL@@": "", "@@HOOK_ID@@": UT.b64_encode(this.id), "@@CTX@@":"", "@@ARGS_DATA@@":"null", "@@RET_DATA@@":"",

The resulting script is stored into the 'script' field of the 'Hook' instance.

Parameters:
Name Type Description
method Method

The method to hook

setEnable()

Source:
Deprecated:
  • Yes

Set enable flag with the given boolean.

setID(id) → {Hook}

Source:

To set the Unique ID of the hook

Parameters:
Name Type Description
id string

The Unique ID of the hook

Returns:

The instance of this hook

Type
Hook

setInterceptAfter(code) → {Hook}

Source:

To set the built hook code to exec AFTER the hooked function.

Parameters:
Name Type Description
code string

The built source code of the hook

Returns:

The instance of this hook

Type
Hook

setInterceptBefore(code) → {Hook}

Source:

To set the built hook code to exec BEFORE the hooked function.

Parameters:
Name Type Description
code string

The built source code of the hook

Returns:

The instance of this hook

Type
Hook

setInterceptReplace(code) → {Hook}

Source:

To set the built hook code to exec in place of the hooked function.

Parameters:
Name Type Description
code string

The builnt source code of the hook

Returns:

The instance of this hook

Type
Hook

setName(id) → {Hook}

Source:

To set the name of the hook. By default, it's the signature of the hooked method

Parameters:
Name Type Description
id string

The parent ID

Returns:

The instance of this hook

Type
Hook

setParentID(id) → {Hook}

Source:

To set the parent ID if available, like an HookSet ID.

Parameters:
Name Type Description
id string

The parent ID

Returns:

The instance of this hook

Type
Hook

toJsonObject() → {Object}

Source:

To make an instance of Object which not contain circular reference and which are ready to be serialized.

Returns:
  • Returns an Object instance representing the type
Type
Object