Style fixes
parent
98355c397c
commit
6388578ee6
|
@ -13,6 +13,7 @@ module IO
|
|||
###
|
||||
module DatagramAbstraction
|
||||
include Rex::IO::SocketAbstraction
|
||||
|
||||
#
|
||||
# Creates a streaming socket pair
|
||||
#
|
||||
|
|
|
@ -52,7 +52,7 @@ class Datagram < Rex::Post::Meterpreter::Channel
|
|||
Rex::Post::Meterpreter::Extensions::Stdapi::TLV_TYPE_PEER_PORT
|
||||
)
|
||||
|
||||
if( peerhost and peerport )
|
||||
if peerhost && peerport
|
||||
# Maxlen here is 65507, to ensure we dont overflow, we need to write twice
|
||||
# If the other side has a full 64k, handle by splitting up the datagram and
|
||||
# writing multiple times along with the sockaddr. Consumers calling recvfrom
|
||||
|
|
|
@ -79,8 +79,8 @@ module SocketAbstraction
|
|||
#
|
||||
module DirectChannelWrite
|
||||
|
||||
def syswrite( buf )
|
||||
channel._write( buf )
|
||||
def syswrite(buf)
|
||||
channel._write(buf)
|
||||
end
|
||||
|
||||
attr_accessor :channel
|
||||
|
|
|
@ -41,7 +41,7 @@ class Socket
|
|||
|
||||
# register the inbound handler for the tcp server channel (allowing us to
|
||||
# receive new client connections to a tcp server channel)
|
||||
client.register_inbound_handler( Rex::Post::Meterpreter::Extensions::Stdapi::Net::SocketSubsystem::TcpServerChannel )
|
||||
client.register_inbound_handler(Rex::Post::Meterpreter::Extensions::Stdapi::Net::SocketSubsystem::TcpServerChannel)
|
||||
|
||||
end
|
||||
|
||||
|
@ -49,7 +49,7 @@ class Socket
|
|||
# Deregister the inbound handler for the tcp server channel
|
||||
#
|
||||
def shutdown
|
||||
client.deregister_inbound_handler( Rex::Post::Meterpreter::Extensions::Stdapi::Net::SocketSubsystem::TcpServerChannel )
|
||||
client.deregister_inbound_handler(Rex::Post::Meterpreter::Extensions::Stdapi::Net::SocketSubsystem::TcpServerChannel)
|
||||
end
|
||||
|
||||
##
|
||||
|
@ -63,17 +63,17 @@ class Socket
|
|||
# in the socket parameters instance. The +params+ argument is expected to be
|
||||
# of type Rex::Socket::Parameters.
|
||||
#
|
||||
def create( params )
|
||||
def create(params)
|
||||
res = nil
|
||||
|
||||
if( params.tcp? )
|
||||
if( params.server? )
|
||||
res = create_tcp_server_channel( params )
|
||||
if params.tcp?
|
||||
if params.server?
|
||||
res = create_tcp_server_channel(params)
|
||||
else
|
||||
res = create_tcp_client_channel( params )
|
||||
res = create_tcp_client_channel(params)
|
||||
end
|
||||
elsif( params.udp? )
|
||||
res = create_udp_channel( params )
|
||||
elsif params.udp?
|
||||
res = create_udp_channel(params)
|
||||
end
|
||||
|
||||
return res
|
||||
|
@ -102,7 +102,7 @@ class Socket
|
|||
def create_tcp_client_channel(params)
|
||||
begin
|
||||
channel = SocketSubsystem::TcpClientChannel.open(client, params)
|
||||
if( channel != nil )
|
||||
if channel != nil
|
||||
return channel.lsock
|
||||
end
|
||||
return nil
|
||||
|
@ -121,7 +121,7 @@ class Socket
|
|||
def create_udp_channel(params)
|
||||
begin
|
||||
channel = SocketSubsystem::UdpChannel.open(client, params)
|
||||
if( channel != nil )
|
||||
if channel != nil
|
||||
return channel.lsock
|
||||
end
|
||||
return nil
|
||||
|
|
|
@ -69,14 +69,14 @@ class TcpClientChannel < Rex::Post::Meterpreter::Stream
|
|||
#
|
||||
# Passes the channel initialization information up to the base class.
|
||||
#
|
||||
def initialize( client, cid, type, flags )
|
||||
super( client, cid, type, flags )
|
||||
def initialize(client, cid, type, flags)
|
||||
super(client, cid, type, flags)
|
||||
|
||||
lsock.extend( SocketInterface )
|
||||
lsock.extend( DirectChannelWrite )
|
||||
lsock.extend(SocketInterface)
|
||||
lsock.extend(DirectChannelWrite)
|
||||
lsock.channel = self
|
||||
|
||||
rsock.extend( SocketInterface )
|
||||
rsock.extend(SocketInterface)
|
||||
rsock.channel = self
|
||||
|
||||
end
|
||||
|
@ -101,7 +101,7 @@ class TcpClientChannel < Rex::Post::Meterpreter::Stream
|
|||
request.add_tlv(TLV_TYPE_SHUTDOWN_HOW, how)
|
||||
request.add_tlv(TLV_TYPE_CHANNEL_ID, self.cid)
|
||||
|
||||
response = client.send_request(request)
|
||||
client.send_request(request)
|
||||
|
||||
return true
|
||||
end
|
||||
|
|
|
@ -60,17 +60,17 @@ class UdpChannel < Rex::Post::Meterpreter::Datagram
|
|||
#
|
||||
# Simply initialize this instance.
|
||||
#
|
||||
def initialize( client, cid, type, flags )
|
||||
super( client, cid, type, flags )
|
||||
def initialize(client, cid, type, flags)
|
||||
super(client, cid, type, flags)
|
||||
|
||||
lsock.extend( Rex::Socket::Udp )
|
||||
lsock.extend(Rex::Socket::Udp)
|
||||
lsock.initsock
|
||||
lsock.extend( SocketInterface )
|
||||
lsock.extend( DirectChannelWrite )
|
||||
lsock.extend(SocketInterface)
|
||||
lsock.extend(DirectChannelWrite)
|
||||
lsock.channel = self
|
||||
|
||||
# rsock.extend( Rex::Socket::Udp )
|
||||
rsock.extend( SocketInterface )
|
||||
rsock.extend(SocketInterface)
|
||||
rsock.channel = self
|
||||
|
||||
end
|
||||
|
@ -79,8 +79,8 @@ class UdpChannel < Rex::Post::Meterpreter::Datagram
|
|||
# This function is called by Rex::Socket::Udp.sendto and writes data to a specified
|
||||
# remote peer host/port via the remote end of the channel.
|
||||
#
|
||||
def send( buf, flags, saddr )
|
||||
af, peerhost, peerport = Rex::Socket.from_sockaddr( saddr )
|
||||
def send(buf, flags, saddr)
|
||||
_af, peerhost, peerport = Rex::Socket.from_sockaddr(saddr)
|
||||
|
||||
addends = [
|
||||
{
|
||||
|
@ -93,7 +93,7 @@ class UdpChannel < Rex::Post::Meterpreter::Datagram
|
|||
}
|
||||
]
|
||||
|
||||
return _write( buf, buf.length, addends )
|
||||
return _write(buf, buf.length, addends)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue