當前位置: 首頁>>代碼示例>>Python>>正文


Python samr.hSamrQueryInformationDomain2方法代碼示例

本文整理匯總了Python中impacket.dcerpc.v5.samr.hSamrQueryInformationDomain2方法的典型用法代碼示例。如果您正苦於以下問題:Python samr.hSamrQueryInformationDomain2方法的具體用法?Python samr.hSamrQueryInformationDomain2怎麽用?Python samr.hSamrQueryInformationDomain2使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在impacket.dcerpc.v5.samr的用法示例。


在下文中一共展示了samr.hSamrQueryInformationDomain2方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_hSamrQueryInformationDomain2

# 需要導入模塊: from impacket.dcerpc.v5 import samr [as 別名]
# 或者: from impacket.dcerpc.v5.samr import hSamrQueryInformationDomain2 [as 別名]
def test_hSamrQueryInformationDomain2(self):
        dce, rpctransport, domainHandle  = self.connect()
        resp = samr.hSamrQueryInformationDomain2(dce, domainHandle,samr.DOMAIN_INFORMATION_CLASS.DomainPasswordInformation)
        resp.dump()

        resp = samr.hSamrQueryInformationDomain2(dce, domainHandle,samr.DOMAIN_INFORMATION_CLASS.DomainGeneralInformation)
        resp.dump()

        resp = samr.hSamrQueryInformationDomain2(dce, domainHandle,samr.DOMAIN_INFORMATION_CLASS.DomainLogoffInformation)
        resp.dump()

        resp = samr.hSamrQueryInformationDomain2(dce, domainHandle,samr.DOMAIN_INFORMATION_CLASS.DomainOemInformation)
        resp.dump()

        resp = samr.hSamrQueryInformationDomain2(dce, domainHandle,samr.DOMAIN_INFORMATION_CLASS.DomainNameInformation)
        resp.dump()

        resp = samr.hSamrQueryInformationDomain2(dce, domainHandle,samr.DOMAIN_INFORMATION_CLASS.DomainServerRoleInformation)
        resp.dump()

        resp = samr.hSamrQueryInformationDomain2(dce, domainHandle,samr.DOMAIN_INFORMATION_CLASS.DomainReplicationInformation)
        resp.dump()

        resp = samr.hSamrQueryInformationDomain2(dce, domainHandle,samr.DOMAIN_INFORMATION_CLASS.DomainModifiedInformation)
        resp.dump()

        resp = samr.hSamrQueryInformationDomain2(dce, domainHandle,samr.DOMAIN_INFORMATION_CLASS.DomainStateInformation)
        resp.dump()

        resp = samr.hSamrQueryInformationDomain2(dce, domainHandle,samr.DOMAIN_INFORMATION_CLASS.DomainGeneralInformation2)
        resp.dump()

        resp = samr.hSamrQueryInformationDomain2(dce, domainHandle,samr.DOMAIN_INFORMATION_CLASS.DomainLockoutInformation)
        resp.dump()

        resp = samr.hSamrQueryInformationDomain2(dce, domainHandle,samr.DOMAIN_INFORMATION_CLASS.DomainModifiedInformation2)
        resp.dump() 
開發者ID:joxeankoret,項目名稱:CVE-2017-7494,代碼行數:39,代碼來源:test_samr.py

示例2: fetchList

# 需要導入模塊: from impacket.dcerpc.v5 import samr [as 別名]
# 或者: from impacket.dcerpc.v5.samr import hSamrQueryInformationDomain2 [as 別名]
def fetchList(self, rpctransport):
        dce = DCERPC_v5(rpctransport)
        dce.connect()
        dce.bind(samr.MSRPC_UUID_SAMR)

        # Setup Connection
        resp = samr.hSamrConnect2(dce)
        if resp['ErrorCode'] != 0:
            raise Exception('Connect error')

        resp2 = samr.hSamrEnumerateDomainsInSamServer(dce, serverHandle=resp['ServerHandle'],
                                                      enumerationContext=0,
                                                      preferedMaximumLength=500)
        if resp2['ErrorCode'] != 0:
            raise Exception('Connect error')

        resp3 = samr.hSamrLookupDomainInSamServer(dce, serverHandle=resp['ServerHandle'],
                                                  name=resp2['Buffer']['Buffer'][0]['Name'])
        if resp3['ErrorCode'] != 0:
            raise Exception('Connect error')

        resp4 = samr.hSamrOpenDomain(dce, serverHandle=resp['ServerHandle'],
                                     desiredAccess=samr.MAXIMUM_ALLOWED,
                                     domainId=resp3['DomainId'])
        if resp4['ErrorCode'] != 0:
            raise Exception('Connect error')

        self.__domains = resp2['Buffer']['Buffer']
        domainHandle = resp4['DomainHandle']
        # End Setup

        re = samr.hSamrQueryInformationDomain2(dce, domainHandle=domainHandle,
                                               domainInformationClass=samr.DOMAIN_INFORMATION_CLASS.DomainPasswordInformation)
        self.__min_pass_len = re['Buffer']['Password']['MinPasswordLength'] or "None"
        self.__pass_hist_len = re['Buffer']['Password']['PasswordHistoryLength'] or "None"
        self.__max_pass_age = convert(int(re['Buffer']['Password']['MaxPasswordAge']['LowPart']), int(re['Buffer']['Password']['MaxPasswordAge']['HighPart']))
        self.__min_pass_age = convert(int(re['Buffer']['Password']['MinPasswordAge']['LowPart']), int(re['Buffer']['Password']['MinPasswordAge']['HighPart']))
        self.__pass_prop = d2b(re['Buffer']['Password']['PasswordProperties'])

        re = samr.hSamrQueryInformationDomain2(dce, domainHandle=domainHandle,
                                               domainInformationClass=samr.DOMAIN_INFORMATION_CLASS.DomainLockoutInformation)
        self.__rst_accnt_lock_counter = convert(0, re['Buffer']['Lockout']['LockoutObservationWindow'], lockout=True)
        self.__lock_accnt_dur = convert(0, re['Buffer']['Lockout']['LockoutDuration'], lockout=True)
        self.__accnt_lock_thres = re['Buffer']['Lockout']['LockoutThreshold'] or "None"

        re = samr.hSamrQueryInformationDomain2(dce, domainHandle=domainHandle,
                                               domainInformationClass=samr.DOMAIN_INFORMATION_CLASS.DomainLogoffInformation)
        self.__force_logoff_time = convert(re['Buffer']['Logoff']['ForceLogoff']['LowPart'], re['Buffer']['Logoff']['ForceLogoff']['HighPart'])

        self.pass_pol = {'min_pass_len': self.__min_pass_len, 'pass_hist_len': self.__pass_hist_len, 
                         'max_pass_age': self.__max_pass_age, 'min_pass_age': self.__min_pass_age, 
                         'pass_prop': self.__pass_prop, 'rst_accnt_lock_counter': self.__rst_accnt_lock_counter,
                         'lock_accnt_dur': self.__lock_accnt_dur, 'accnt_lock_thres': self.__accnt_lock_thres,
                         'force_logoff_time': self.__force_logoff_time} 
開發者ID:byt3bl33d3r,項目名稱:CrackMapExec,代碼行數:56,代碼來源:passpol.py

示例3: enumerate_password_policy

# 需要導入模塊: from impacket.dcerpc.v5 import samr [as 別名]
# 或者: from impacket.dcerpc.v5.samr import hSamrQueryInformationDomain2 [as 別名]
def enumerate_password_policy(self, dce, domain_handle):
		# This method is a refactored and cleaned up version of polenum.py. I had a hard time finding the true
		# author of polenum.py to give credit.. Give me a shout if you're out there!
		domain_passwd = samr.DOMAIN_INFORMATION_CLASS.DomainPasswordInformation
		resp = samr.hSamrQueryInformationDomain2(dce, domainHandle=domain_handle, domainInformationClass=domain_passwd)
		policy = resp['Buffer']['Password']
		minimum_len = policy['MinPasswordLength'] or "None"
		history = policy['PasswordHistoryLength'] or "None"
		maximum_age = self.convert_policy(int(policy['MaxPasswordAge']['LowPart']), int(policy['MaxPasswordAge']['HighPart']))
		minimum_pass_age = self.convert_policy(int(policy['MinPasswordAge']['LowPart']), int(policy['MinPasswordAge']['HighPart']))
		password_props = policy['PasswordProperties']

		complexity_binary = []
		while password_props:
			complexity_binary.append(password_props % 2)
			password_props /= 2

		com_binary = complexity_binary[::-1]
		if len(com_binary) != 8:
			for x in xrange(6 - len(com_binary)):
				com_binary.insert(0, 0)
		password_props = ''.join([str(value) for value in com_binary])

		domain_lockout = samr.DOMAIN_INFORMATION_CLASS.DomainLockoutInformation
		resp = samr.hSamrQueryInformationDomain2(dce, domainHandle=domain_handle, domainInformationClass=domain_lockout)
		lockout = resp['Buffer']['Lockout']
		lockout_observation = self.convert_policy(0, lockout['LockoutObservationWindow'], lockout=True)
		lockout_duration = self.convert_policy(0, lockout['LockoutDuration'], lockout=True)
		lockout_threshold = lockout['LockoutThreshold'] or "None"

		domain_logoff = samr.DOMAIN_INFORMATION_CLASS.DomainLogoffInformation
		resp = samr.hSamrQueryInformationDomain2(dce, domainHandle=domain_handle, domainInformationClass=domain_logoff)
		logoff = resp['Buffer']['Logoff']['ForceLogoff']
		logoff_time = self.convert_policy(logoff['LowPart'], logoff['HighPart'])

		domain_complexity = {
			5: 'Domain Password Complex:',
			4: 'Domain Password No Anon Change:',
			3: 'Domain Password No Clear Change:',
			2: 'Domain Password Lockout Admins:',
			1: 'Domain Password Store Cleartext:',
			0: 'Domain Refuse Password Change:'
		}

		self.log.info("\n\t[+] Minimum password length: {0}".format(minimum_len))
		self.log.info("\t[+] Password history length: {0}".format(history))
		self.log.info("\t[+] Maximum password age: {0}".format(maximum_age))
		self.log.info("\t[+] Password Complexity Flags: {0}\n".format(password_props or "None"))

		for i, a in enumerate(password_props):
			self.log.info("\t\t[+] {0} {1}".format(domain_complexity[i], str(a)))

		self.log.info("\n\t[+] Minimum password age: {0}".format(minimum_pass_age))
		self.log.info("\t[+] Reset Account Lockout Counter: {0}".format(lockout_observation))
		self.log.info("\t[+] Locked Account Duration: {0}".format(lockout_duration))
		self.log.info("\t[+] Account Lockout Threshold: {0}".format(lockout_threshold))
		self.log.info("\t[+] Forced Log off Time: {0}\n".format(logoff_time)) 
開發者ID:Gilks,項目名稱:enumerid,代碼行數:59,代碼來源:enumerid.py


注:本文中的impacket.dcerpc.v5.samr.hSamrQueryInformationDomain2方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。