0.1.7 • Published 4 years ago

deflectjs-engine v0.1.7

Weekly downloads
7
License
MIT
Repository
github
Last release
4 years ago

DeflectJS API - Hooking

Make it easier to hook APIs and functions into javascript using DeflectJS API Hooking. If you want install it in node, please check our npm package deflectjs-engine.

Get started into DeflectJS Hooking Engine

Our example will show how to change the behavior of the console.log function using a replacement hook.

The console.log by default display a text parameter specified in log(str), thus let's change the real output to "Hooked: " + str. When an user call console.log(str) the string displayed should be "Hooked: " + str. After attach our hook, console.log("Test!") will give "Hooked: Test!" instead of "Test!".

Original output when calling console.log

Hooking the function console.log using DeflectJS Hooking Engine

var hookStruct; //Struct that contains our hook data.
var hookQueue = []; //Queue where our hook will be added.

//Function that will replace the current console.log
function hookedLog(text){
    return hookStruct.OriginalFunction("Hooked: " + text); 
}

//Creating the stub that will intercept calls for console.log
hookStruct = deflect_create_native_hook(console.log, hookedLog, DEFLECT_NATIVE_OVERWRITTEN_HOOK, console);

//Adding the hooks in the queue to be attached.
if (deflect_enqueue_hook(hookStruct, hookQueue) != DEFLECT_STATE_ENQUEUED){
    alert('Error!');
}

//Attaching all hooks in queue.
if (deflect_attach_hook(hookQueue) != DEFLECT_STATE_HOOKED){
    alert('Error!');
}

After hooking the console.log api, let's see what happens when you call it.

//Now, let's see what happens when call console.log
console.log("Test!");

And our result will be:

Unhooking the function console.log using DeflectJS Hooking Engine

if (deflect_detach_hook(hookQueue) == DEFLECT_STATE_UNHOOKED){
    alert('Successful unhooked!');
}

Compatibility of modern browsers

BrowserVerified versionSupported features
Google Chromev79.0.3945.88All features
Mozilla Firefoxv71.0All features
Operav65.0.3467.78All features
Microsoft Edgev20.10240.16384.0All features

Malicious use of DeflectJS Hooking Engine

When a function is hooked its behavior changes and leads to different results than the application intended. Malicious use of hooks to exploit systems is discouraged and isn't our responsibility.

Wiki of DeflectJS Engine Hooking

Visit our wiki page and read our api sample.

0.1.7

4 years ago

0.1.6

4 years ago

0.1.5

4 years ago

0.1.4

4 years ago

0.1.3

4 years ago

1.0.2

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago