File tree Expand file tree Collapse file tree 3 files changed +13
-4
lines changed Expand file tree Collapse file tree 3 files changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -127,7 +127,7 @@ def start_handler
127
127
rescue Rex ::ConnectionRefused
128
128
# Connection refused is a-okay
129
129
rescue ::Exception
130
- wlog ( "Exception caught in bind handler: #{ $!} " )
130
+ wlog ( "Exception caught in bind handler: #{ $!. class } #{ $! } " )
131
131
end
132
132
133
133
break if client
@@ -138,7 +138,6 @@ def start_handler
138
138
139
139
# Valid client connection?
140
140
if ( client )
141
-
142
141
# Increment the has connection counter
143
142
self . pending_connections += 1
144
143
Original file line number Diff line number Diff line change @@ -149,6 +149,9 @@ def monitor_rsock
149
149
closed = true
150
150
wlog ( "monitor_rsock: closed remote socket due to nil read" )
151
151
end
152
+ rescue EOFError => e
153
+ closed = true
154
+ dlog ( "monitor_rsock: EOF in rsock" )
152
155
rescue ::Exception => e
153
156
closed = true
154
157
wlog ( "monitor_rsock: exception during read: #{ e . class } #{ e } " )
Original file line number Diff line number Diff line change @@ -154,7 +154,7 @@ def swap_sock_plain_to_ssl
154
154
ssl = OpenSSL ::SSL ::SSLSocket . new ( sock , ctx )
155
155
156
156
# Use non-blocking OpenSSL operations on Windows
157
- if not ( ssl . respond_to? ( :accept_nonblock ) and Rex ::Compat . is_windows )
157
+ if ! ( ssl . respond_to? ( :accept_nonblock ) and Rex ::Compat . is_windows )
158
158
ssl . accept
159
159
else
160
160
begin
@@ -211,12 +211,19 @@ def generate_ssl_context
211
211
cert . version = 2
212
212
cert . serial = rand ( 0xFFFFFFFF )
213
213
214
+ # Depending on how the socket was created, getsockname will
215
+ # return either a struct sockaddr as a String (the default ruby
216
+ # Socket behavior) or an Array (the extend'd Rex::Socket::Tcp
217
+ # behavior). Avoid the ambiguity by always picking a random
218
+ # hostname. See #7350.
219
+ subject_cn = Rex ::Text . rand_hostname
220
+
214
221
subject = OpenSSL ::X509 ::Name . new ( [
215
222
[ "C" , "US" ] ,
216
223
[ 'ST' , Rex ::Text . rand_state ( ) ] ,
217
224
[ "L" , Rex ::Text . rand_text_alpha ( rand ( 20 ) + 10 ) ] ,
218
225
[ "O" , Rex ::Text . rand_text_alpha ( rand ( 20 ) + 10 ) ] ,
219
- [ "CN" , self . sock . getsockname [ 1 ] || Rex :: Text . rand_hostname ] ,
226
+ [ "CN" , subject_cn ] ,
220
227
] )
221
228
issuer = OpenSSL ::X509 ::Name . new ( [
222
229
[ "C" , "US" ] ,
You can’t perform that action at this time.
0 commit comments