Example #1
0
 def changeServiceAndQuery2(self, dce, info, changeDone):
     serviceHandle = info['hService']
     dwInfoLevel = info['Info']['Union']['tag']
     cbBuffSize = 0
     request = scmr.RQueryServiceConfig2W()
     request['hService'] = serviceHandle
     request['dwInfoLevel'] = dwInfoLevel
     request['cbBufSize'] = cbBuffSize
     try:
         resp = dce.request(request)
     except Exception, e:
         if str(e).find('ERROR_INSUFFICIENT_BUFFER') <= 0:
             raise
         else:
             resp = e.get_packet()
Example #2
0
    def changeServiceAndQuery2(self, dce, info, changeDone):
        serviceHandle = info['hService']
        dwInfoLevel = info['Info']['Union']['tag']
        cbBuffSize = 0
        request = scmr.RQueryServiceConfig2W()
        request['hService'] = serviceHandle
        request['dwInfoLevel'] = dwInfoLevel
        request['cbBufSize'] = cbBuffSize
        try:
            resp = dce.request(request)
        except scmr.DCERPCSessionError as e:
            if str(e).find('ERROR_INSUFFICIENT_BUFFER') <= 0:
                raise
            else:
                resp = e.get_packet()

        request['cbBufSize'] = resp['pcbBytesNeeded']
        resp = dce.request(request)
        arrayData = b''.join(resp['lpBuffer'])
        if dwInfoLevel == 1:
            self.assertEqual(arrayData[4:].decode('utf-16le'), changeDone)
        elif dwInfoLevel == 2:
            offset = unpack('<L', arrayData[4:][:4])[0]
            self.assertEqual(
                arrayData[offset:][:len(changeDone) * 2].decode('utf-16le'),
                changeDone)
        elif dwInfoLevel == 3:
            self.assertEqual(unpack('<L', arrayData)[0], changeDone)
        elif dwInfoLevel == 4:
            self.assertEqual(unpack('<L', arrayData)[0], changeDone)
        elif dwInfoLevel == 5:
            self.assertEqual(unpack('<L', arrayData)[0], changeDone)
        elif dwInfoLevel == 6:
            changeDone = bytes(changeDone).decode('utf-16le')
            self.assertEqual(arrayData[4:].decode('utf-16le'), changeDone)
        elif dwInfoLevel == 7:
            self.assertEqual(unpack('<L', arrayData)[0], changeDone)