Ejemplo n.º 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
Ejemplo n.º 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
        ]:
            return Socks5ProxyConnection(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
Ejemplo n.º 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!')
Ejemplo n.º 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!')
Ejemplo n.º 5
0
    async def setup_kc(self):
        try:
            if self.target.proxy is None:
                self.kc = AIOKerberosClient(self.ccred, self.target)
            elif self.target.proxy.type in [
                    SMBProxyType.SOCKS5, SMBProxyType.SOCKS5_SSL,
                    SMBProxyType.SOCKS4, SMBProxyType.SOCKS4_SSL
            ]:
                target = AIOKerberosClientSocksSocket(self.target)
                self.kc = AIOKerberosClient(self.ccred, target)

            elif self.target.proxy.type in [
                    SMBProxyType.MULTIPLEXOR, SMBProxyType.MULTIPLEXOR_SSL
            ]:
                #	kcred.target.proxy = KerberosProxy()
                #	kcred.target.proxy.target = copy.deepcopy(target.proxy.target)
                #	kcred.target.proxy.target.endpoint_ip = target.dc_ip
                #	kcred.target.proxy.target.endpoint_port = 88
                #	kcred.target.proxy.creds = copy.deepcopy(target.proxy.auth)

                from aiosmb.network.multiplexornetwork import MultiplexorProxyConnection
                mpc = MultiplexorProxyConnection(self.target)
                socks_proxy, err = await mpc.connect(is_kerberos=True)

                self.kc = AIOKerberosClient(self.ccred, socks_proxy)

            else:
                raise Exception('Unknown proxy type %s' %
                                self.target.proxy.type)

            #elif target.proxy.type in [SMBProxyType.SOCKS5, SMBProxyType.SOCKS5_SSL, SMBProxyType.SOCKS4, SMBProxyType.SOCKS4_SSL]:
            #	self.kc = AIOKerberosClient(self.ccred, self.target)
            #elif target.proxy.type in [SMBProxyType.MULTIPLEXOR, SMBProxyType.MULTIPLEXOR_SSL]:
            #	mpc = MultiplexorProxyConnection(target)
            #	socks_proxy = await mpc.connect()
            return None, None
        except Exception as e:
            return None, e
Ejemplo n.º 6
0
    async def setup_kc(self):
        try:
            if self.target.proxy is None or isinstance(self.target.proxy,
                                                       KerberosProxy) is True:
                self.kc = AIOKerberosClient(self.ccred, self.target)

            elif self.target.proxy.type in [
                    SMBProxyType.MULTIPLEXOR, SMBProxyType.MULTIPLEXOR_SSL
            ]:
                from aiosmb.network.multiplexornetwork import MultiplexorProxyConnection
                mpc = MultiplexorProxyConnection(self.target)
                socks_proxy, err = await mpc.connect(is_kerberos=True)
                if err is not None:
                    raise err

                self.kc = AIOKerberosClient(self.ccred, socks_proxy)

            else:
                raise Exception('Unknown proxy type %s' %
                                self.target.proxy.type)

            return None, None
        except Exception as e:
            return None, e