本文整理汇总了Python中impacket.dcerpc.v5.lsad.hLsarOpenPolicy2方法的典型用法代码示例。如果您正苦于以下问题:Python lsad.hLsarOpenPolicy2方法的具体用法?Python lsad.hLsarOpenPolicy2怎么用?Python lsad.hLsarOpenPolicy2使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类impacket.dcerpc.v5.lsad
的用法示例。
在下文中一共展示了lsad.hLsarOpenPolicy2方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: connect
# 需要导入模块: from impacket.dcerpc.v5 import lsad [as 别名]
# 或者: from impacket.dcerpc.v5.lsad import hLsarOpenPolicy2 [as 别名]
def connect(self):
rpctransport = transport.DCERPCTransportFactory(self.stringBinding)
if len(self.hashes) > 0:
lmhash, nthash = self.hashes.split(':')
else:
lmhash = ''
nthash = ''
if hasattr(rpctransport, 'set_credentials'):
# This method exists only for selected protocol sequences.
rpctransport.set_credentials(self.username,self.password, self.domain, lmhash, nthash)
dce = rpctransport.get_dce_rpc()
dce.connect()
dce.bind(lsad.MSRPC_UUID_LSAD, transfer_syntax = self.ts)
resp = lsad.hLsarOpenPolicy2(dce, MAXIMUM_ALLOWED | lsad.POLICY_CREATE_SECRET | DELETE | lsad.POLICY_VIEW_LOCAL_INFORMATION)
return dce, rpctransport, resp['PolicyHandle']
示例2: get_sid
# 需要导入模块: from impacket.dcerpc.v5 import lsad [as 别名]
# 或者: from impacket.dcerpc.v5.lsad import hLsarOpenPolicy2 [as 别名]
def get_sid(self, name):
self.log.info('[*] Looking up SID for {0}..'.format(name))
stringbinding = r'ncacn_np:{0}[\pipe\lsarpc]'.format(self.target)
logging.debug('StringBinding {0}'.format(stringbinding))
rpctransport = transport.DCERPCTransportFactory(stringbinding)
rpctransport.set_dport(self.port)
rpctransport.setRemoteHost(self.target)
if hasattr(rpctransport, 'set_credentials'):
rpctransport.set_credentials(self.username, self.password, self.domain)
dce = rpctransport.get_dce_rpc()
dce.connect()
dce.bind(lsat.MSRPC_UUID_LSAT)
resp = lsad.hLsarOpenPolicy2(dce, MAXIMUM_ALLOWED | lsad.POLICY_LOOKUP_NAMES)
policyHandle = resp['PolicyHandle']
resp = lsat.hLsarLookupNames(dce, policyHandle, (name,))
self.rid = resp['TranslatedSids']['Sids'][0]['RelativeId']
dce.disconnect()
return
示例3: __resolveSids
# 需要导入模块: from impacket.dcerpc.v5 import lsad [as 别名]
# 或者: from impacket.dcerpc.v5.lsad import hLsarOpenPolicy2 [as 别名]
def __resolveSids(self, sids):
dce = self.__getDceBinding(self.__lsaBinding)
dce.connect()
dce.bind(lsat.MSRPC_UUID_LSAT)
resp = lsad.hLsarOpenPolicy2(dce, MAXIMUM_ALLOWED | lsat.POLICY_LOOKUP_NAMES)
policyHandle = resp['PolicyHandle']
resp = lsat.hLsarLookupSids(dce, policyHandle, sids, lsat.LSAP_LOOKUP_LEVEL.LsapLookupWksta)
names = []
for n, item in enumerate(resp['TranslatedNames']['Names']):
names.append("{}\\{}".format(resp['ReferencedDomains']['Domains'][item['DomainIndex']]['Name'].encode('utf-16-le'), item['Name']))
dce.disconnect()
return names