Beispiel #1
0
    def from_params(url_str):
        proxy = SMBProxy()
        url = urlparse(url_str)
        if url.query is None:
            return None

        query = parse_qs(url.query)
        if 'proxytype' not in query and 'sametype' not in query:
            return None

        proxy.type = SMBProxyType(query['proxytype'][0].upper())

        if proxy.type in [
                SMBProxyType.WSNET, SMBProxyType.WSNETWS,
                SMBProxyType.WSNETWSS, SMBProxyType.SOCKS4,
                SMBProxyType.SOCKS4_SSL, SMBProxyType.SOCKS5,
                SMBProxyType.SOCKS5_SSL
        ]:
            cu = SocksClientURL.from_params(url_str)
            cu[-1].endpoint_port = 445
            proxy.target = cu
        else:
            proxy.target = SMBMultiplexorProxy.from_params(url_str)

        return proxy
Beispiel #2
0
    def from_params(url_str):
        """
		Creates a proxy object from the parameters found in an LDAP URL string

		:param type: url_str
		:type type: str
		:return: The proxy object 
		:rtype: :class:`MSLDAPProxy`
		"""
        proxy = MSLDAPProxy()
        url = urlparse(url_str)
        if url.query is None:
            return None

        query = parse_qs(url.query)
        if 'proxytype' not in query and 'sametype' not in query:
            return None

        proxy.type = MSLDAPProxyType(query['proxytype'][0].upper())
        if proxy.type in [
                MSLDAPProxyType.SOCKS4, MSLDAPProxyType.SOCKS4_SSL,
                MSLDAPProxyType.SOCKS5, MSLDAPProxyType.SOCKS5_SSL
        ]:
            cu = SocksClientURL.from_params(url_str)
            proxy.target = cu.get_target()
            proxy.auth = cu.get_creds()
        else:
            proxy.target = MSLDAPMultiplexorProxy.from_params(url_str)

        return proxy
Beispiel #3
0
    def from_url(url_str):
        res = KerberosClientURL()
        url = urlparse(url_str)

        res.dc_ip = url.hostname
        schemes = url.scheme.upper().split('+')
        if schemes[0] not in ['KERBEROS', 'KERBEROS-TCP, KERBEROS-UDP']:
            raise Exception('Unknown protocol! %s' % schemes[0])

        if schemes[0].endswith('UDP') is True:
            res.protocol = KerberosSocketType.UDP

        try:
            res.secret_type = KerberosSecretType(schemes[1])
        except:
            raise Exception('Unknown secret type! %s' % schemes[0])

        if url.username is not None:
            if url.username.find('\\') != -1:
                res.domain, res.username = url.username.split('\\')
            else:
                raise Exception('Domain missing from username!')
        else:
            raise Exception('Missing username!')

        res.secret = url.password
        if url.port is not None:
            res.port = int(url.port)

        query = parse_qs(url.query)
        proxy_present = False
        for k in query:
            if k.startswith('proxy') is True:
                proxy_present = True

            if k in kerberosclienturl_param2var:
                data = query[k][0]
                for c in kerberosclienturl_param2var[k][1]:
                    data = c(data)

                    setattr(res, kerberosclienturl_param2var[k][0], data)

        if proxy_present is True:
            cu = SocksClientURL.from_params(url_str)
            cu.endpoint_ip = res.dc_ip
            cu.endpoint_port = res.port

            res.proxy = KerberosProxy(cu.get_target(), cu.get_creds())

        if res.username is None:
            raise Exception('Missing username!')
        if res.secret is None:
            raise Exception('Missing secret/password!')
        if res.secret_type is None:
            raise Exception('Missing secret_type!')
        if res.dc_ip is None:
            raise Exception('Missing target hostname!')

        return res
Beispiel #4
0
    async def setup(self):
        try:
            try:
                ipaddress.ip_address(self.server)
                return None, None
            except:
                pass

            self.in_q = asyncio.Queue()
            self.out_q = asyncio.Queue()
            su = SocksClientURL.from_params(self.server)
            comms = SocksQueueComms(self.in_q, self.out_q)
            self.proxy = SOCKSClient(comms, su)
            self.proxy_task = asyncio.create_task(self.proxy.run())
            return None, None
        except Exception as e:
            return None, e
Beispiel #5
0
	def from_params(url_str):
		proxy = MSLDAPProxy()
		url = urlparse(url_str)
		if url.query is None:
			return None

		query = parse_qs(url.query)
		if 'proxytype' not in query and 'sametype' not in query:
			return None
		
		proxy.type = MSLDAPProxyType(query['proxytype'][0].upper())
		if proxy.type in [MSLDAPProxyType.SOCKS4, MSLDAPProxyType.SOCKS4_SSL, MSLDAPProxyType.SOCKS5, MSLDAPProxyType.SOCKS5_SSL]:
			cu = SocksClientURL.from_params(url_str)
			proxy.target = cu.get_target()
			proxy.auth = cu.get_creds()
		else:
			proxy.target  = MSLDAPMultiplexorProxy.from_params(url_str)
		
		return proxy
Beispiel #6
0
    def from_url(url_str):
        res = KerberosClientURL()
        url = urlparse(url_str)

        res.dc_ip = url.hostname
        schemes = url.scheme.upper().split('+')

        if schemes[0] not in [
                'KERBEROS', 'KERBEROS-TCP, KERBEROS-UDP', 'KRB5', 'KRB5-UDP',
                'KRB5-TCP'
        ]:
            raise Exception('Unknown protocol! %s' % schemes[0])

        if schemes[0].endswith('UDP') is True:
            res.protocol = KerberosSocketType.UDP

        ttype = schemes[1]
        if ttype.find('-') != -1 and ttype.upper().endswith('-PROMPT'):
            ttype = ttype.split('-')[0]
            res.secret = getpass.getpass()
        try:
            res.secret_type = KerberosSecretType(ttype)
        except:
            raise Exception('Unknown secret type! %s' % ttype)

        if url.username is not None:
            if url.username.find('\\') != -1:
                res.domain, res.username = url.username.split('\\')
            else:
                raise Exception('Domain missing from username!')
        else:
            raise Exception('Missing username!')

        if res.secret is None:
            res.secret = url.password
        if url.port is not None:
            res.port = int(url.port)

        query = parse_qs(url.query)
        proxy_type = None
        for k in query:
            if k == 'proxytype':
                proxy_type = query[k][0]

            if k in kerberosclienturl_param2var:
                data = query[k][0]
                for c in kerberosclienturl_param2var[k][1]:
                    data = c(data)

                    setattr(res, kerberosclienturl_param2var[k][0], data)

        if proxy_type is not None:
            cu = SocksClientURL.from_params(url_str)
            cu[-1].endpoint_ip = res.dc_ip
            cu[-1].endpoint_port = res.port

            res.proxy = KerberosProxy(cu, None, type='SOCKS')

        if res.username is None:
            raise Exception('Missing username!')
        if res.secret is None:
            raise Exception('Missing secret/password!')
        if res.secret_type is None:
            raise Exception('Missing secret_type!')
        if res.dc_ip is None:
            raise Exception('Missing target hostname!')

        return res
Beispiel #7
0
def main():
    url_1 = 'smb://10.10.10.2/?timeout=10&dc=10.10.10.2&proxytype=socks5&proxyserver=127.0.0.1&proxyuser=admin&proxypass=alma&dc=10.10.10.2&dns=8.8.8.8'
    cu = SocksClientURL.from_params(url_1)

    target = cu.get_target()
    print(repr(target))