rex-core 0.1.24 → 0.1.25

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 879343c39c0c1769143a3d0b5c61ce102e26ac898a50e5eec9581bc2bee47c91
4
- data.tar.gz: fca03a370a59dc3d03369fb29f47a0fb5e42dcb66db9d6e7b4f3b0824e9620f7
3
+ metadata.gz: 92383c2b5e9cf999abfc198c12992d176cfdf262fbd782886ef1ea1a705f2fd6
4
+ data.tar.gz: 584ffd804e8c5b1d3b96c5cf90580553fb12513c958362d93238cf92545c7184
5
5
  SHA512:
6
- metadata.gz: fda24ae80de4cfda9e66f3bfe45b93bee23e4b35b57bb55f1fca0784721fa333154c8d6972a01594794a3b479e3a07c7809c0911a573b79315dfa8d01148faea
7
- data.tar.gz: a6c8d8c2783a611b50f240e664ab2011da5e6ec5d46b3d7353e12cae0e56140f0ec33973fa7d25c0e10226a12b53815bc76fa3de6363678eb6b8e72cc2e7a569
6
+ metadata.gz: fc7aa81e629107d66ceefdee7fcde2f7620fd95aff8bb2f163eacd31387835e84f123bdda4666b5e4c6a3390db5a9ddb4a55e8a15850c670ad0610c479ac2816
7
+ data.tar.gz: 5d4b2fd53ec1cb320a5d503d97ff4f478f330368f98c3230cc1918edf1d07a9f950c2bef7d0210074e52ce1ee16097f3e32703b4476cd16d7d3edb651c26e35e
checksums.yaml.gz.sig CHANGED
Binary file
@@ -1,5 +1,5 @@
1
1
  module Rex
2
2
  module Core
3
- VERSION = "0.1.24"
3
+ VERSION = "0.1.25"
4
4
  end
5
5
  end
@@ -53,6 +53,9 @@ module Rex
53
53
  #
54
54
  def cleanup_abstraction
55
55
  lsock.close if lsock and !lsock.closed?
56
+
57
+ monitor_thread.join if monitor_thread&.alive?
58
+
56
59
  rsock.close if rsock and !rsock.closed?
57
60
 
58
61
  self.lsock = nil
@@ -111,19 +114,36 @@ module Rex
111
114
  #
112
115
  attr_reader :rsock
113
116
 
117
+ module MonitoredRSock
118
+ def close
119
+ @close_requested = true
120
+ @monitor_thread.join
121
+ nil
122
+ end
123
+
124
+ def sysclose
125
+ self.class.instance_method(:close).bind(self).call
126
+ end
127
+
128
+ attr_reader :close_requested
129
+ attr_writer :monitor_thread
130
+ end
131
+
114
132
  protected
115
133
 
116
134
  def monitor_rsock(threadname = 'SocketMonitorRemote')
117
- self.monitor_thread = Rex::ThreadFactory.spawn(threadname, false) do
135
+ rsock.extend(MonitoredRSock)
136
+ rsock.monitor_thread = self.monitor_thread = Rex::ThreadFactory.spawn(threadname, false) do
118
137
  loop do
119
- closed = false
120
- buf = nil
138
+ closed = rsock.nil? || rsock.close_requested
121
139
 
122
- unless rsock
123
- wlog('monitor_rsock: the remote socket is nil, exiting loop')
140
+ if closed
141
+ wlog('monitor_rsock: the remote socket has been closed, exiting loop')
124
142
  break
125
143
  end
126
144
 
145
+ buf = nil
146
+
127
147
  begin
128
148
  s = Rex::ThreadSafe.select([rsock], nil, nil, 0.2)
129
149
  next if s.nil? || s[0].nil?
@@ -159,10 +179,10 @@ module Rex
159
179
  # Using syswrite() breaks SSL streams.
160
180
  sent = write(data)
161
181
 
162
- # sf: Only remove the data off the queue is write was successfull.
163
- # This way we naturally perform a resend if a failure occured.
182
+ # sf: Only remove the data off the queue is write was successful.
183
+ # This way we naturally perform a resend if a failure occurred.
164
184
  # Catches an edge case with meterpreter TCP channels where remote send
165
- # failes gracefully and a resend is required.
185
+ # fails gracefully and a resend is required.
166
186
  if sent.nil?
167
187
  closed = true
168
188
  wlog('monitor_rsock: failed writing, socket must be dead')
@@ -182,14 +202,18 @@ module Rex
182
202
 
183
203
  begin
184
204
  close_write if respond_to?('close_write')
185
- rescue IOError
205
+ rescue StandardError
186
206
  end
207
+
187
208
  break
188
209
  end
210
+
211
+ rsock.sysclose
189
212
  end
190
213
  end
191
214
 
192
215
  attr_accessor :monitor_thread
193
216
  attr_writer :lsock, :rsock
194
217
  end
195
- end; end
218
+ end
219
+ end
@@ -141,7 +141,7 @@ module Rex
141
141
  begin
142
142
  cli = accept
143
143
  unless cli
144
- elog("The accept() returned nil in stream server listener monitor: #{fd.inspect}")
144
+ elog('The accept() returned nil in stream server listener monitor')
145
145
  ::IO.select(nil, nil, nil, 0.10)
146
146
  next
147
147
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rex-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.24
4
+ version: 0.1.25
5
5
  platform: ruby
6
6
  authors:
7
7
  - Metasploit Hackers
metadata.gz.sig CHANGED
Binary file