本文整理汇总了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
示例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
示例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')
示例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)
示例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)
示例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)
示例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)
示例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
示例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
示例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)
示例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
示例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
##################################################
示例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
示例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
示例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