rex-core 0.1.24 → 0.1.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 879343c39c0c1769143a3d0b5c61ce102e26ac898a50e5eec9581bc2bee47c91
4
- data.tar.gz: fca03a370a59dc3d03369fb29f47a0fb5e42dcb66db9d6e7b4f3b0824e9620f7
3
+ metadata.gz: 2aa029e6b51914e6b125525408d3b691ba3b3f3d714a95cc3b5a7759eddda95d
4
+ data.tar.gz: 7895ffdabf047757db4a42af53cb3d97888bc3756963217a267ad513679a078d
5
5
  SHA512:
6
- metadata.gz: fda24ae80de4cfda9e66f3bfe45b93bee23e4b35b57bb55f1fca0784721fa333154c8d6972a01594794a3b479e3a07c7809c0911a573b79315dfa8d01148faea
7
- data.tar.gz: a6c8d8c2783a611b50f240e664ab2011da5e6ec5d46b3d7353e12cae0e56140f0ec33973fa7d25c0e10226a12b53815bc76fa3de6363678eb6b8e72cc2e7a569
6
+ metadata.gz: 498bba8dce9ef27f6314affa367949c9a011428e9dabb06ef3a0f56d7a1c00f12321ef31e49b5a9442eed5a39ae3f30fcfecbc1b4c5adf57a3856d4fb3c9dcd4
7
+ data.tar.gz: bde42deb8d8798570dd5ac6504242194dc0857e88a18c14ccaf50a79ad6f9722f4b3f31dcbd1e75e2bcafcebd17ef159c171121445f4698c9c9a9f2415080574
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/rex/compat.rb CHANGED
@@ -133,6 +133,7 @@ def self.open_browser(url='http://google.com/')
133
133
  when /darwin/
134
134
  system("open #{url}")
135
135
  when /android/
136
+ url = "file://#{url}" if url.to_s.start_with?('/')
136
137
  system("am start --user 0 -a android.intent.action.VIEW -d #{url}")
137
138
  else
138
139
  # Search through the PATH variable (if it exists) and chose a browser
@@ -190,6 +191,7 @@ def self.open_webrtc_browser(url='http://google.com/')
190
191
  end
191
192
  end
192
193
  when /android/
194
+ url = "file://#{url}" if url.to_s.start_with?('/')
193
195
  system("am start --user 0 -a android.intent.action.VIEW -d #{url}")
194
196
  else
195
197
  if defined? ENV['PATH']
@@ -1,5 +1,5 @@
1
1
  module Rex
2
2
  module Core
3
- VERSION = "0.1.24"
3
+ VERSION = "0.1.27"
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/lib/rex/sync/ref.rb CHANGED
@@ -10,11 +10,38 @@ module Rex
10
10
  #
11
11
  ###
12
12
  module Ref
13
+ #
14
+ # Raises a TypeError to prevent cloning.
15
+ #
16
+ def clone
17
+ raise TypeError, "can't clone instance of Ref #{self.class}"
18
+ end
19
+
20
+ #
21
+ # Raises a TypeError to prevent duping.
22
+ #
23
+ def dup
24
+ raise TypeError, "can't dup instance of Ref #{self.class}"
25
+ end
26
+
27
+ #
28
+ # Ensures that the Ref is correctly initialized when extended on an object:
29
+ # ```
30
+ # arbitrary_resource = Resource.new
31
+ # arbitrary_resource.extend(::Rex::Ref)
32
+ # ```
33
+ #
34
+ # @param instance [object] the instance that has just extended the Ref module
35
+ def self.extended(instance)
36
+ instance.refinit
37
+ end
13
38
 
14
39
  #
15
40
  # Initializes the reference count to one.
16
41
  #
17
42
  def refinit
43
+ return if defined?(@_references)
44
+
18
45
  @_references = 1
19
46
  @_references_mutex = Mutex.new
20
47
 
data.tar.gz.sig CHANGED
@@ -1 +1,3 @@
1
- cc=�:,ۥq���<NS)�-�'����X)���ݥ��ߋb깋��]w\ܷ�IQ��lGZ�����t��_ڑ�0�EY���<.y�\B n��
1
+ !�@��`���X)� ��
2
+ ��b ���cpi������ G�=M���E~{1���})���U�'��/��B�Тn\�?j���սwNT�f ?/l6A�oon�Ad6���}W`5�����w��(6�]�T+�G��ܞ8s=ɼ߾�[VX�%��`�������,���Y�;�R{�|x
3
+ }$Y�󞰸�i-U j_��&ĚN�x� =G�����컔�r8��m��ޣk�o��0|hM��ݥD�T��n�uL
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.27
5
5
  platform: ruby
6
6
  authors:
7
7
  - Metasploit Hackers
@@ -93,7 +93,7 @@ cert_chain:
93
93
  EknWpNgVhohbot1lfVAMmIhdtOVaRVcQQixWPwprDj/ydB8ryDMDosIMcw+fkoXU
94
94
  9GJsSaSRRYQ9UUkVL27b64okU8D48m8=
95
95
  -----END CERTIFICATE-----
96
- date: 2022-01-26 00:00:00.000000000 Z
96
+ date: 2022-03-24 00:00:00.000000000 Z
97
97
  dependencies:
98
98
  - !ruby/object:Gem::Dependency
99
99
  name: rake
metadata.gz.sig CHANGED
Binary file