rex-core 0.1.14 → 0.1.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/rex/core/version.rb +1 -1
- data/lib/rex/io/stream.rb +91 -31
- data/lib/rex/io/stream_abstraction.rb +4 -0
- metadata +2 -2
- metadata.gz.sig +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 30d6d74b1603e11dd926c24e867db559a88c9294fc1b4dc88559d66366928044
|
4
|
+
data.tar.gz: 7484592c2f3429b4481700937395ae6f0457b61fdddaf4abd9b780ebfff1de85
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0698ecc78c85cb0497065dc82521be98a264784e4e76951d24ac36d82ab7f3a3e7ade7c6993127e1db1513157826edfd137dfe33d4ca71fa139088235f5694c6'
|
7
|
+
data.tar.gz: 1b819f79ced4a1656120ceeca644d4a634b5e54923bc3c2887edf76b9e28ed1e4de85c917ffeeef4cce5c239913b398492ba4b3f20f058700ad2b5fc9304427c
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/rex/core/version.rb
CHANGED
data/lib/rex/io/stream.rb
CHANGED
@@ -25,6 +25,22 @@ module Stream
|
|
25
25
|
#
|
26
26
|
##
|
27
27
|
|
28
|
+
#
|
29
|
+
# Initialize synchronization for this stream. This should be used if the
|
30
|
+
# stream will be written to, read or closed from multiple threads.
|
31
|
+
#
|
32
|
+
def initialize_synchronization
|
33
|
+
self.stream_lock = Rex::ReadWriteLock.new
|
34
|
+
self.close_resource = false
|
35
|
+
end
|
36
|
+
|
37
|
+
def close
|
38
|
+
self.close_resource = true
|
39
|
+
synchronize_update {
|
40
|
+
super
|
41
|
+
}
|
42
|
+
end
|
43
|
+
|
28
44
|
#
|
29
45
|
# This method writes the supplied buffer to the stream. This method
|
30
46
|
# intelligent reduces the size of supplied buffers so that ruby doesn't get
|
@@ -37,28 +53,31 @@ module Stream
|
|
37
53
|
total_length = buf.length
|
38
54
|
block_size = 32768
|
39
55
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
56
|
+
synchronize_access {
|
57
|
+
begin
|
58
|
+
while( total_sent < total_length )
|
59
|
+
s = Rex::ThreadSafe.select( nil, [ fd ], nil, 0.2 )
|
60
|
+
if( s == nil || s[0] == nil )
|
61
|
+
next
|
62
|
+
end
|
63
|
+
data = buf[total_sent, block_size]
|
64
|
+
sent = fd.write_nonblock( data )
|
65
|
+
if sent > 0
|
66
|
+
total_sent += sent
|
67
|
+
end
|
50
68
|
end
|
69
|
+
rescue ::Errno::EAGAIN, ::Errno::EWOULDBLOCK
|
70
|
+
return nil if self.close_resource
|
71
|
+
# Sleep for a half a second, or until we can write again
|
72
|
+
Rex::ThreadSafe.select( nil, [ fd ], nil, 0.5 )
|
73
|
+
# Decrement the block size to handle full sendQs better
|
74
|
+
block_size = 1024
|
75
|
+
# Try to write the data again
|
76
|
+
retry
|
77
|
+
rescue ::IOError, ::Errno::EPIPE
|
78
|
+
return nil
|
51
79
|
end
|
52
|
-
|
53
|
-
# Sleep for a half a second, or until we can write again
|
54
|
-
Rex::ThreadSafe.select( nil, [ fd ], nil, 0.5 )
|
55
|
-
# Decrement the block size to handle full sendQs better
|
56
|
-
block_size = 1024
|
57
|
-
# Try to write the data again
|
58
|
-
retry
|
59
|
-
rescue ::IOError, ::Errno::EPIPE
|
60
|
-
return nil
|
61
|
-
end
|
80
|
+
}
|
62
81
|
|
63
82
|
total_sent
|
64
83
|
end
|
@@ -67,17 +86,19 @@ module Stream
|
|
67
86
|
# This method reads data of the supplied length from the stream.
|
68
87
|
#
|
69
88
|
def read(length = nil, opts = {})
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
89
|
+
synchronize_access {
|
90
|
+
begin
|
91
|
+
return fd.read_nonblock( length )
|
92
|
+
rescue ::Errno::EAGAIN, ::Errno::EWOULDBLOCK
|
93
|
+
return nil if self.close_resource
|
94
|
+
# Sleep for a half a second, or until we can read again
|
95
|
+
Rex::ThreadSafe.select( [ fd ], nil, nil, 0.5 )
|
96
|
+
# Decrement the block size to handle full sendQs better
|
97
|
+
retry
|
98
|
+
rescue ::IOError, ::Errno::EPIPE
|
99
|
+
return nil
|
100
|
+
end
|
101
|
+
}
|
81
102
|
end
|
82
103
|
|
83
104
|
#
|
@@ -306,6 +327,45 @@ module Stream
|
|
306
327
|
|
307
328
|
protected
|
308
329
|
|
330
|
+
#
|
331
|
+
# The read-write lock used to synchronize access to the stream. This is only
|
332
|
+
# set when synchronization has been initialized as performed by
|
333
|
+
# #initialize_synchronization.
|
334
|
+
#
|
335
|
+
attr_accessor :stream_lock
|
336
|
+
|
337
|
+
#
|
338
|
+
# A boolean flag indicating that the resource is to be closed. Blocking
|
339
|
+
# operations that are synchronized (such as #read and #write) should evaluate
|
340
|
+
# this flag and exit appropriately when there is no data to be processed.
|
341
|
+
attr_accessor :close_resource
|
342
|
+
|
343
|
+
#
|
344
|
+
# Synchronize non-state changing access to the stream such as read and write
|
345
|
+
# operations. If synchronization has not been initialized, this doesn't do
|
346
|
+
# anything.
|
347
|
+
#
|
348
|
+
def synchronize_access
|
349
|
+
self.stream_lock.lock_read unless self.stream_lock.nil?
|
350
|
+
begin
|
351
|
+
yield
|
352
|
+
ensure
|
353
|
+
self.stream_lock.unlock_read unless self.stream_lock.nil?
|
354
|
+
end
|
355
|
+
end
|
356
|
+
|
357
|
+
#
|
358
|
+
# Synchronize state changing operations to the stream such as closing it.
|
359
|
+
# If synchronization has not been initialized, this doesn't do anything.
|
360
|
+
#
|
361
|
+
def synchronize_update
|
362
|
+
self.stream_lock.lock_write unless self.stream_lock.nil?
|
363
|
+
begin
|
364
|
+
yield
|
365
|
+
ensure
|
366
|
+
self.stream_lock.unlock_write unless self.stream_lock.nil?
|
367
|
+
end
|
368
|
+
end
|
309
369
|
end
|
310
370
|
|
311
371
|
end end
|
@@ -19,10 +19,14 @@ module StreamAbstraction
|
|
19
19
|
#
|
20
20
|
def initialize_abstraction
|
21
21
|
self.lsock, self.rsock = Rex::Socket.tcp_socket_pair()
|
22
|
+
|
22
23
|
self.lsock.extend(Rex::IO::Stream)
|
23
24
|
self.lsock.extend(Ext)
|
24
25
|
self.rsock.extend(Rex::IO::Stream)
|
25
26
|
|
27
|
+
self.lsock.initialize_synchronization
|
28
|
+
self.rsock.initialize_synchronization
|
29
|
+
|
26
30
|
self.monitor_rsock("StreamMonitorRemote")
|
27
31
|
end
|
28
32
|
|
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.
|
4
|
+
version: 0.1.15
|
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:
|
96
|
+
date: 2021-02-04 00:00:00.000000000 Z
|
97
97
|
dependencies:
|
98
98
|
- !ruby/object:Gem::Dependency
|
99
99
|
name: rake
|
metadata.gz.sig
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
�]��q���Oc���|����`_����� ���u�n�w�&?���;��q�
|