当前位置: 首页>>代码示例>>Python>>正文


Python ldap.LDAPConnection方法代码示例

本文整理汇总了Python中impacket.ldap.ldap.LDAPConnection方法的典型用法代码示例。如果您正苦于以下问题:Python ldap.LDAPConnection方法的具体用法?Python ldap.LDAPConnection怎么用?Python ldap.LDAPConnection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在impacket.ldap.ldap的用法示例。


在下文中一共展示了ldap.LDAPConnection方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: kerberos_login

# 需要导入模块: from impacket.ldap import ldap [as 别名]
# 或者: from impacket.ldap.ldap import LDAPConnection [as 别名]
def kerberos_login(self, aesKey, kdcHost):
        # Create the baseDN
        domainParts = self.domain.split('.')
        self.baseDN = ''
        for i in domainParts:
            self.baseDN += 'dc=%s,' % i
        # Remove last ','
        self.baseDN = self.baseDN[:-1]

        if self.kdcHost is not None:
            target = self.kdcHost
        else:
            target = self.domain

        try:
            self.ldapConnection.kerberosLogin(self.username, self.password, self.domain, self.lmhash, self.nthash,
                                                self.aesKey, kdcHost=self.kdcHost)                                
        except ldap_impacket.LDAPSessionError as e:
            if str(e).find('strongerAuthRequired') >= 0:
                # We need to try SSL
                self.ldapConnection = ldap_impacket.LDAPConnection('ldaps://%s' % target, self.baseDN, self.kdcHost)
                self.ldapConnection.kerberosLogin(self.username, self.password, self.domain, self.lmhash, self.nthash,
                                                self.aesKey, kdcHost=self.kdcHost)

        return True 
开发者ID:byt3bl33d3r,项目名称:CrackMapExec,代码行数:27,代码来源:ldap.py

示例2: connect

# 需要导入模块: from impacket.ldap import ldap [as 别名]
# 或者: from impacket.ldap.ldap import LDAPConnection [as 别名]
def connect(self):
        ldapConnection = ldap.LDAPConnection(self.url, self.baseDN)
        ldapConnection.login(self.username, self.password)
        return ldapConnection 
开发者ID:joxeankoret,项目名称:CVE-2017-7494,代码行数:6,代码来源:test_ldap.py

示例3: test_sicily

# 需要导入模块: from impacket.ldap import ldap [as 别名]
# 或者: from impacket.ldap.ldap import LDAPConnection [as 别名]
def test_sicily(self):
        ldapConnection = ldap.LDAPConnection(self.url, self.baseDN)
        ldapConnection.login(authenticationChoice='sicilyPackageDiscovery') 
开发者ID:joxeankoret,项目名称:CVE-2017-7494,代码行数:5,代码来源:test_ldap.py

示例4: test_sicilyNtlm

# 需要导入模块: from impacket.ldap import ldap [as 别名]
# 或者: from impacket.ldap.ldap import LDAPConnection [as 别名]
def test_sicilyNtlm(self):
        ldapConnection = ldap.LDAPConnection(self.url, self.baseDN)
        ldapConnection.login(user=self.username, password=self.password, domain=self.domain)

        self.dummySearch(ldapConnection) 
开发者ID:joxeankoret,项目名称:CVE-2017-7494,代码行数:7,代码来源:test_ldap.py

示例5: test_kerberosLogin

# 需要导入模块: from impacket.ldap import ldap [as 别名]
# 或者: from impacket.ldap.ldap import LDAPConnection [as 别名]
def test_kerberosLogin(self):
        ldapConnection = ldap.LDAPConnection(self.url, self.baseDN)
        ldapConnection.kerberosLogin(self.username, self.password, self.domain)

        self.dummySearch(ldapConnection) 
开发者ID:joxeankoret,项目名称:CVE-2017-7494,代码行数:7,代码来源:test_ldap.py

示例6: test_kerberosLoginHashes

# 需要导入模块: from impacket.ldap import ldap [as 别名]
# 或者: from impacket.ldap.ldap import LDAPConnection [as 别名]
def test_kerberosLoginHashes(self):
        if len(self.hashes) > 0:
            lmhash, nthash = self.hashes.split(':')
        else:
            lmhash = ''
            nthash = ''
        ldapConnection = ldap.LDAPConnection(self.url, self.baseDN)
        ldapConnection.kerberosLogin(self.username, '', self.domain, lmhash, nthash, '', None, None)

        self.dummySearch(ldapConnection) 
开发者ID:joxeankoret,项目名称:CVE-2017-7494,代码行数:12,代码来源:test_ldap.py

示例7: test_sicilyNtlmHashes

# 需要导入模块: from impacket.ldap import ldap [as 别名]
# 或者: from impacket.ldap.ldap import LDAPConnection [as 别名]
def test_sicilyNtlmHashes(self):
        if len(self.hashes) > 0:
            lmhash, nthash = self.hashes.split(':')
        else:
            lmhash = ''
            nthash = ''
        ldapConnection = ldap.LDAPConnection(self.url, self.baseDN)
        ldapConnection.login(user=self.username, password=self.password, domain=self.domain, lmhash=lmhash, nthash=nthash )

        self.dummySearch(ldapConnection) 
开发者ID:joxeankoret,项目名称:CVE-2017-7494,代码行数:12,代码来源:test_ldap.py

示例8: _create_ldap_connection

# 需要导入模块: from impacket.ldap import ldap [as 别名]
# 或者: from impacket.ldap.ldap import LDAPConnection [as 别名]
def _create_ldap_connection(self, queried_domain=str(), ads_path=str(),
                                ads_prefix=str()):
        if not self._domain:
            self._domain = self._get_netfqdn()

        if not queried_domain:
            queried_domain = self._get_netfqdn()
        self._queried_domain = queried_domain

        base_dn = str()

        if ads_prefix:
            self._ads_prefix = ads_prefix
            base_dn = '{},'.format(self._ads_prefix)

        if ads_path:
            # TODO: manage ADS path starting with 'GC://'
            if ads_path.upper().startswith('LDAP://'):
                ads_path = ads_path[7:]
            self._ads_path = ads_path
            base_dn += self._ads_path
        else:
            base_dn += ','.join('dc={}'.format(x) for x in self._queried_domain.split('.'))

        try:
            ldap_connection = ldap.LDAPConnection('ldap://{}'.format(self._domain_controller),
                                                  base_dn, self._domain_controller)
            ldap_connection.login(self._user, self._password, self._domain,
                                  self._lmhash, self._nthash)
        except ldap.LDAPSessionError, e:
            if str(e).find('strongerAuthRequired') >= 0:
                # We need to try SSL
                ldap_connection = ldap.LDAPConnection('ldaps://{}'.format(self._domain_controller),
                                                      base_dn, self._domain_controller)
                ldap_connection.login(self._user, self._password, self._domain,
                                      self._lmhash, self._nthash)
            else:
                raise e 
开发者ID:the-useless-one,项目名称:pywerview,代码行数:40,代码来源:requester.py

示例9: _create_ldap_connection

# 需要导入模块: from impacket.ldap import ldap [as 别名]
# 或者: from impacket.ldap.ldap import LDAPConnection [as 别名]
def _create_ldap_connection(self, queried_domain=str(), ads_path=str(), ads_prefix=str()):
        if not self._domain:
            self._domain = self._get_netfqdn()

        if not queried_domain:
            queried_domain = self._get_netfqdn()
        self._queried_domain = queried_domain

        base_dn = str()

        if ads_prefix:
            self._ads_prefix = ads_prefix
            base_dn = '{},'.format(self._ads_prefix)

        if ads_path:
            # TODO: manage ADS path starting with 'GC://'
            if ads_path.upper().startswith('LDAP://'):
                ads_path = ads_path[7:]
            self._ads_path = ads_path
            base_dn += self._ads_path
        else:
            base_dn += ','.join('dc={}'.format(x) for x in self._queried_domain.split('.'))

        try:
            ldap_connection = ldap.LDAPConnection('ldap://{}'.format(self._domain_controller),
                                                  base_dn, self._domain_controller)
            ldap_connection.login(self._user, self._password, self._domain,
                                  self._lmhash, self._nthash)
        except ldap.LDAPSessionError as e:
            if str(e).find('strongerAuthRequired') >= 0:
                # We need to try SSL
                ldap_connection = ldap.LDAPConnection('ldaps://{}'.format(self._domain_controller),
                                                      base_dn, self._domain_controller)
                ldap_connection.login(self._user, self._password, self._domain,
                                      self._lmhash, self._nthash)
            else:
                raise e
        except socket.error as e:
            return

        self._ldap_connection = ldap_connection 
开发者ID:aas-n,项目名称:spraykatz,代码行数:43,代码来源:requester.py

示例10: test_kerberosLoginKeys

# 需要导入模块: from impacket.ldap import ldap [as 别名]
# 或者: from impacket.ldap.ldap import LDAPConnection [as 别名]
def test_kerberosLoginKeys(self):
        ldapConnection = ldap.LDAPConnection(self.url, self.baseDN)
        ldapConnection.kerberosLogin(self.username, '', self.domain, '', '', self.aesKey, None, None)

        self.dummySearch(ldapConnection) 
开发者ID:Coalfire-Research,项目名称:Slackor,代码行数:7,代码来源:test_ldap.py

示例11: ldap_con

# 需要导入模块: from impacket.ldap import ldap [as 别名]
# 或者: from impacket.ldap.ldap import LDAPConnection [as 别名]
def ldap_con(self):
        try:
            self.con = ldap.LDAPConnection("ldap://{}".format(self.ip))
            return True
        except:
            return False 
开发者ID:m8r0wn,项目名称:ActiveReign,代码行数:8,代码来源:__init__.py

示例12: ldaps_con

# 需要导入模块: from impacket.ldap import ldap [as 别名]
# 或者: from impacket.ldap.ldap import LDAPConnection [as 别名]
def ldaps_con(self):
        try:
            self.con = ldap.LDAPConnection("ldaps://{}".format(self.ip))
            self.ldaps = True
            return True
        except:
            return False

    ##################################################
    # Ldap Query Functions
    ################################################## 
开发者ID:m8r0wn,项目名称:ActiveReign,代码行数:13,代码来源:__init__.py

示例13: create_ldap_con

# 需要导入模块: from impacket.ldap import ldap [as 别名]
# 或者: from impacket.ldap.ldap import LDAPConnection [as 别名]
def create_ldap_con(self):
        try:
            self.con = ldap.LDAPConnection("ldap://{}".format(self.host), )
            return True
        except Exception as e:
            print(e)
            return False 
开发者ID:m8r0wn,项目名称:ldap_search,代码行数:9,代码来源:core.py

示例14: create_ldaps_con

# 需要导入模块: from impacket.ldap import ldap [as 别名]
# 或者: from impacket.ldap.ldap import LDAPConnection [as 别名]
def create_ldaps_con(self):
        try:
            self.con = ldap.LDAPConnection("ldaps://{}".format(self.host), )
            self.ldaps = True
            return True
        except Exception as e:
            print(e)
            return False 
开发者ID:m8r0wn,项目名称:ldap_search,代码行数:10,代码来源:core.py

示例15: run

# 需要导入模块: from impacket.ldap import ldap [as 别名]
# 或者: from impacket.ldap.ldap import LDAPConnection [as 别名]
def run(self):
        if self.__doKerberos:
            self.__target = self.getMachineName()
        else:
            if self.__kdcHost is not None:
                self.__target = self.__kdcHost
            else:
                self.__target = self.__domain

        # Connect to LDAP
        try:
            ldapConnection = ldap.LDAPConnection('ldap://%s'%self.__target, self.baseDN, self.__kdcHost)
            if self.__doKerberos is not True:
                ldapConnection.login(self.__username, self.__password, self.__domain, self.__lmhash, self.__nthash)
            else:
                ldapConnection.kerberosLogin(self.__username, self.__password, self.__domain, self.__lmhash, self.__nthash,
                                             self.__aesKey, kdcHost=self.__kdcHost)
        except ldap.LDAPSessionError, e:
            if str(e).find('strongerAuthRequired') >= 0:
                # We need to try SSL
                ldapConnection = ldap.LDAPConnection('ldaps://%s' % self.__target, self.baseDN, self.__kdcHost)
                if self.__doKerberos is not True:
                    ldapConnection.login(self.__username, self.__password, self.__domain, self.__lmhash, self.__nthash)
                else:
                    ldapConnection.kerberosLogin(self.__username, self.__password, self.__domain, self.__lmhash, self.__nthash,
                                                 self.__aesKey, kdcHost=self.__kdcHost)
            else:
                raise

        # Building the search filter 
开发者ID:tholum,项目名称:PiBunny,代码行数:32,代码来源:GetUserSPNs.py


注:本文中的impacket.ldap.ldap.LDAPConnection方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。