Esempio n. 1
0
File: decode.py Progetto: 6f/Hearthy
    def _handle(self, who, dec):
        if isinstance(dec, mtypes.BnetConnectRequest):
            # learn exported and imported services
            self._req_imports = dec.BindRequest.ImportedServiceHash

            for i, hval in enumerate(dec.BindRequest.ImportedServiceHash):
                service = _hash_to_service.get(hval, None)
                service_name = service.name if service is not None else '?'
                print('Import[{0}] - Hash {1}, name {2}'.format(i, hval, service_name))

            for item in dec.BindRequest.ExportedService:
                service = _hash_to_service.get(item.Hash, None)
                service_name = service.name if service is not None else '?'
                print('Export: Id {0}, Hash {1}, name {2}'.format(item.Id, item.Hash, service_name))

            for item in dec.BindRequest.ExportedService:
                self._exports[item.Id] = _hash_to_service.get(item.Hash, None)

        elif isinstance(dec, mtypes.BnetConnectResponse):
            bind_response = dec.BindResponse

            if hasattr(dec, 'ContentHandleArray'):
                cha = dec.ContentHandleArray
                for handle in cha.List:
                    print('Region: {0}'.format(utils.decode_fourcc(handle.region)))
                    print('Usage: {0}'.format(utils.decode_fourcc(handle.usage)))
                    print('Hash: {0}'.format(binascii.hexlify(handle.hash)))

            assert len(bind_response.ImportedServices) == len(self._req_imports)
            for i, service_id in enumerate(bind_response.ImportedServices):
                print('Mapping {0} <-> {1}'.format(service_id, self._req_imports[i]))
                service = _hash_to_service.get(self._req_imports[i], None)
                if service is not None:
                    print(service_id, service)
                    self._import_bindings[service_id] = service
Esempio n. 2
0
    def get_content_handle(self, req):
        program = utils.decode_fourcc(req.program_id)
        stream = utils.decode_fourcc(req.stream_id)
        locale = utils.decode_fourcc(req.locale)
        self.logger.info('get_content_handle for program=%s, stream=%s and locale=%s', program, stream, locale)

        handle = mtypes.BnetContentHandle(
            region=utils.encode_fourcc('REGI'),
            usage=utils.encode_fourcc('USAG'),
            hash=b'\x00'*32
        )
        return handle
Esempio n. 3
0
    def _handle(self, who, dec):
        if isinstance(dec, mtypes.BnetConnectRequest):
            # learn exported and imported services
            self._req_imports = dec.BindRequest.ImportedServiceHash

            for i, hval in enumerate(dec.BindRequest.ImportedServiceHash):
                service = _hash_to_service.get(hval, None)
                service_name = service.name if service is not None else '?'
                print('Import[{0}] - Hash {1}, name {2}'.format(
                    i, hval, service_name))

            for item in dec.BindRequest.ExportedService:
                service = _hash_to_service.get(item.Hash, None)
                service_name = service.name if service is not None else '?'
                print('Export: Id {0}, Hash {1}, name {2}'.format(
                    item.Id, item.Hash, service_name))

            for item in dec.BindRequest.ExportedService:
                self._exports[item.Id] = _hash_to_service.get(item.Hash, None)

        elif isinstance(dec, mtypes.BnetConnectResponse):
            bind_response = dec.BindResponse

            if hasattr(dec, 'ContentHandleArray'):
                cha = dec.ContentHandleArray
                for handle in cha.List:
                    print('Region: {0}'.format(
                        utils.decode_fourcc(handle.region)))
                    print('Usage: {0}'.format(utils.decode_fourcc(
                        handle.usage)))
                    print('Hash: {0}'.format(binascii.hexlify(handle.hash)))

            assert len(bind_response.ImportedServices) == len(
                self._req_imports)
            for i, service_id in enumerate(bind_response.ImportedServices):
                print('Mapping {0} <-> {1}'.format(service_id,
                                                   self._req_imports[i]))
                service = _hash_to_service.get(self._req_imports[i], None)
                if service is not None:
                    print(service_id, service)
                    self._import_bindings[service_id] = service