Class: Msf::Sessions::Modem::UdpChannel
- Inherits:
-
ChannelBase
- Object
- ChannelBase
- Msf::Sessions::Modem::UdpChannel
- Includes:
- Rex::IO::DatagramAbstraction
- Defined in:
- lib/msf/base/sessions/modem.rb
Overview
Generic UDP channel
Mirrors the Meterpreter UDP channel (Rex::Post::Meterpreter::Extensions::Stdapi::Net::SocketSubsystem::UdpChannel): it builds a real UDP socketpair via Rex::IO::DatagramAbstraction and hands the framework an lsock extended with Rex::Socket::Udp, so the returned object is a drop-in UDPSocket-alike (send/sendto/recv/recvfrom/read/write).
Outbound datagrams are routed to the modem connection’s send() via the DirectChannelWrite mixin; inbound datagrams drained from recv are written into rsock followed by the sender’s sockaddr (the same two-write trick Meterpreter’s Datagram#dio_write_handler uses) so recvfrom() can reconstruct [data, host, port].
Defined Under Namespace
Modules: DirectChannelWrite, SocketInterface
Instance Attribute Summary
Attributes inherited from ChannelBase
Instance Method Summary collapse
-
#dio_write(buf) ⇒ Object
Send a datagram toward the peer through the modem connection.
-
#initialize(session, cid, conn, params) ⇒ UdpChannel
constructor
Create a new UdpChannel.
Methods inherited from ChannelBase
#close, #closed?, #remote_closed, #remote_closed?
Constructor Details
#initialize(session, cid, conn, params) ⇒ UdpChannel
Create a new UdpChannel.
313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 |
# File 'lib/msf/base/sessions/modem.rb', line 313 def initialize(session, cid, conn, params) initialize_abstraction super lsock.extend(Rex::Socket::Udp) lsock.initsock lsock.extend(SocketInterface) lsock.extend(DirectChannelWrite) lsock.channel = self rsock.extend(SocketInterface) rsock.channel = self @sockaddr = Rex::Socket.to_sockaddr(@params.peerhost, @params.peerport) start_reader_thread('ModemUdpChannelReader') do |data| if data.is_a?(::String) && !data.empty? rsock.syswrite(data) rsock.syswrite(@sockaddr) end true rescue ::StandardError false end session.add_channel(self) end |
Instance Method Details
#dio_write(buf) ⇒ Object
Send a datagram toward the peer through the modem connection. Invoked by the lsock’s DirectChannelWrite#syswrite and SocketInterface#send.
344 345 346 |
# File 'lib/msf/base/sessions/modem.rb', line 344 def dio_write(buf) send_to_connection(buf) end |