rex-core 0.1.24 → 0.1.25
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 +4 -4
 - checksums.yaml.gz.sig +0 -0
 - data/lib/rex/core/version.rb +1 -1
 - data/lib/rex/io/socket_abstraction.rb +34 -10
 - data/lib/rex/io/stream_server.rb +1 -1
 - data.tar.gz.sig +0 -0
 - metadata +1 -1
 - metadata.gz.sig +0 -0
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 92383c2b5e9cf999abfc198c12992d176cfdf262fbd782886ef1ea1a705f2fd6
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 584ffd804e8c5b1d3b96c5cf90580553fb12513c958362d93238cf92545c7184
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: fc7aa81e629107d66ceefdee7fcde2f7620fd95aff8bb2f163eacd31387835e84f123bdda4666b5e4c6a3390db5a9ddb4a55e8a15850c670ad0610c479ac2816
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 5d4b2fd53ec1cb320a5d503d97ff4f478f330368f98c3230cc1918edf1d07a9f950c2bef7d0210074e52ce1ee16097f3e32703b4476cd16d7d3edb651c26e35e
         
     | 
    
        checksums.yaml.gz.sig
    CHANGED
    
    | 
         Binary file 
     | 
    
        data/lib/rex/core/version.rb
    CHANGED
    
    
| 
         @@ -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 
     | 
    
         
            -
                     
     | 
| 
      
 135 
     | 
    
         
            +
                    rsock.extend(MonitoredRSock)
         
     | 
| 
      
 136 
     | 
    
         
            +
                    rsock.monitor_thread = self.monitor_thread = Rex::ThreadFactory.spawn(threadname, false) do
         
     | 
| 
       118 
137 
     | 
    
         
             
                      loop do
         
     | 
| 
       119 
     | 
    
         
            -
                        closed =  
     | 
| 
       120 
     | 
    
         
            -
                        buf = nil
         
     | 
| 
      
 138 
     | 
    
         
            +
                        closed = rsock.nil? || rsock.close_requested
         
     | 
| 
       121 
139 
     | 
    
         | 
| 
       122 
     | 
    
         
            -
                         
     | 
| 
       123 
     | 
    
         
            -
                          wlog('monitor_rsock: the remote socket  
     | 
| 
      
 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  
     | 
| 
       163 
     | 
    
         
            -
                              #     This way we naturally perform a resend if a failure  
     | 
| 
      
 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 
     | 
    
         
            -
                              #      
     | 
| 
      
 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  
     | 
| 
      
 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 
     | 
| 
      
 218 
     | 
    
         
            +
              end
         
     | 
| 
      
 219 
     | 
    
         
            +
            end
         
     | 
    
        data/lib/rex/io/stream_server.rb
    CHANGED
    
    | 
         @@ -141,7 +141,7 @@ module Rex 
     | 
|
| 
       141 
141 
     | 
    
         
             
                      begin
         
     | 
| 
       142 
142 
     | 
    
         
             
                        cli = accept
         
     | 
| 
       143 
143 
     | 
    
         
             
                        unless cli
         
     | 
| 
       144 
     | 
    
         
            -
                          elog( 
     | 
| 
      
 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
    
    
    
        metadata.gz.sig
    CHANGED
    
    | 
         Binary file 
     |