本文整理汇总了Python中impacket.dcerpc.v5.dtypes.RPC_SID属性的典型用法代码示例。如果您正苦于以下问题:Python dtypes.RPC_SID属性的具体用法?Python dtypes.RPC_SID怎么用?Python dtypes.RPC_SID使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类impacket.dcerpc.v5.dtypes
的用法示例。
在下文中一共展示了dtypes.RPC_SID属性的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_hSamrOpenDomain
# 需要导入模块: from impacket.dcerpc.v5 import dtypes [as 别名]
# 或者: from impacket.dcerpc.v5.dtypes import RPC_SID [as 别名]
def test_hSamrOpenDomain(self):
dce, rpctransport, domainHandle = self.connect()
resp = samr.hSamrConnect(dce)
SID = 'S-1-5-352321536-2562177771-1589929855-2033349547'
sid = dtypes.RPC_SID()
sid.fromCanonical(SID)
try:
resp = samr.hSamrOpenDomain(dce, serverHandle = resp['ServerHandle'], domainId = sid)
resp.dump()
except Exception, e:
if str(e).find('STATUS_NO_SUCH_DOMAIN') < 0:
raise
示例2: test_SamrAddMemberToAlias_SamrRemoveMemberFromAlias
# 需要导入模块: from impacket.dcerpc.v5 import dtypes [as 别名]
# 或者: from impacket.dcerpc.v5.dtypes import RPC_SID [as 别名]
def test_SamrAddMemberToAlias_SamrRemoveMemberFromAlias(self):
dce, rpctransport, domainHandle = self.connect()
request = samr.SamrCreateAliasInDomain()
request['DomainHandle'] = domainHandle
request['AccountName'] = 'testGroup'
request['DesiredAccess'] = samr.GROUP_ALL_ACCESS | samr.DELETE
#request.dump()
resp = dce.request(request)
aliasHandle = resp['AliasHandle']
relativeId = resp['RelativeId']
resp.dump()
request = samr.SamrRidToSid()
request['ObjectHandle'] = domainHandle
request['Rid'] = relativeId
resp3 = dce.request(request)
resp3.dump()
# Let's extract the SID and remove the RID from one entry
sp = resp3['Sid'].formatCanonical()
domainID = '-'.join(sp.split('-')[:-1])
adminSID = domainID + '-%d' % samr.DOMAIN_USER_RID_ADMIN
sid = samr.RPC_SID()
sid.fromCanonical(adminSID)
request = samr.SamrAddMemberToAlias()
request['AliasHandle'] = aliasHandle
request['MemberId'] = sid
resp2 = dce.request(request)
resp2.dump()
request = samr.SamrRemoveMemberFromAlias()
request['AliasHandle'] = aliasHandle
request['MemberId'] = sid
resp2 = dce.request(request)
resp2.dump()
request = samr.SamrDeleteAlias()
request['AliasHandle'] = aliasHandle
resp = dce.request(request)
示例3: test_hSamrAddMemberToAlias_hSamrRemoveMemberFromAlias
# 需要导入模块: from impacket.dcerpc.v5 import dtypes [as 别名]
# 或者: from impacket.dcerpc.v5.dtypes import RPC_SID [as 别名]
def test_hSamrAddMemberToAlias_hSamrRemoveMemberFromAlias(self):
dce, rpctransport, domainHandle = self.connect()
resp = samr.hSamrCreateAliasInDomain(dce, domainHandle, 'testGroup', samr.GROUP_ALL_ACCESS | samr.DELETE)
resp.dump()
aliasHandle = resp['AliasHandle']
relativeId = resp['RelativeId']
resp.dump()
request = samr.SamrRidToSid()
request['ObjectHandle'] = domainHandle
request['Rid'] = relativeId
resp3 = dce.request(request)
resp3.dump()
# Let's extract the SID and remove the RID from one entry
sp = resp3['Sid'].formatCanonical()
domainID = '-'.join(sp.split('-')[:-1])
adminSID = domainID + '-%d' % samr.DOMAIN_USER_RID_ADMIN
sid = samr.RPC_SID()
sid.fromCanonical(adminSID)
resp2 = samr.hSamrAddMemberToAlias(dce, aliasHandle, sid)
resp2.dump()
resp2 = samr.hSamrRemoveMemberFromAlias(dce, aliasHandle, sid)
resp2.dump()
resp = samr.hSamrDeleteAlias(dce, aliasHandle)
resp.dump()
示例4: test_hSamrRemoveMemberFromForeignDomain
# 需要导入模块: from impacket.dcerpc.v5 import dtypes [as 别名]
# 或者: from impacket.dcerpc.v5.dtypes import RPC_SID [as 别名]
def test_hSamrRemoveMemberFromForeignDomain(self):
dce, rpctransport, domainHandle = self.connect()
request = samr.SamrCreateAliasInDomain()
request['DomainHandle'] = domainHandle
request['AccountName'] = 'testGroup'
request['DesiredAccess'] = samr.GROUP_ALL_ACCESS | samr.DELETE
#request.dump()
resp = dce.request(request)
aliasHandle = resp['AliasHandle']
relativeId = resp['RelativeId']
resp.dump()
request = samr.SamrRidToSid()
request['ObjectHandle'] = domainHandle
request['Rid'] = relativeId
resp3 = dce.request(request)
resp3.dump()
# Let's extract the SID and remove the RID from one entry
sp = resp3['Sid'].formatCanonical()
domainID = '-'.join(sp.split('-')[:-1])
adminSID = domainID + '-%d' % samr.DOMAIN_USER_RID_ADMIN
sid = samr.RPC_SID()
sid.fromCanonical(adminSID)
try:
resp= samr.hSamrRemoveMemberFromForeignDomain(dce, domainHandle, sid)
resp = dce.request(request)
resp.dump()
except Exception, e:
if str(e).find('STATUS_SPECIAL_ACCOUNT') < 0:
raise
示例5: dump
# 需要导入模块: from impacket.dcerpc.v5 import dtypes [as 别名]
# 或者: from impacket.dcerpc.v5.dtypes import RPC_SID [as 别名]
def dump(self):
print("[WINDOWS BIOMETRIC KEY]")
print('Sid : %s' % RPC_SID(b'\x05\x00\x00\x00'+self['Sid']).formatCanonical())
print('Friendly Name: %s' % self['Name'].decode('utf-16le'))
print('Biometric Key: 0x%s' % (hexlify(self['BioKey']['bKey'])).decode('latin-1'))
print()
示例6: test_hSamrOpenDomain
# 需要导入模块: from impacket.dcerpc.v5 import dtypes [as 别名]
# 或者: from impacket.dcerpc.v5.dtypes import RPC_SID [as 别名]
def test_hSamrOpenDomain(self):
dce, rpctransport, domainHandle = self.connect()
resp = samr.hSamrConnect(dce)
SID = 'S-1-5-352321536-2562177771-1589929855-2033349547'
sid = dtypes.RPC_SID()
sid.fromCanonical(SID)
try:
resp = samr.hSamrOpenDomain(dce, serverHandle = resp['ServerHandle'], domainId = sid)
resp.dump()
except Exception as e:
if str(e).find('STATUS_NO_SUCH_DOMAIN') < 0:
raise
示例7: test_SamrAddMemberToAlias_SamrRemoveMemberFromAlias
# 需要导入模块: from impacket.dcerpc.v5 import dtypes [as 别名]
# 或者: from impacket.dcerpc.v5.dtypes import RPC_SID [as 别名]
def test_SamrAddMemberToAlias_SamrRemoveMemberFromAlias(self):
dce, rpctransport, domainHandle = self.connect()
request = samr.SamrCreateAliasInDomain()
request['DomainHandle'] = domainHandle
request['AccountName'] = 'testGroup'
request['DesiredAccess'] = samr.GROUP_ALL_ACCESS | samr.DELETE
#request.dump()
resp = dce.request(request)
aliasHandle = resp['AliasHandle']
relativeId = resp['RelativeId']
resp.dump()
request = samr.SamrRidToSid()
request['ObjectHandle'] = domainHandle
request['Rid'] = relativeId
resp3 = dce.request(request)
resp3.dump()
# Let's extract the SID and remove the RID from one entry
sp = resp3['Sid'].formatCanonical()
domainID = '-'.join(sp.split('-')[:-1])
adminSID = domainID + '-%d' % samr.DOMAIN_USER_RID_ADMIN
sid = samr.RPC_SID()
sid.fromCanonical(adminSID)
request = samr.SamrAddMemberToAlias()
request['AliasHandle'] = aliasHandle
request['MemberId'] = sid
resp2 = dce.request(request)
resp2.dump()
request = samr.SamrRemoveMemberFromAlias()
request['AliasHandle'] = aliasHandle
request['MemberId'] = sid
resp2 = dce.request(request)
resp2.dump()
request = samr.SamrDeleteAlias()
request['AliasHandle'] = aliasHandle
dce.request(request)
示例8: test_hSamrRemoveMemberFromForeignDomain
# 需要导入模块: from impacket.dcerpc.v5 import dtypes [as 别名]
# 或者: from impacket.dcerpc.v5.dtypes import RPC_SID [as 别名]
def test_hSamrRemoveMemberFromForeignDomain(self):
dce, rpctransport, domainHandle = self.connect()
request = samr.SamrCreateAliasInDomain()
request['DomainHandle'] = domainHandle
request['AccountName'] = 'testGroup'
request['DesiredAccess'] = samr.GROUP_ALL_ACCESS | samr.DELETE
#request.dump()
resp = dce.request(request)
aliasHandle = resp['AliasHandle']
relativeId = resp['RelativeId']
resp.dump()
request = samr.SamrRidToSid()
request['ObjectHandle'] = domainHandle
request['Rid'] = relativeId
resp3 = dce.request(request)
resp3.dump()
# Let's extract the SID and remove the RID from one entry
sp = resp3['Sid'].formatCanonical()
domainID = '-'.join(sp.split('-')[:-1])
adminSID = domainID + '-%d' % samr.DOMAIN_USER_RID_ADMIN
sid = samr.RPC_SID()
sid.fromCanonical(adminSID)
try:
resp= samr.hSamrRemoveMemberFromForeignDomain(dce, domainHandle, sid)
resp = dce.request(request)
resp.dump()
except Exception as e:
if str(e).find('STATUS_SPECIAL_ACCOUNT') < 0:
raise
request = samr.SamrDeleteAlias()
request['AliasHandle'] = aliasHandle
dce.request(request)
示例9: test_hSamrAddMultipleMembersToAlias_hSamrRemoveMultipleMembersFromAliass
# 需要导入模块: from impacket.dcerpc.v5 import dtypes [as 别名]
# 或者: from impacket.dcerpc.v5.dtypes import RPC_SID [as 别名]
def test_hSamrAddMultipleMembersToAlias_hSamrRemoveMultipleMembersFromAliass(self):
dce, rpctransport, domainHandle = self.connect()
#resp = samr.hSamrEnumerateAliasesInDomain(dce, domainHandle)
#resp = samr.hSamrOpenAlias(dce, domainHandle, samr.DELETE, 1257)
#resp = samr.hSamrDeleteAlias(dce, resp['AliasHandle'])
resp = samr.hSamrCreateAliasInDomain(dce, domainHandle, 'testGroup', samr.GROUP_ALL_ACCESS | samr.DELETE)
aliasHandle = resp['AliasHandle']
relativeId = resp['RelativeId']
resp.dump()
request = samr.SamrRidToSid()
request['ObjectHandle'] = domainHandle
request['Rid'] = relativeId
resp3 = dce.request(request)
resp3.dump()
# Let's extract the SID and remove the RID from one entry
sp = resp3['Sid'].formatCanonical()
domainID = '-'.join(sp.split('-')[:-1])
adminSID = domainID + '-%d' % samr.DOMAIN_USER_RID_ADMIN
sid = samr.RPC_SID()
sid.fromCanonical(adminSID)
sid = samr.RPC_SID()
sid.fromCanonical(adminSID)
guestSID = domainID + '-%d' % samr.DOMAIN_USER_RID_GUEST
sid1 = samr.RPC_SID()
sid1.fromCanonical(adminSID)
sid2 = samr.RPC_SID()
sid2.fromCanonical(guestSID)
si = samr.PSAMPR_SID_INFORMATION()
si['SidPointer'] = sid1
si2 = samr.PSAMPR_SID_INFORMATION()
si2['SidPointer'] = sid2
sidArray = samr.SAMPR_PSID_ARRAY()
sidArray['Sids'].append(si)
sidArray['Sids'].append(si2)
resp = samr.hSamrAddMultipleMembersToAlias(dce, aliasHandle, sidArray)
resp.dump()
resp = samr.hSamrRemoveMultipleMembersFromAlias(dce, aliasHandle, sidArray)
resp.dump()
request = samr.SamrDeleteAlias()
request['AliasHandle'] = aliasHandle
resp = dce.request(request)
示例10: test_hSamrGetAliasMembership
# 需要导入模块: from impacket.dcerpc.v5 import dtypes [as 别名]
# 或者: from impacket.dcerpc.v5.dtypes import RPC_SID [as 别名]
def test_hSamrGetAliasMembership(self):
dce, rpctransport, domainHandle = self.connect()
#resp = samr.hSamrEnumerateAliasesInDomain(dce, domainHandle)
#resp = samr.hSamrOpenAlias(dce, domainHandle, samr.DELETE, 1268)
#resp = samr.hSamrDeleteAlias(dce, resp['AliasHandle'])
request = samr.SamrCreateAliasInDomain()
request['DomainHandle'] = domainHandle
request['AccountName'] = 'testGroup'
request['DesiredAccess'] = samr.GROUP_ALL_ACCESS | samr.DELETE
#request.dump()
resp = dce.request(request)
aliasHandle = resp['AliasHandle']
relativeId = resp['RelativeId']
resp.dump()
request = samr.SamrRidToSid()
request['ObjectHandle'] = domainHandle
request['Rid'] = relativeId
resp3 = dce.request(request)
resp3.dump()
# Let's extract the SID and remove the RID from one entry
sp = resp3['Sid'].formatCanonical()
domainID = '-'.join(sp.split('-')[:-1])
adminSID = domainID + '-%d' % samr.DOMAIN_USER_RID_ADMIN
sid = samr.RPC_SID()
sid.fromCanonical(adminSID)
guestSID = domainID + '-%d' % samr.DOMAIN_USER_RID_GUEST
sid1 = samr.RPC_SID()
sid1.fromCanonical(adminSID)
sid2 = samr.RPC_SID()
sid2.fromCanonical(guestSID)
si = samr.PSAMPR_SID_INFORMATION()
si['SidPointer'] = sid1
si2 = samr.PSAMPR_SID_INFORMATION()
si2['SidPointer'] = sid2
sidsArray = samr.SAMPR_PSID_ARRAY()
sidsArray['Sids'].append(si)
sidsArray['Sids'].append(si2)
try:
resp = samr.hSamrGetAliasMembership(dce, domainHandle, sidsArray)
resp.dump()
except Exception, e:
request = samr.SamrDeleteAlias()
request['AliasHandle'] = aliasHandle
resp = dce.request(request)
raise
示例11: test_SamrGetAliasMembership
# 需要导入模块: from impacket.dcerpc.v5 import dtypes [as 别名]
# 或者: from impacket.dcerpc.v5.dtypes import RPC_SID [as 别名]
def test_SamrGetAliasMembership(self):
dce, rpctransport, domainHandle = self.connect()
request = samr.SamrCreateAliasInDomain()
request['DomainHandle'] = domainHandle
request['AccountName'] = 'testGroup'
request['DesiredAccess'] = samr.GROUP_ALL_ACCESS | samr.DELETE
#request.dump()
resp = dce.request(request)
aliasHandle = resp['AliasHandle']
relativeId = resp['RelativeId']
resp.dump()
request = samr.SamrRidToSid()
request['ObjectHandle'] = domainHandle
request['Rid'] = relativeId
resp3 = dce.request(request)
resp3.dump()
# Let's extract the SID and remove the RID from one entry
sp = resp3['Sid'].formatCanonical()
domainID = '-'.join(sp.split('-')[:-1])
adminSID = domainID + '-%d' % samr.DOMAIN_USER_RID_ADMIN
sid = samr.RPC_SID()
sid.fromCanonical(adminSID)
guestSID = domainID + '-%d' % samr.DOMAIN_USER_RID_GUEST
sid1 = samr.RPC_SID()
sid1.fromCanonical(adminSID)
sid2 = samr.RPC_SID()
sid2.fromCanonical(guestSID)
si = samr.PSAMPR_SID_INFORMATION()
si['SidPointer'] = sid1
si2 = samr.PSAMPR_SID_INFORMATION()
si2['SidPointer'] = sid2
request = samr.SamrGetAliasMembership()
request['DomainHandle'] = domainHandle
request['SidArray']['Count'] = 2
request['SidArray']['Sids'].append(si)
request['SidArray']['Sids'].append(si2)
resp = dce.request(request)
resp.dump()
request = samr.SamrDeleteAlias()
request['AliasHandle'] = aliasHandle
dce.request(request)
示例12: test_hSamrGetAliasMembership
# 需要导入模块: from impacket.dcerpc.v5 import dtypes [as 别名]
# 或者: from impacket.dcerpc.v5.dtypes import RPC_SID [as 别名]
def test_hSamrGetAliasMembership(self):
dce, rpctransport, domainHandle = self.connect()
#resp = samr.hSamrEnumerateAliasesInDomain(dce, domainHandle)
#resp = samr.hSamrOpenAlias(dce, domainHandle, samr.DELETE, 1268)
#resp = samr.hSamrDeleteAlias(dce, resp['AliasHandle'])
request = samr.SamrCreateAliasInDomain()
request['DomainHandle'] = domainHandle
request['AccountName'] = 'testGroup'
request['DesiredAccess'] = samr.GROUP_ALL_ACCESS | samr.DELETE
#request.dump()
resp = dce.request(request)
aliasHandle = resp['AliasHandle']
relativeId = resp['RelativeId']
resp.dump()
request = samr.SamrRidToSid()
request['ObjectHandle'] = domainHandle
request['Rid'] = relativeId
resp3 = dce.request(request)
resp3.dump()
# Let's extract the SID and remove the RID from one entry
sp = resp3['Sid'].formatCanonical()
domainID = '-'.join(sp.split('-')[:-1])
adminSID = domainID + '-%d' % samr.DOMAIN_USER_RID_ADMIN
sid = samr.RPC_SID()
sid.fromCanonical(adminSID)
guestSID = domainID + '-%d' % samr.DOMAIN_USER_RID_GUEST
sid1 = samr.RPC_SID()
sid1.fromCanonical(adminSID)
sid2 = samr.RPC_SID()
sid2.fromCanonical(guestSID)
si = samr.PSAMPR_SID_INFORMATION()
si['SidPointer'] = sid1
si2 = samr.PSAMPR_SID_INFORMATION()
si2['SidPointer'] = sid2
sidsArray = samr.SAMPR_PSID_ARRAY()
sidsArray['Sids'].append(si)
sidsArray['Sids'].append(si2)
try:
resp = samr.hSamrGetAliasMembership(dce, domainHandle, sidsArray)
resp.dump()
except Exception as e:
request = samr.SamrDeleteAlias()
request['AliasHandle'] = aliasHandle
dce.request(request)
raise
request = samr.SamrDeleteAlias()
request['AliasHandle'] = aliasHandle
dce.request(request)