passbe/beef-migration-test-2 — Issue #209: Module code should only run once (Module Lock)
Author: passbe
Created: 2011-12-05 09:25:27+00:00
State: open

I think though, that we maybe need a new constuct/function within
beefjs whereby a module can specify a "lock" such that it doesn't
execute twice?

In both the detect_tor and the vtiger module I've *hacked* this by
creating a non-existant image DOM element. When the module first
executes it checks for that image, if it's present it stops running.
Everywhere in the code where it sends back using beef.net.sendback
I've also put in relevant code to remove that DOM element such that
the module can run again in the future.

I think this process should probably be built into the framework, but
I'm not entirely sure, and I'm not entirely sure if the image tag is
the best way for it to work?

The method I've used:

Setup lock:
13 if (document.getElementById('vtigerimg')) {
14 return "Exploit running already";
15 }
16
17 var img = new Image();
18 img.setAttribute("style","visibility:hidden");
19 img.setAttribute("width","0");
20 img.setAttribute("height","0");
21 img.id = 'vtigerimg';
22
23 document.body.appendChild(img);

Remove lock:
127 document.body.removeChild(document.getElementById('vtigerimg'));

Original link: http://code.google.com/p/beef/issues/detail?id=186