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.



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

def lsock
  @lsock
end

#rsockObject

The right side of the stream.



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

def rsock
  @rsock
end

Instance Method Details

#cleanup_abstractionObject

This method cleans up the abstraction layer.



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

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.



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

def close
	cleanup_abstraction
end

#initialize_abstractionObject

This method creates a streaming socket pair and initializes it.



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

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.



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

def localinfo
	"Local-side of Pipe"
end

#peerinfoObject

Symbolic peer information.



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

def peerinfo
	"Remote-side of Pipe"
end

#shutdown(how) ⇒ Object

Shuts down the local side of the stream abstraction.



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

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

#sysread(length) ⇒ Object

Low-level read from the local side.



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

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

#syswrite(buffer) ⇒ Object

Low-level write to the local side.



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

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