本文整理汇总了Python中impacket.dcerpc.v5.samr.hSamrLookupNamesInDomain方法的典型用法代码示例。如果您正苦于以下问题:Python samr.hSamrLookupNamesInDomain方法的具体用法?Python samr.hSamrLookupNamesInDomain怎么用?Python samr.hSamrLookupNamesInDomain使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类impacket.dcerpc.v5.samr
的用法示例。
在下文中一共展示了samr.hSamrLookupNamesInDomain方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_hSamrSetSecurityObject
# 需要导入模块: from impacket.dcerpc.v5 import samr [as 别名]
# 或者: from impacket.dcerpc.v5.samr import hSamrLookupNamesInDomain [as 别名]
def test_hSamrSetSecurityObject(self):
dce, rpctransport, domainHandle = self.connect()
dce, rpctransport, domainHandle = self.connect()
resp = samr.hSamrLookupNamesInDomain(dce, domainHandle, (self.username,))
resp.dump()
resp = samr.hSamrOpenUser(dce, domainHandle, samr.USER_ALL_ACCESS | samr.USER_READ_GROUP_INFORMATION | samr.USER_WRITE_GROUP_INFORMATION, resp['RelativeIds']['Element'][0]['Data'])
resp.dump()
userHandle = resp['UserHandle']
resp = samr.hSamrQuerySecurityObject(dce, userHandle, dtypes.GROUP_SECURITY_INFORMATION)
resp.dump()
try:
resp = samr.hSamrSetSecurityObject(dce, userHandle,dtypes.GROUP_SECURITY_INFORMATION ,resp['SecurityDescriptor'] )
resp.dump()
except Exception, e:
if str(e).find('STATUS_BAD_DESCRIPTOR_FORMAT') <= 0:
raise
示例2: getUserSID
# 需要导入模块: from impacket.dcerpc.v5 import samr [as 别名]
# 或者: from impacket.dcerpc.v5.samr import hSamrLookupNamesInDomain [as 别名]
def getUserSID(self):
stringBinding = r'ncacn_np:%s[\pipe\samr]' % self.__kdcHost
rpctransport = transport.DCERPCTransportFactory(stringBinding)
if hasattr(rpctransport, 'set_credentials'):
rpctransport.set_credentials(self.__username,self.__password, self.__domain, self.__lmhash, self.__nthash)
dce = rpctransport.get_dce_rpc()
dce.connect()
dce.bind(samr.MSRPC_UUID_SAMR)
resp = samr.hSamrConnect(dce)
serverHandle = resp['ServerHandle']
resp = samr.hSamrLookupDomainInSamServer(dce, serverHandle, self.__domain)
domainId = resp['DomainId']
resp = samr.hSamrOpenDomain(dce, serverHandle, domainId = domainId)
domainHandle = resp['DomainHandle']
resp = samr.hSamrLookupNamesInDomain(dce, domainHandle, (self.__username,))
# Let's pick the relative ID
rid = resp['RelativeIds']['Element'][0]['Data']
logging.info("User SID: %s-%s"% (domainId.formatCanonical(), rid))
return domainId, rid
示例3: test_hSamrSetSecurityObject
# 需要导入模块: from impacket.dcerpc.v5 import samr [as 别名]
# 或者: from impacket.dcerpc.v5.samr import hSamrLookupNamesInDomain [as 别名]
def test_hSamrSetSecurityObject(self):
dce, rpctransport, domainHandle = self.connect()
dce, rpctransport, domainHandle = self.connect()
resp = samr.hSamrLookupNamesInDomain(dce, domainHandle, (self.username,))
resp.dump()
resp = samr.hSamrOpenUser(dce, domainHandle, samr.USER_ALL_ACCESS | samr.USER_READ_GROUP_INFORMATION | samr.USER_WRITE_GROUP_INFORMATION, resp['RelativeIds']['Element'][0]['Data'])
resp.dump()
userHandle = resp['UserHandle']
resp = samr.hSamrQuerySecurityObject(dce, userHandle, dtypes.GROUP_SECURITY_INFORMATION)
resp.dump()
try:
resp = samr.hSamrSetSecurityObject(dce, userHandle,dtypes.GROUP_SECURITY_INFORMATION ,resp['SecurityDescriptor'] )
resp.dump()
except Exception as e:
if str(e).find('STATUS_BAD_DESCRIPTOR_FORMAT') <= 0:
raise
resp = samr.hSamrCloseHandle(dce, userHandle)
resp.dump()
示例4: test_hSamrLookupNamesInDomain
# 需要导入模块: from impacket.dcerpc.v5 import samr [as 别名]
# 或者: from impacket.dcerpc.v5.samr import hSamrLookupNamesInDomain [as 别名]
def test_hSamrLookupNamesInDomain(self):
dce, rpctransport, domainHandle = self.connect()
resp = samr.hSamrLookupNamesInDomain(dce, domainHandle, ('Administrator','Guest'))
resp.dump()
示例5: test_SamrSetSecurityObject
# 需要导入模块: from impacket.dcerpc.v5 import samr [as 别名]
# 或者: from impacket.dcerpc.v5.samr import hSamrLookupNamesInDomain [as 别名]
def test_SamrSetSecurityObject(self):
dce, rpctransport, domainHandle = self.connect()
resp = samr.hSamrLookupNamesInDomain(dce, domainHandle, (self.username,))
resp.dump()
resp = samr.hSamrOpenUser(dce, domainHandle, samr.USER_ALL_ACCESS | samr.USER_READ_GROUP_INFORMATION | samr.USER_WRITE_GROUP_INFORMATION, resp['RelativeIds']['Element'][0]['Data'])
resp.dump()
userHandle = resp['UserHandle']
request = samr.SamrQuerySecurityObject()
request['ObjectHandle'] = userHandle
request['SecurityInformation'] = dtypes.GROUP_SECURITY_INFORMATION
resp = dce.request(request)
resp.dump()
request = samr.SamrSetSecurityObject()
request['ObjectHandle'] = userHandle
request['SecurityInformation'] = dtypes.GROUP_SECURITY_INFORMATION
request['SecurityDescriptor'] = resp['SecurityDescriptor']
#request.dump()
try:
resp = dce.request(request)
resp.dump()
except Exception, e:
if str(e).find('STATUS_BAD_DESCRIPTOR_FORMAT') <= 0:
raise
示例6: test_hSamrLookupNamesInDomain
# 需要导入模块: from impacket.dcerpc.v5 import samr [as 别名]
# 或者: from impacket.dcerpc.v5.samr import hSamrLookupNamesInDomain [as 别名]
def test_hSamrLookupNamesInDomain(self):
dce, rpctransport, domainHandle = self.connect()
try:
resp = samr.hSamrLookupNamesInDomain(dce, domainHandle, ('Administrator','Guest'))
resp.dump()
except Exception, e:
if str(e).find('STATUS_MORE_ENTRIES') >=0:
pass
e.get_packet().dump()
示例7: test_hSamrLookupNamesInDomain
# 需要导入模块: from impacket.dcerpc.v5 import samr [as 别名]
# 或者: from impacket.dcerpc.v5.samr import hSamrLookupNamesInDomain [as 别名]
def test_hSamrLookupNamesInDomain(self):
dce, rpctransport, domainHandle = self.connect()
try:
resp = samr.hSamrLookupNamesInDomain(dce, domainHandle, ('Administrator','Guest'))
resp.dump()
except Exception as e:
if str(e).find('STATUS_MORE_ENTRIES') >=0:
pass
e.get_packet().dump()
示例8: test_SamrSetSecurityObject
# 需要导入模块: from impacket.dcerpc.v5 import samr [as 别名]
# 或者: from impacket.dcerpc.v5.samr import hSamrLookupNamesInDomain [as 别名]
def test_SamrSetSecurityObject(self):
dce, rpctransport, domainHandle = self.connect()
resp = samr.hSamrLookupNamesInDomain(dce, domainHandle, (self.username,))
resp.dump()
resp = samr.hSamrOpenUser(dce, domainHandle, samr.USER_ALL_ACCESS | samr.USER_READ_GROUP_INFORMATION | samr.USER_WRITE_GROUP_INFORMATION, resp['RelativeIds']['Element'][0]['Data'])
resp.dump()
userHandle = resp['UserHandle']
request = samr.SamrQuerySecurityObject()
request['ObjectHandle'] = userHandle
request['SecurityInformation'] = dtypes.GROUP_SECURITY_INFORMATION
resp = dce.request(request)
resp.dump()
request = samr.SamrSetSecurityObject()
request['ObjectHandle'] = userHandle
request['SecurityInformation'] = dtypes.GROUP_SECURITY_INFORMATION
request['SecurityDescriptor'] = resp['SecurityDescriptor']
#request.dump()
try:
resp = dce.request(request)
resp.dump()
except Exception as e:
if str(e).find('STATUS_BAD_DESCRIPTOR_FORMAT') <= 0:
raise
resp = samr.hSamrCloseHandle(dce, userHandle)
resp.dump()