From 6388578ee685e739f1a092d3ac50685330469e98 Mon Sep 17 00:00:00 2001 From: James Lee Date: Wed, 23 Mar 2016 16:15:46 -0500 Subject: [PATCH] Style fixes --- lib/rex/io/datagram_abstraction.rb | 1 + lib/rex/post/meterpreter/channels/datagram.rb | 2 +- .../channels/socket_abstraction.rb | 4 ++-- .../extensions/stdapi/net/socket.rb | 22 +++++++++---------- .../socket_subsystem/tcp_client_channel.rb | 12 +++++----- .../net/socket_subsystem/udp_channel.rb | 18 +++++++-------- 6 files changed, 30 insertions(+), 29 deletions(-) diff --git a/lib/rex/io/datagram_abstraction.rb b/lib/rex/io/datagram_abstraction.rb index a052a13b1f..bf9492dfa2 100644 --- a/lib/rex/io/datagram_abstraction.rb +++ b/lib/rex/io/datagram_abstraction.rb @@ -13,6 +13,7 @@ module IO ### module DatagramAbstraction include Rex::IO::SocketAbstraction + # # Creates a streaming socket pair # diff --git a/lib/rex/post/meterpreter/channels/datagram.rb b/lib/rex/post/meterpreter/channels/datagram.rb index 3cb33b1660..16498d1092 100644 --- a/lib/rex/post/meterpreter/channels/datagram.rb +++ b/lib/rex/post/meterpreter/channels/datagram.rb @@ -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 diff --git a/lib/rex/post/meterpreter/channels/socket_abstraction.rb b/lib/rex/post/meterpreter/channels/socket_abstraction.rb index b08965d35b..c59577dfae 100644 --- a/lib/rex/post/meterpreter/channels/socket_abstraction.rb +++ b/lib/rex/post/meterpreter/channels/socket_abstraction.rb @@ -79,8 +79,8 @@ module SocketAbstraction # module DirectChannelWrite - def syswrite( buf ) - channel._write( buf ) + def syswrite(buf) + channel._write(buf) end attr_accessor :channel diff --git a/lib/rex/post/meterpreter/extensions/stdapi/net/socket.rb b/lib/rex/post/meterpreter/extensions/stdapi/net/socket.rb index 0aa0d31f4d..753dd8c808 100644 --- a/lib/rex/post/meterpreter/extensions/stdapi/net/socket.rb +++ b/lib/rex/post/meterpreter/extensions/stdapi/net/socket.rb @@ -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 diff --git a/lib/rex/post/meterpreter/extensions/stdapi/net/socket_subsystem/tcp_client_channel.rb b/lib/rex/post/meterpreter/extensions/stdapi/net/socket_subsystem/tcp_client_channel.rb index 9574caebc5..09832b6c2b 100644 --- a/lib/rex/post/meterpreter/extensions/stdapi/net/socket_subsystem/tcp_client_channel.rb +++ b/lib/rex/post/meterpreter/extensions/stdapi/net/socket_subsystem/tcp_client_channel.rb @@ -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 diff --git a/lib/rex/post/meterpreter/extensions/stdapi/net/socket_subsystem/udp_channel.rb b/lib/rex/post/meterpreter/extensions/stdapi/net/socket_subsystem/udp_channel.rb index dda93f0040..c9f3511624 100644 --- a/lib/rex/post/meterpreter/extensions/stdapi/net/socket_subsystem/udp_channel.rb +++ b/lib/rex/post/meterpreter/extensions/stdapi/net/socket_subsystem/udp_channel.rb @@ -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