Python impacket.dcerpc.v5.lsat.hLsarLookupNames() Examples

The following are 13 code examples of impacket.dcerpc.v5.lsat.hLsarLookupNames(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module impacket.dcerpc.v5.lsat , or try the search function .
Example #1
Source File: test_lsat.py    From CVE-2017-7494 with GNU General Public License v3.0 6 votes vote down vote up
def test_hLsarLookupSids(self):
        dce, rpctransport, policyHandle = self.connect()

        resp = lsat.hLsarLookupNames(dce, policyHandle, ('Administrator',))
        resp.dump()
        domainSid = resp['ReferencedDomains']['Domains'][0]['Sid'].formatCanonical()

        sids = list()
        for i in range(1000):
            sids.append(domainSid + '-%d' % (500+i))
        try:
            resp = lsat.hLsarLookupSids(dce, policyHandle, sids )
            resp.dump()
        except Exception, e:
            if str(e).find('STATUS_SOME_NOT_MAPPED') < 0:
                raise
            else:
                resp = e.get_packet()
                resp.dump() 
Example #2
Source File: test_lsat.py    From cracke-dit with MIT License 6 votes vote down vote up
def test_hLsarLookupSids(self):
        dce, rpctransport, policyHandle = self.connect()

        resp = lsat.hLsarLookupNames(dce, policyHandle, ('Administrator',))
        resp.dump()
        domainSid = resp['ReferencedDomains']['Domains'][0]['Sid'].formatCanonical()

        sids = list()
        for i in range(1000):
            sids.append(domainSid + '-%d' % (500+i))
        try:
            resp = lsat.hLsarLookupSids(dce, policyHandle, sids )
            resp.dump()
        except Exception, e:
            if str(e).find('STATUS_SOME_NOT_MAPPED') < 0:
                raise
            else:
                resp = e.get_packet()
                resp.dump() 
Example #3
Source File: enumerid.py    From enumerid with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
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 
Example #4
Source File: test_lsat.py    From Slackor with GNU General Public License v3.0 6 votes vote down vote up
def test_hLsarLookupSids(self):
        dce, rpctransport, policyHandle = self.connect()

        resp = lsat.hLsarLookupNames(dce, policyHandle, ('Administrator',))
        resp.dump()
        domainSid = resp['ReferencedDomains']['Domains'][0]['Sid'].formatCanonical()

        sids = list()
        for i in range(1000):
            sids.append(domainSid + '-%d' % (500+i))
        try:
            resp = lsat.hLsarLookupSids(dce, policyHandle, sids )
            resp.dump()
        except Exception as e:
            if str(e).find('STATUS_SOME_NOT_MAPPED') < 0:
                raise
            else:
                resp = e.get_packet()
                resp.dump() 
Example #5
Source File: test_lsat.py    From PiBunny with MIT License 6 votes vote down vote up
def test_hLsarLookupSids(self):
        dce, rpctransport, policyHandle = self.connect()

        resp = lsat.hLsarLookupNames(dce, policyHandle, ('Administrator',))
        resp.dump()
        domainSid = resp['ReferencedDomains']['Domains'][0]['Sid'].formatCanonical()

        sids = list()
        for i in range(1000):
            sids.append(domainSid + '-%d' % (500+i))
        try:
            resp = lsat.hLsarLookupSids(dce, policyHandle, sids )
            resp.dump()
        except Exception, e:
            if str(e).find('STATUS_SOME_NOT_MAPPED') < 0:
                raise
            else:
                resp = e.get_packet()
                resp.dump() 
Example #6
Source File: test_lsat.py    From CVE-2017-7494 with GNU General Public License v3.0 5 votes vote down vote up
def test_hLsarLookupNames(self):
        dce, rpctransport, policyHandle = self.connect()

        resp = lsat.hLsarLookupNames(dce, policyHandle, ('Administrator', 'Guest'))
        resp.dump() 
Example #7
Source File: test_lsat.py    From CVE-2017-7494 with GNU General Public License v3.0 5 votes vote down vote up
def test_hLsarLookupSids2(self):
        dce, rpctransport, policyHandle = self.connect()

        resp = lsat.hLsarLookupNames(dce, policyHandle, ('Administrator',))
        resp.dump()
        domainSid = resp['ReferencedDomains']['Domains'][0]['Sid'].formatCanonical()
        sids = list()
        sids.append(domainSid + '-500')
        sids.append(domainSid + '-501')
        resp = lsat.hLsarLookupSids2(dce, policyHandle, sids)
        resp.dump() 
Example #8
Source File: test_lsat.py    From cracke-dit with MIT License 5 votes vote down vote up
def test_hLsarLookupNames(self):
        dce, rpctransport, policyHandle = self.connect()

        resp = lsat.hLsarLookupNames(dce, policyHandle, ('Administrator', 'Guest'))
        resp.dump() 
Example #9
Source File: test_lsat.py    From cracke-dit with MIT License 5 votes vote down vote up
def test_hLsarLookupSids2(self):
        dce, rpctransport, policyHandle = self.connect()

        resp = lsat.hLsarLookupNames(dce, policyHandle, ('Administrator',))
        resp.dump()
        domainSid = resp['ReferencedDomains']['Domains'][0]['Sid'].formatCanonical()
        sids = list()
        sids.append(domainSid + '-500')
        sids.append(domainSid + '-501')
        resp = lsat.hLsarLookupSids2(dce, policyHandle, sids)
        resp.dump() 
Example #10
Source File: test_lsat.py    From Slackor with GNU General Public License v3.0 5 votes vote down vote up
def test_hLsarLookupNames(self):
        dce, rpctransport, policyHandle = self.connect()

        resp = lsat.hLsarLookupNames(dce, policyHandle, ('Administrator', 'Guest'))
        resp.dump() 
Example #11
Source File: test_lsat.py    From Slackor with GNU General Public License v3.0 5 votes vote down vote up
def test_hLsarLookupSids2(self):
        dce, rpctransport, policyHandle = self.connect()

        resp = lsat.hLsarLookupNames(dce, policyHandle, ('Administrator',))
        resp.dump()
        domainSid = resp['ReferencedDomains']['Domains'][0]['Sid'].formatCanonical()
        sids = list()
        sids.append(domainSid + '-500')
        sids.append(domainSid + '-501')
        resp = lsat.hLsarLookupSids2(dce, policyHandle, sids)
        resp.dump() 
Example #12
Source File: test_lsat.py    From PiBunny with MIT License 5 votes vote down vote up
def test_hLsarLookupNames(self):
        dce, rpctransport, policyHandle = self.connect()

        resp = lsat.hLsarLookupNames(dce, policyHandle, ('Administrator', 'Guest'))
        resp.dump() 
Example #13
Source File: test_lsat.py    From PiBunny with MIT License 5 votes vote down vote up
def test_hLsarLookupSids2(self):
        dce, rpctransport, policyHandle = self.connect()

        resp = lsat.hLsarLookupNames(dce, policyHandle, ('Administrator',))
        resp.dump()
        domainSid = resp['ReferencedDomains']['Domains'][0]['Sid'].formatCanonical()
        sids = list()
        sids.append(domainSid + '-500')
        sids.append(domainSid + '-501')
        resp = lsat.hLsarLookupSids2(dce, policyHandle, sids)
        resp.dump()