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


Python samr.hSamrLookupNamesInDomain方法代碼示例

本文整理匯總了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 
開發者ID:joxeankoret,項目名稱:CVE-2017-7494,代碼行數:21,代碼來源:test_samr.py

示例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 
開發者ID:Coalfire-Research,項目名稱:Slackor,代碼行數:24,代碼來源:goldenPac.py

示例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() 
開發者ID:Coalfire-Research,項目名稱:Slackor,代碼行數:24,代碼來源:test_samr.py

示例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() 
開發者ID:joxeankoret,項目名稱:CVE-2017-7494,代碼行數:6,代碼來源:test_samr.py

示例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 
開發者ID:joxeankoret,項目名稱:CVE-2017-7494,代碼行數:28,代碼來源:test_samr.py

示例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() 
開發者ID:eth0izzle,項目名稱:cracke-dit,代碼行數:11,代碼來源:test_samr.py

示例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() 
開發者ID:Coalfire-Research,項目名稱:Slackor,代碼行數:11,代碼來源:test_samr.py

示例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() 
開發者ID:Coalfire-Research,項目名稱:Slackor,代碼行數:31,代碼來源:test_samr.py


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