Module: Rex::IO::StreamAbstraction

Overview

This class provides an abstraction to a stream based connection through the use of a streaming socketpair.

Defined Under Namespace

Modules: Ext

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#lsockObject

The left side of the stream.


115
116
117
# File 'lib/rex/io/stream_abstraction.rb', line 115

def lsock
  @lsock
end

#rsockObject

The right side of the stream.


119
120
121
# File 'lib/rex/io/stream_abstraction.rb', line 119

def rsock
  @rsock
end

Instance Method Details

#cleanup_abstractionObject

This method cleans up the abstraction layer.


62
63
64
65
66
67
68
# File 'lib/rex/io/stream_abstraction.rb', line 62

def cleanup_abstraction
  self.lsock.close if (self.lsock)
  self.rsock.close if (self.rsock)

  self.lsock = nil
  self.rsock = nil
end

#closeObject

Closes both sides of the stream abstraction.


94
95
96
# File 'lib/rex/io/stream_abstraction.rb', line 94

def close
  cleanup_abstraction
end

#initialize_abstractionObject

This method creates a streaming socket pair and initializes it.


50
51
52
53
54
55
56
57
# File 'lib/rex/io/stream_abstraction.rb', line 50

def initialize_abstraction
  self.lsock, self.rsock = Rex::Socket.tcp_socket_pair()
  self.lsock.extend(Rex::IO::Stream)
  self.lsock.extend(Ext)
  self.rsock.extend(Rex::IO::Stream)

  self.monitor_rsock
end

#localinfoObject

Symbolic local information.


108
109
110
# File 'lib/rex/io/stream_abstraction.rb', line 108

def localinfo
  "Local-side of Pipe"
end

#peerinfoObject

Symbolic peer information.


101
102
103
# File 'lib/rex/io/stream_abstraction.rb', line 101

def peerinfo
  "Remote-side of Pipe"
end

#shutdown(how) ⇒ Object

Shuts down the local side of the stream abstraction.


87
88
89
# File 'lib/rex/io/stream_abstraction.rb', line 87

def shutdown(how)
  lsock.shutdown(how)
end

#sysread(length) ⇒ Object

Low-level read from the local side.


80
81
82
# File 'lib/rex/io/stream_abstraction.rb', line 80

def sysread(length)
  lsock.sysread(length)
end

#syswrite(buffer) ⇒ Object

Low-level write to the local side.


73
74
75
# File 'lib/rex/io/stream_abstraction.rb', line 73

def syswrite(buffer)
  lsock.syswrite(buffer)
end