Sha256: d3f4012880867e8b84c57b12538a049cac7cf1e09593adc9ef0c4554ecaecb0c

Contents?: true

Size: 1.53 KB

Versions: 45

Compression:

Stored size: 1.53 KB

Contents

module Rex
  module Socket

    # This class exists to abuse the Proxy capabilities in the Net::SSH library to allow the use of Rex::Sockets
    # for the transport layer in Net::SSH. The SSHFactory object will respond to the #open method and create the
    # {Rex::Socket::Tcp}
    class SSHFactory

      # @!attribute msfraemwork
      #   @return [Object] The framework instance object
      attr_accessor :framework
      # @!attribute msfmodule
      #   @return [Object] The metasploit module this socket belongs to
      attr_accessor :msfmodule
      # @!attribute proxies
      #   @return [String] Any proxies to use for the connection
      attr_accessor :proxies

      def initialize(framework, msfmodule, proxies)
        @framework = framework
        @msfmodule   = msfmodule
        @proxies     = proxies
      end

      # Responds to the proxy setup routine Net::SSH will call when
      # initialising the Transport Layer. This will instead create our
      # {Rex::Socket::Tcp} and tie the socket back to the calling module
      # @param host [String] The host to open the connection to
      # @param port [Fixnum] the port to open the connection on
      # @param options [Hash] the options hash
      def open(host, port, options={})
        socket = Rex::Socket::Tcp.create(
          'PeerHost' => host,
          'PeerPort' => port,
          'Proxies' => proxies,
          'Context'  => {
            'Msf'          => framework,
            'MsfExploit'   => msfmodule
          }
        )
        socket
      end
    end
  end
end

Version data entries

45 entries across 45 versions & 1 rubygems

Version Path
rex-socket-0.1.59 lib/rex/socket/ssh_factory.rb
rex-socket-0.1.58 lib/rex/socket/ssh_factory.rb
rex-socket-0.1.57 lib/rex/socket/ssh_factory.rb
rex-socket-0.1.56 lib/rex/socket/ssh_factory.rb
rex-socket-0.1.55 lib/rex/socket/ssh_factory.rb
rex-socket-0.1.54 lib/rex/socket/ssh_factory.rb
rex-socket-0.1.53 lib/rex/socket/ssh_factory.rb
rex-socket-0.1.52 lib/rex/socket/ssh_factory.rb
rex-socket-0.1.51 lib/rex/socket/ssh_factory.rb
rex-socket-0.1.50 lib/rex/socket/ssh_factory.rb
rex-socket-0.1.49 lib/rex/socket/ssh_factory.rb
rex-socket-0.1.48 lib/rex/socket/ssh_factory.rb
rex-socket-0.1.47 lib/rex/socket/ssh_factory.rb
rex-socket-0.1.46 lib/rex/socket/ssh_factory.rb
rex-socket-0.1.45 lib/rex/socket/ssh_factory.rb
rex-socket-0.1.44 lib/rex/socket/ssh_factory.rb
rex-socket-0.1.43 lib/rex/socket/ssh_factory.rb
rex-socket-0.1.42 lib/rex/socket/ssh_factory.rb
rex-socket-0.1.41 lib/rex/socket/ssh_factory.rb
rex-socket-0.1.40 lib/rex/socket/ssh_factory.rb