Module: Rex::IO::SocketAbstraction

Included in:
DatagramAbstraction, StreamAbstraction
Defined in:
lib/rex/io/socket_abstraction.rb

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.



113
114
115
# File 'lib/rex/io/socket_abstraction.rb', line 113

def lsock
  @lsock
end

#rsockObject

The right side of the stream.



117
118
119
# File 'lib/rex/io/socket_abstraction.rb', line 117

def rsock
  @rsock
end

Instance Method Details

#cleanup_abstractionObject

This method cleans up the abstraction layer.



56
57
58
59
60
61
62
63
64
65
# File 'lib/rex/io/socket_abstraction.rb', line 56

def cleanup_abstraction
  lsock.close if lsock and !lsock.closed?

  monitor_thread.join if monitor_thread&.alive? && monitor_thread&.object_id != Thread.current.object_id

  rsock.close if rsock and !rsock.closed?

  self.lsock = nil
  self.rsock = nil
end

#closeObject

Closes both sides of the stream abstraction.



91
92
93
94
# File 'lib/rex/io/socket_abstraction.rb', line 91

def close
  cleanup_abstraction
  super
end

#initialize_abstractionObject

Override this method to init the abstraction



49
50
51
# File 'lib/rex/io/socket_abstraction.rb', line 49

def initialize_abstraction
  self.lsock, self.rsock = Rex::Compat.pipe
end

#localinfoObject

Symbolic local information.



106
107
108
# File 'lib/rex/io/socket_abstraction.rb', line 106

def localinfo
  'Local-side of Pipe'
end

#peerinfoObject

Symbolic peer information.



99
100
101
# File 'lib/rex/io/socket_abstraction.rb', line 99

def peerinfo
  'Remote-side of Pipe'
end

#shutdown(how) ⇒ Object

Shuts down the local side of the stream abstraction.



84
85
86
# File 'lib/rex/io/socket_abstraction.rb', line 84

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

#sysread(length) ⇒ Object

Low-level read from the local side.



77
78
79
# File 'lib/rex/io/socket_abstraction.rb', line 77

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

#syswrite(buffer) ⇒ Object

Low-level write to the local side.



70
71
72
# File 'lib/rex/io/socket_abstraction.rb', line 70

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