Beispiel #1
0
    async def get_connection_layer(self):
        try:
            if self.target.proxy is None:
                return DCERPCTCPConnection(self.target.ip,
                                           self.target.port), None

            elif self.target.proxy.type in [
                    SMBProxyType.WSNET, SMBProxyType.WSNETWS,
                    SMBProxyType.WSNETWSS, SMBProxyType.SOCKS5,
                    SMBProxyType.SOCKS5_SSL, SMBProxyType.SOCKS4,
                    SMBProxyType.SOCKS4_SSL
            ]:
                self.is_proxy = True
                return SocksProxyConnection(target=self.target), None

            elif self.target.proxy.type in [
                    SMBProxyType.MULTIPLEXOR, SMBProxyType.MULTIPLEXOR_SSL
            ]:
                self.is_proxy = True
                mpc = MultiplexorProxyConnection(self.target)
                socks_proxy, err = await mpc.connect()
                return socks_proxy, err

            else:
                raise Exception('Unknown proxy type %s' %
                                self.target.proxy.type)
        except Exception as e:
            return None, e
Beispiel #2
0
    async def select(target):
        if target.proxy is None:
            return TCPSocket(target=target)
        elif target.proxy.type in [
                SMBProxyType.SOCKS5, SMBProxyType.SOCKS5_SSL,
                SMBProxyType.SOCKS4, SMBProxyType.SOCKS4_SSL
        ]:
            return SocksProxyConnection(target=target)

        elif target.proxy.type in [
                SMBProxyType.MULTIPLEXOR, SMBProxyType.MULTIPLEXOR_SSL
        ]:
            mpc = MultiplexorProxyConnection(target)
            socks_proxy = await mpc.connect()
            return socks_proxy

        return None
Beispiel #3
0
    async def select(target):
        if target.proxy is None:
            return TCPSocket(target=target), None
        elif target.proxy.type in [
                SMBProxyType.SOCKS5, SMBProxyType.SOCKS5_SSL,
                SMBProxyType.SOCKS4, SMBProxyType.SOCKS4_SSL
        ]:
            return SocksProxyConnection(target=target), None

        elif target.proxy.type in [
                SMBProxyType.MULTIPLEXOR, SMBProxyType.MULTIPLEXOR_SSL
        ]:
            mpc = MultiplexorProxyConnection(target)
            socks_proxy, err = await mpc.connect()
            return socks_proxy, err

        else:
            return None, Exception('Cant select correct connectgion type!')
Beispiel #4
0
    async def select(target):
        if target.proxy is None:
            if target.protocol == SMBConnectionProtocol.QUIC:
                from aiosmb.network.quic import QUICSocket
                return QUICSocket(target=target), None
            else:
                return TCPSocket(target=target), None
        elif target.proxy.type in ASYSOCKS_PROXY_TYPES:
            return SocksProxyConnection(target=target), None

        elif target.proxy.type in [
                SMBProxyType.MULTIPLEXOR, SMBProxyType.MULTIPLEXOR_SSL
        ]:
            mpc = MultiplexorProxyConnection(target)
            socks_proxy, err = await mpc.connect()
            return socks_proxy, err

        else:
            return None, Exception('Cant select correct connection type!')
Beispiel #5
0
    async def connect(self, is_kerberos=False):
        """
		
		"""
        #hiding the import, so you'll only need to install multiplexor when actually using it
        from multiplexor.operator import MultiplexorOperator

        #creating connection string
        #if self.target.proxy.type == SMBProxyType.MULTIPLEXOR:
        #	con_str = 'ws://%s:%s' % (self.target.proxy.ip, self.target.proxy.port)
        #else:
        #	con_str = 'wss://%s:%s' % (self.target.proxy.ip, self.target.proxy.port)
        con_str = self.target.proxy.target.get_server_url()
        #creating operator and connecting to multiplexor server
        self.operator = MultiplexorOperator(con_str, logging_sink=logger)
        await self.operator.connect()
        #creating socks5 proxy
        server_info = await self.operator.start_socks5(
            self.target.proxy.target.agent_id)
        await self.operator.terminate()
        #print(server_info)
        if is_kerberos is False:

            #copying the original target, then feeding it to socks5proxy object. it will hold the actual socks5 proxy server address we created before
            tp = SMBProxy()
            tp.target = SocksTarget()
            tp.target.version = SocksServerVersion.SOCKS5
            tp.target.server_ip = server_info['listen_ip']
            tp.target.server_port = server_info['listen_port']
            tp.target.is_bind = False
            tp.target.proto = SocksProtocol.TCP
            tp.target.timeout = 10
            tp.target.buffer_size = 4096

            tp.target.endpoint_ip = self.target.ip
            tp.target.endpoint_port = self.target.port
            tp.target.endpoint_timeout = self.target.timeout
            tp.type = SMBProxyType.SOCKS5

            newtarget = copy.deepcopy(self.target)
            newtarget.proxy = tp

            return SocksProxyConnection(target=newtarget)

        else:
            kt = copy.deepcopy(self.target)
            kt.proxy = KerberosProxy()
            kt.proxy.target = SocksTarget()
            kt.proxy.target.version = SocksServerVersion.SOCKS5
            kt.proxy.target.server_ip = server_info['listen_ip']
            kt.proxy.target.server_port = server_info['listen_port']
            kt.proxy.target.is_bind = False
            kt.proxy.target.proto = SocksProtocol.TCP
            kt.proxy.target.timeout = 10
            kt.proxy.target.buffer_size = 4096

            kt.proxy.target.endpoint_ip = self.target.ip
            kt.proxy.target.endpoint_port = self.target.port
            kt.proxy.creds = copy.deepcopy(self.target.proxy.auth)

            return kt