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


Python kaitaistruct.KaitaiStream方法代碼示例

本文整理匯總了Python中kaitaistruct.KaitaiStream方法的典型用法代碼示例。如果您正苦於以下問題:Python kaitaistruct.KaitaiStream方法的具體用法?Python kaitaistruct.KaitaiStream怎麽用?Python kaitaistruct.KaitaiStream使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在kaitaistruct的用法示例。


在下文中一共展示了kaitaistruct.KaitaiStream方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _read

# 需要導入模塊: import kaitaistruct [as 別名]
# 或者: from kaitaistruct import KaitaiStream [as 別名]
def _read(self):
        self.hdr = self._root.Header(self._io, self, self._root)
        self.logical_screen_descriptor = self._root.LogicalScreenDescriptorStruct(self._io, self, self._root)
        if self.logical_screen_descriptor.has_color_table:
            self._raw_global_color_table = self._io.read_bytes((self.logical_screen_descriptor.color_table_size * 3))
            io = KaitaiStream(BytesIO(self._raw_global_color_table))
            self.global_color_table = self._root.ColorTable(io, self, self._root)

        self.blocks = []
        i = 0
        while True:
            _ = self._root.Block(self._io, self, self._root)
            self.blocks.append(_)
            if  ((self._io.is_eof()) or (_.block_type == self._root.BlockType.end_of_file)) :
                break
            i += 1 
開發者ID:bodqhrohro,項目名稱:giftolottie,代碼行數:18,代碼來源:gif2numpy.py

示例2: program_headers

# 需要導入模塊: import kaitaistruct [as 別名]
# 或者: from kaitaistruct import KaitaiStream [as 別名]
def program_headers(self):
            if hasattr(self, '_m_program_headers'):
                return self._m_program_headers if hasattr(self, '_m_program_headers') else None

            _pos = self._io.pos()
            self._io.seek(self.program_header_offset)
            if self._is_le:
                self._raw__m_program_headers = [None] * (self.qty_program_header)
                self._m_program_headers = [None] * (self.qty_program_header)
                for i in range(self.qty_program_header):
                    self._raw__m_program_headers[i] = self._io.read_bytes(self.program_header_entry_size)
                    io = KaitaiStream(BytesIO(self._raw__m_program_headers[i]))
                    self._m_program_headers[i] = self._root.EndianElf.ProgramHeader(io, self, self._root, self._is_le)

            else:
                self._raw__m_program_headers = [None] * (self.qty_program_header)
                self._m_program_headers = [None] * (self.qty_program_header)
                for i in range(self.qty_program_header):
                    self._raw__m_program_headers[i] = self._io.read_bytes(self.program_header_entry_size)
                    io = KaitaiStream(BytesIO(self._raw__m_program_headers[i]))
                    self._m_program_headers[i] = self._root.EndianElf.ProgramHeader(io, self, self._root, self._is_le)

            self._io.seek(_pos)
            return self._m_program_headers if hasattr(self, '_m_program_headers') else None 
開發者ID:Antonin-Deniau,項目名稱:cave_miner,代碼行數:26,代碼來源:elf.py

示例3: section_headers

# 需要導入模塊: import kaitaistruct [as 別名]
# 或者: from kaitaistruct import KaitaiStream [as 別名]
def section_headers(self):
            if hasattr(self, '_m_section_headers'):
                return self._m_section_headers if hasattr(self, '_m_section_headers') else None

            _pos = self._io.pos()
            self._io.seek(self.section_header_offset)
            if self._is_le:
                self._raw__m_section_headers = [None] * (self.qty_section_header)
                self._m_section_headers = [None] * (self.qty_section_header)
                for i in range(self.qty_section_header):
                    self._raw__m_section_headers[i] = self._io.read_bytes(self.section_header_entry_size)
                    io = KaitaiStream(BytesIO(self._raw__m_section_headers[i]))
                    self._m_section_headers[i] = self._root.EndianElf.SectionHeader(io, self, self._root, self._is_le)

            else:
                self._raw__m_section_headers = [None] * (self.qty_section_header)
                self._m_section_headers = [None] * (self.qty_section_header)
                for i in range(self.qty_section_header):
                    self._raw__m_section_headers[i] = self._io.read_bytes(self.section_header_entry_size)
                    io = KaitaiStream(BytesIO(self._raw__m_section_headers[i]))
                    self._m_section_headers[i] = self._root.EndianElf.SectionHeader(io, self, self._root, self._is_le)

            self._io.seek(_pos)
            return self._m_section_headers if hasattr(self, '_m_section_headers') else None 
開發者ID:Antonin-Deniau,項目名稱:cave_miner,代碼行數:26,代碼來源:elf.py

示例4: strings

# 需要導入模塊: import kaitaistruct [as 別名]
# 或者: from kaitaistruct import KaitaiStream [as 別名]
def strings(self):
            if hasattr(self, '_m_strings'):
                return self._m_strings if hasattr(self, '_m_strings') else None

            _pos = self._io.pos()
            self._io.seek(self.section_headers[self.section_names_idx].offset)
            if self._is_le:
                self._raw__m_strings = self._io.read_bytes(self.section_headers[self.section_names_idx].size)
                io = KaitaiStream(BytesIO(self._raw__m_strings))
                self._m_strings = self._root.EndianElf.StringsStruct(io, self, self._root, self._is_le)
            else:
                self._raw__m_strings = self._io.read_bytes(self.section_headers[self.section_names_idx].size)
                io = KaitaiStream(BytesIO(self._raw__m_strings))
                self._m_strings = self._root.EndianElf.StringsStruct(io, self, self._root, self._is_le)
            self._io.seek(_pos)
            return self._m_strings if hasattr(self, '_m_strings') else None 
開發者ID:Antonin-Deniau,項目名稱:cave_miner,代碼行數:18,代碼來源:elf.py

示例5: _read

# 需要導入模塊: import kaitaistruct [as 別名]
# 或者: from kaitaistruct import KaitaiStream [as 別名]
def _read(self):
            self.crc16 = self._io.read_u2le()
            self.block_type = self._root.BlockTypes(self._io.read_u1())
            self.flags = self._io.read_u2le()
            self.block_size = self._io.read_u2le()
            if self.has_add:
                self.add_size = self._io.read_u4le()

            _on = self.block_type
            if _on == self._root.BlockTypes.file_header:
                self._raw_body = self._io.read_bytes(self.body_size)
                io = KaitaiStream(BytesIO(self._raw_body))
                self.body = self._root.BlockFileHeader(io, self, self._root)
            else:
                self.body = self._io.read_bytes(self.body_size)
            if self.has_add:
                self.add_body = self._io.read_bytes(self.add_size) 
開發者ID:kaitai-io,項目名稱:kaitai_fs,代碼行數:19,代碼來源:rar.py

示例6: _read

# 需要導入模塊: import kaitaistruct [as 別名]
# 或者: from kaitaistruct import KaitaiStream [as 別名]
def _read(self):
        self.total_length = self._io.read_u4le()
        self.install_paths_length = self._io.read_u4le()
        self._raw_install_paths = self._io.read_bytes(self.install_paths_length)
        io = KaitaiStream(BytesIO(self._raw_install_paths))
        self.install_paths = self._root.InstallPathsStruct(io, self, self._root)
        self.binaries_length = self._io.read_u4le()
        self._raw_binaries = self._io.read_bytes(self.binaries_length)
        io = KaitaiStream(BytesIO(self._raw_binaries))
        self.binaries = self._root.BinariesStruct(io, self, self._root)
        self.persistence_length = self._io.read_u4le()
        self._raw_persistence_strings = self._io.read_bytes(self.persistence_length)
        io = KaitaiStream(BytesIO(self._raw_persistence_strings))
        self.persistence_strings = self._root.PersistenceStruct(io, self, self._root) 
開發者ID:eset,項目名稱:malware-research,代碼行數:16,代碼來源:ol_unpack_files_from_3rd_stage.py

示例7: parse_vek_keybag

# 需要導入模塊: import kaitaistruct [as 別名]
# 或者: from kaitaistruct import KaitaiStream [as 別名]
def parse_vek_keybag(unwrapped_keybag):
    """
    Returns a kaitai struct structure of the unwrapped keybag
    param: unwrappped_keybag: The bytes like keybag that will be parsed
    return: keybag: The structured keybag
    """

    stream = KaitaiStream(BytesIO(unwrapped_keybag))
    keybag = media_keybag_t_vek(stream)
    return keybag 
開發者ID:ydkhatri,項目名稱:mac_apt,代碼行數:12,代碼來源:decryptor.py

示例8: parse_volume_keybag

# 需要導入模塊: import kaitaistruct [as 別名]
# 或者: from kaitaistruct import KaitaiStream [as 別名]
def parse_volume_keybag(unwrapped_keybag):
    """
    Returns a kaitai struct structure of the unwrapped keybag
    param: unwrappped_keybag: The bytes like keybag that will be parsed
    return: keybag: The structured keybag
    """

    stream = KaitaiStream(BytesIO(unwrapped_keybag))
    keybag = media_keybag_t_kek(stream)
    return keybag 
開發者ID:ydkhatri,項目名稱:mac_apt,代碼行數:12,代碼來源:decryptor.py

示例9: read_vol_block

# 需要導入模塊: import kaitaistruct [as 別名]
# 或者: from kaitaistruct import KaitaiStream [as 別名]
def read_vol_block(self, block_num, key=None):
        """ Parse a single block """
        data = self.container.get_block(block_num)

        if not data:
            return None
        if key is None:
            block = self.apfs.Block(KaitaiStream(BytesIO(data)), self.apfs, self.apfs)
        else:
            decrypted_block = self.decrypt_vol_block(data, block_num, key)
            block = self.apfs.Block(KaitaiStream(BytesIO(decrypted_block)), self.apfs, self.apfs)
        return block 
開發者ID:ydkhatri,項目名稱:mac_apt,代碼行數:14,代碼來源:apfs_reader.py

示例10: read_block

# 需要導入模塊: import kaitaistruct [as 別名]
# 或者: from kaitaistruct import KaitaiStream [as 別名]
def read_block(self, block_num):
        """ Parse a single block """
        data = self.get_block(block_num)

        if not data:
            return None

        block = self.apfs.Block(KaitaiStream(BytesIO(data)), self.apfs, self.apfs)
        return block 
開發者ID:ydkhatri,項目名稱:mac_apt,代碼行數:11,代碼來源:apfs_reader.py

示例11: _read

# 需要導入模塊: import kaitaistruct [as 別名]
# 或者: from kaitaistruct import KaitaiStream [as 別名]
def _read(self):
            self.unused1 = self._io.ensure_fixed_contents(struct.pack('1b', 0))
            self.system_id = (self._io.read_bytes(32)).decode(u"UTF-8")
            self.volume_id = (self._io.read_bytes(32)).decode(u"UTF-8")
            self.unused2 = self._io.ensure_fixed_contents(struct.pack('8b', 0, 0, 0, 0, 0, 0, 0, 0))
            self.vol_space_size = self._root.U4bi(self._io, self, self._root)
            self.unused3 = self._io.ensure_fixed_contents(struct.pack('32b', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0))
            self.vol_set_size = self._root.U2bi(self._io, self, self._root)
            self.vol_seq_num = self._root.U2bi(self._io, self, self._root)
            self.logical_block_size = self._root.U2bi(self._io, self, self._root)
            self.path_table_size = self._root.U4bi(self._io, self, self._root)
            self.lba_path_table_le = self._io.read_u4le()
            self.lba_opt_path_table_le = self._io.read_u4le()
            self.lba_path_table_be = self._io.read_u4be()
            self.lba_opt_path_table_be = self._io.read_u4be()
            self._raw_root_dir = self._io.read_bytes(34)
            io = KaitaiStream(BytesIO(self._raw_root_dir))
            self.root_dir = self._root.DirEntry(io, self, self._root)
            self.vol_set_id = (self._io.read_bytes(128)).decode(u"UTF-8")
            self.publisher_id = (self._io.read_bytes(128)).decode(u"UTF-8")
            self.data_preparer_id = (self._io.read_bytes(128)).decode(u"UTF-8")
            self.application_id = (self._io.read_bytes(128)).decode(u"UTF-8")
            self.copyright_file_id = (self._io.read_bytes(38)).decode(u"UTF-8")
            self.abstract_file_id = (self._io.read_bytes(36)).decode(u"UTF-8")
            self.bibliographic_file_id = (self._io.read_bytes(37)).decode(u"UTF-8")
            self.vol_create_datetime = self._root.DecDatetime(self._io, self, self._root)
            self.vol_mod_datetime = self._root.DecDatetime(self._io, self, self._root)
            self.vol_expire_datetime = self._root.DecDatetime(self._io, self, self._root)
            self.vol_effective_datetime = self._root.DecDatetime(self._io, self, self._root)
            self.file_structure_version = self._io.read_u1()
            self.unused4 = self._io.read_u1()
            self.application_area = self._io.read_bytes(512) 
開發者ID:kaitai-io,項目名稱:kaitai_fs,代碼行數:34,代碼來源:iso9660.py

示例12: path_table

# 需要導入模塊: import kaitaistruct [as 別名]
# 或者: from kaitaistruct import KaitaiStream [as 別名]
def path_table(self):
            if hasattr(self, '_m_path_table'):
                return self._m_path_table if hasattr(self, '_m_path_table') else None

            _pos = self._io.pos()
            self._io.seek((self.lba_path_table_le * self._root.sector_size))
            self._raw__m_path_table = self._io.read_bytes(self.path_table_size.le)
            io = KaitaiStream(BytesIO(self._raw__m_path_table))
            self._m_path_table = self._root.PathTableLe(io, self, self._root)
            self._io.seek(_pos)
            return self._m_path_table if hasattr(self, '_m_path_table') else None 
開發者ID:kaitai-io,項目名稱:kaitai_fs,代碼行數:13,代碼來源:iso9660.py

示例13: extent_as_dir

# 需要導入模塊: import kaitaistruct [as 別名]
# 或者: from kaitaistruct import KaitaiStream [as 別名]
def extent_as_dir(self):
            if hasattr(self, '_m_extent_as_dir'):
                return self._m_extent_as_dir if hasattr(self, '_m_extent_as_dir') else None

            if (self.file_flags & 2) != 0:
                io = self._root._io
                _pos = io.pos()
                io.seek((self.lba_extent.le * self._root.sector_size))
                self._raw__m_extent_as_dir = io.read_bytes(self.size_extent.le)
                io = KaitaiStream(BytesIO(self._raw__m_extent_as_dir))
                self._m_extent_as_dir = self._root.DirEntries(io, self, self._root)
                io.seek(_pos)

            return self._m_extent_as_dir if hasattr(self, '_m_extent_as_dir') else None 
開發者ID:kaitai-io,項目名稱:kaitai_fs,代碼行數:16,代碼來源:iso9660.py

示例14: read_fbp_file

# 需要導入模塊: import kaitaistruct [as 別名]
# 或者: from kaitaistruct import KaitaiStream [as 別名]
def read_fbp_file(file_name, msg_root_class, msg_header_class, msg_class):
    reader = fbs_reader.FBSReader(file_name)
    buf = io.BytesIO()
    stream = KaitaiStream(buf)
    header = None
    messages = []
    last_ofs = 0
    _root = None

    for dat, ts in reader:
        buf.seek(0, io.SEEK_END)
        buf.write(dat)
        buf.seek(last_ofs, io.SEEK_SET)

        try:
            if header is None:
                header = msg_header_class(stream, _root=msg_root_class)
                buf.seek(0, io.SEEK_SET)
                _root = msg_root_class(stream)
            else:
                msg = msg_class(stream, _root=_root, _parent=_root)
                messages.append((ts, msg))
            last_ofs = buf.tell()
        except Exception as e:
            pass
    return header, messages 
開發者ID:PacktPublishing,項目名稱:Deep-Reinforcement-Learning-Hands-On,代碼行數:28,代碼來源:vnc_demo.py

示例15: varint

# 需要導入模塊: import kaitaistruct [as 別名]
# 或者: from kaitaistruct import KaitaiStream [as 別名]
def varint(i):
    io = KaitaiStream(BytesIO(i))
    res = vlq_base128_le.VlqBase128Le(io)
    return res.len, res.value 
開發者ID:sophoslabs,項目名稱:WebAssembly,代碼行數:6,代碼來源:wasm-disassembler.py


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