rex-core 0.1.20 → 0.1.21

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: cacc2616718c8056c7ff5ecf2626562f71ac9efd0a6ae69c80cd21565824b666
4
- data.tar.gz: e6ed793586462b6cc826be77b533030e45a7bce1ae4fd0bdb2cbaf62ed6e17dd
3
+ metadata.gz: 1ab976e408acf491f30c2d5ec12fde516b6ceebf75257216a07997dccee92ba5
4
+ data.tar.gz: 382f26dd0e86f8245bdbdde3462f5555080a6f85a03b76a7a164ab4b796c7672
5
5
  SHA512:
6
- metadata.gz: a7367cb540a9638f4f64e5756f3c9761e3ebe05f15444ee2d4ae8e6f6af94888f50e2813cc89e7ef3bc7492335f20c31ccc98c8c3ba4b2a55e61995b174c8497
7
- data.tar.gz: 4dbd3f07ec237c23ca088bbbdc2f67e2a59bcf5167bcebe841550877fc99f1e81ef3a9c763ddb9c7d8478844676e08ee3f706188c721049be00fbe2b3350ef89
6
+ metadata.gz: 27ca06a5a3a339a079c2b177dbb034737e1836a2b9a14edfd48accc04912a803c8158eebc6f800425fbcbaccf86abfc22d2a7892cc4650e073927a758cf11c14
7
+ data.tar.gz: a4b223838152b1eb302bc3ff52298b60d9ed25f5eb9d920eb6a526607d5490f4fdaa89f8135913c15b66cbce0cf54a6be5b263faf717d299000dcc368491b6fd
checksums.yaml.gz.sig CHANGED
Binary file
@@ -1,5 +1,5 @@
1
1
  module Rex
2
2
  module Core
3
- VERSION = "0.1.20"
3
+ VERSION = "0.1.21"
4
4
  end
5
5
  end
@@ -4,202 +4,192 @@ require 'socket'
4
4
  require 'fcntl'
5
5
 
6
6
  module Rex
7
- module IO
8
-
9
- ###
10
- #
11
- # This class provides an abstraction to a stream based
12
- # connection through the use of a streaming socketpair.
13
- #
14
- ###
15
- module SocketAbstraction
16
-
17
- ###
18
- #
19
- # Extension information for required Stream interface.
20
- #
21
- ###
22
- module Ext
23
-
24
- #
25
- # Initializes peer information.
7
+ module IO
8
+ ###
26
9
  #
27
- def initinfo(peer,local)
28
- @peer = peer
29
- @local = local
30
- end
31
-
10
+ # This class provides an abstraction to a stream based
11
+ # connection through the use of a streaming socketpair.
32
12
  #
33
- # Symbolic peer information.
34
- #
35
- def peerinfo
36
- (@peer || "Remote Pipe")
37
- end
13
+ ###
14
+ module SocketAbstraction
15
+ ###
16
+ #
17
+ # Extension information for required Stream interface.
18
+ #
19
+ ###
20
+ module Ext
21
+ #
22
+ # Initializes peer information.
23
+ #
24
+ def initinfo(peer, local)
25
+ @peer = peer
26
+ @local = local
27
+ end
38
28
 
39
- #
40
- # Symbolic local information.
41
- #
42
- def localinfo
43
- (@local || "Local Pipe")
44
- end
45
- end
46
-
47
- #
48
- # Override this method to init the abstraction
49
- #
50
- def initialize_abstraction
51
- self.lsock, self.rsock = Rex::Compat.pipe
52
- end
53
-
54
- #
55
- # This method cleans up the abstraction layer.
56
- #
57
- def cleanup_abstraction
58
- self.lsock.close if (self.lsock and !self.lsock.closed?)
59
- self.rsock.close if (self.rsock and !self.rsock.closed?)
60
-
61
- self.lsock = nil
62
- self.rsock = nil
63
- end
64
-
65
- #
66
- # Low-level write to the local side.
67
- #
68
- def syswrite(buffer)
69
- lsock.syswrite(buffer)
70
- end
71
-
72
- #
73
- # Low-level read from the local side.
74
- #
75
- def sysread(length)
76
- lsock.sysread(length)
77
- end
78
-
79
- #
80
- # Shuts down the local side of the stream abstraction.
81
- #
82
- def shutdown(how)
83
- lsock.shutdown(how)
84
- end
85
-
86
- #
87
- # Closes both sides of the stream abstraction.
88
- #
89
- def close
90
- cleanup_abstraction
91
- super
92
- end
93
-
94
- #
95
- # Symbolic peer information.
96
- #
97
- def peerinfo
98
- "Remote-side of Pipe"
99
- end
100
-
101
- #
102
- # Symbolic local information.
103
- #
104
- def localinfo
105
- "Local-side of Pipe"
106
- end
107
-
108
- #
109
- # The left side of the stream.
110
- #
111
- attr_reader :lsock
112
- #
113
- # The right side of the stream.
114
- #
115
- attr_reader :rsock
116
-
117
- protected
118
-
119
- def monitor_rsock(threadname = "SocketMonitorRemote")
120
- self.monitor_thread = Rex::ThreadFactory.spawn(threadname, false) {
121
- loop do
122
- closed = false
123
- buf = nil
124
-
125
- if not self.rsock
126
- wlog("monitor_rsock: the remote socket is nil, exiting loop")
127
- break
29
+ #
30
+ # Symbolic peer information.
31
+ #
32
+ def peerinfo
33
+ (@peer || 'Remote Pipe')
128
34
  end
129
35
 
130
- begin
131
- s = Rex::ThreadSafe.select( [ self.rsock ], nil, nil, 0.2 )
132
- if( s == nil || s[0] == nil )
133
- next
134
- end
135
- rescue Exception => e
136
- wlog("monitor_rsock: exception during select: #{e.class} #{e}")
137
- closed = true
36
+ #
37
+ # Symbolic local information.
38
+ #
39
+ def localinfo
40
+ (@local || 'Local Pipe')
138
41
  end
42
+ end
139
43
 
140
- if( closed == false )
141
- begin
142
- buf = self.rsock.sysread( 32768 )
143
- if buf == nil
144
- closed = true
145
- wlog("monitor_rsock: closed remote socket due to nil read")
44
+ #
45
+ # Override this method to init the abstraction
46
+ #
47
+ def initialize_abstraction
48
+ self.lsock, self.rsock = Rex::Compat.pipe
49
+ end
50
+
51
+ #
52
+ # This method cleans up the abstraction layer.
53
+ #
54
+ def cleanup_abstraction
55
+ lsock.close if lsock and !lsock.closed?
56
+ rsock.close if rsock and !rsock.closed?
57
+
58
+ self.lsock = nil
59
+ self.rsock = nil
60
+ end
61
+
62
+ #
63
+ # Low-level write to the local side.
64
+ #
65
+ def syswrite(buffer)
66
+ lsock.syswrite(buffer)
67
+ end
68
+
69
+ #
70
+ # Low-level read from the local side.
71
+ #
72
+ def sysread(length)
73
+ lsock.sysread(length)
74
+ end
75
+
76
+ #
77
+ # Shuts down the local side of the stream abstraction.
78
+ #
79
+ def shutdown(how)
80
+ lsock.shutdown(how)
81
+ end
82
+
83
+ #
84
+ # Closes both sides of the stream abstraction.
85
+ #
86
+ def close
87
+ cleanup_abstraction
88
+ super
89
+ end
90
+
91
+ #
92
+ # Symbolic peer information.
93
+ #
94
+ def peerinfo
95
+ 'Remote-side of Pipe'
96
+ end
97
+
98
+ #
99
+ # Symbolic local information.
100
+ #
101
+ def localinfo
102
+ 'Local-side of Pipe'
103
+ end
104
+
105
+ #
106
+ # The left side of the stream.
107
+ #
108
+ attr_reader :lsock
109
+ #
110
+ # The right side of the stream.
111
+ #
112
+ attr_reader :rsock
113
+
114
+ protected
115
+
116
+ def monitor_rsock(threadname = 'SocketMonitorRemote')
117
+ self.monitor_thread = Rex::ThreadFactory.spawn(threadname, false) do
118
+ loop do
119
+ closed = false
120
+ buf = nil
121
+
122
+ unless rsock
123
+ wlog('monitor_rsock: the remote socket is nil, exiting loop')
124
+ break
146
125
  end
147
- rescue EOFError => e
148
- closed = true
149
- dlog("monitor_rsock: EOF in rsock")
150
- rescue ::Exception => e
151
- closed = true
152
- wlog("monitor_rsock: exception during read: #{e.class} #{e}")
153
- end
154
- end
155
126
 
156
- if( closed == false )
157
- total_sent = 0
158
- total_length = buf.length
159
- while( total_sent < total_length )
160
127
  begin
161
- data = buf[total_sent, buf.length]
162
-
163
- # Note that this must be write() NOT syswrite() or put() or anything like it.
164
- # Using syswrite() breaks SSL streams.
165
- sent = self.write( data )
128
+ s = Rex::ThreadSafe.select([rsock], nil, nil, 0.2)
129
+ next if s.nil? || s[0].nil?
130
+ rescue Exception => e
131
+ wlog("monitor_rsock: exception during select: #{e.class} #{e}")
132
+ closed = true
133
+ end
166
134
 
167
- # sf: Only remove the data off the queue is write was successfull.
168
- # This way we naturally perform a resend if a failure occured.
169
- # Catches an edge case with meterpreter TCP channels where remote send
170
- # failes gracefully and a resend is required.
171
- if (sent.nil?)
135
+ unless closed
136
+ begin
137
+ buf = rsock.sysread(32_768)
138
+ if buf.nil?
139
+ closed = true
140
+ wlog('monitor_rsock: closed remote socket due to nil read')
141
+ end
142
+ rescue EOFError => e
172
143
  closed = true
173
- wlog("monitor_rsock: failed writing, socket must be dead")
174
- break
175
- elsif (sent > 0)
176
- total_sent += sent
144
+ dlog('monitor_rsock: EOF in rsock')
145
+ rescue ::Exception => e
146
+ closed = true
147
+ wlog("monitor_rsock: exception during read: #{e.class} #{e}")
177
148
  end
178
- rescue ::IOError, ::EOFError => e
179
- closed = true
180
- wlog("monitor_rsock: exception during write: #{e.class} #{e}")
181
- break
182
149
  end
183
- end
184
- end
185
150
 
186
- if( closed )
187
- begin
188
- self.close_write if self.respond_to?('close_write')
189
- rescue IOError
151
+ unless closed
152
+ total_sent = 0
153
+ total_length = buf.length
154
+ while total_sent < total_length
155
+ begin
156
+ data = buf[total_sent, buf.length]
157
+
158
+ # Note that this must be write() NOT syswrite() or put() or anything like it.
159
+ # Using syswrite() breaks SSL streams.
160
+ sent = write(data)
161
+
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.
164
+ # Catches an edge case with meterpreter TCP channels where remote send
165
+ # failes gracefully and a resend is required.
166
+ if sent.nil?
167
+ closed = true
168
+ wlog('monitor_rsock: failed writing, socket must be dead')
169
+ break
170
+ elsif sent > 0
171
+ total_sent += sent
172
+ end
173
+ rescue ::IOError, ::EOFError => e
174
+ closed = true
175
+ wlog("monitor_rsock: exception during write: #{e.class} #{e}")
176
+ break
177
+ end
178
+ end
179
+ end
180
+
181
+ next unless closed
182
+
183
+ begin
184
+ close_write if respond_to?('close_write')
185
+ rescue IOError
186
+ end
187
+ break
190
188
  end
191
- break
192
189
  end
193
190
  end
194
- }
195
- end
196
-
197
- protected
198
- attr_accessor :monitor_thread
199
- attr_writer :lsock
200
- attr_writer :rsock
201
-
202
- end
203
-
204
- end; end
205
191
 
192
+ attr_accessor :monitor_thread
193
+ attr_writer :lsock, :rsock
194
+ end
195
+ end; 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.20
4
+ version: 0.1.21
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: 2021-11-16 00:00:00.000000000 Z
96
+ date: 2022-01-25 00:00:00.000000000 Z
97
97
  dependencies:
98
98
  - !ruby/object:Gem::Dependency
99
99
  name: rake
metadata.gz.sig CHANGED
Binary file