当前位置: 首页>>代码示例>>Python>>正文


Python olefile.OleFileIO方法代码示例

本文整理汇总了Python中olefile.OleFileIO方法的典型用法代码示例。如果您正苦于以下问题:Python olefile.OleFileIO方法的具体用法?Python olefile.OleFileIO怎么用?Python olefile.OleFileIO使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在olefile的用法示例。


在下文中一共展示了olefile.OleFileIO方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: import olefile [as 别名]
# 或者: from olefile import OleFileIO [as 别名]
def __init__(self, file):
        self.format = "ooxml"
        file.seek(0)  # TODO: Investigate the effect (required for olefile.isOleFile)
        # olefile cannot process non password protected ooxml files.
        # TODO: this code is duplicate of OfficeFile(). Merge?
        if olefile.isOleFile(file):
            ole = olefile.OleFileIO(file)
            self.file = ole
            with self.file.openstream('EncryptionInfo') as stream:
                self.type, self.info = _parseinfo(stream)
            logger.debug("OOXMLFile.type: {}".format(self.type))
            self.secret_key = None
            if self.type == 'agile':
                # TODO: Support aliases?
                self.keyTypes = ('password', 'private_key', 'secret_key')
            elif self.type == 'standard':
                self.keyTypes = ('password', 'secret_key')
            elif self.type == 'extensible':
                pass
        elif zipfile.is_zipfile(file):
            self.file = file
            self.type, self.info = None, None
            self.secret_key = None
        else:
            raise Exception("Unsupported file format") 
开发者ID:nolze,项目名称:msoffcrypto-tool,代码行数:27,代码来源:ooxml.py

示例2: __init__

# 需要导入模块: import olefile [as 别名]
# 或者: from olefile import OleFileIO [as 别名]
def __init__(self, file):
        self.file = file
        ole = olefile.OleFileIO(file)  # do not close this, would close file
        self.ole = ole
        self.format = "doc97"
        self.keyTypes = ['password']
        self.key = None
        self.salt = None

        # https://msdn.microsoft.com/en-us/library/dd944620(v=office.12).aspx
        with ole.openstream('wordDocument') as stream:
            fib = _parseFib(stream)

        # https://msdn.microsoft.com/en-us/library/dd923367(v=office.12).aspx
        tablename = '1Table' if fib.base.fWhichTblStm == 1 else '0Table'

        Info = namedtuple('Info', ['fib', 'tablename'])
        self.info = Info(
            fib=fib,
            tablename=tablename,
        ) 
开发者ID:nolze,项目名称:msoffcrypto-tool,代码行数:23,代码来源:doc97.py

示例3: __init__

# 需要导入模块: import olefile [as 别名]
# 或者: from olefile import OleFileIO [as 别名]
def __init__(self, msg_file_path):
        self.msg_file_path = msg_file_path
        self.include_attachment_data = False

        if not self.is_valid_msg_file():
            raise Exception(
                "Invalid file provided, please provide valid Microsoft’s Outlook MSG file."
            )

        with OleFileIO(msg_file_path) as ole_file:
            # process directory entries
            ole_root = ole_file.root
            kids_dict = ole_root.kids_dict

            self._message = Message(kids_dict)
            self._message_dict = self._message.as_dict()

            # process msg properties
            self._set_properties()

            # process msg recipients
            self._set_recipients()

            # process attachments
            self._set_attachments() 
开发者ID:vikramarsid,项目名称:msg_parser,代码行数:27,代码来源:msg_parser.py

示例4: stomp_it

# 需要导入模块: import olefile [as 别名]
# 或者: from olefile import OleFileIO [as 别名]
def stomp_it(stomped_file):    
    # Open file to mangle the VBA streams.
    with olefile.OleFileIO(stomped_file, write_mode=True) as ole:
    
        # Mangle the macro VBA streams.
        for stream_name in ole.listdir():
        
            # Got macros?
            data = ole.openstream(stream_name).read()
            
            marker = b"Attrib"
            if marker not in data:
                continue
           
            # Find where to write.
            start = data.rindex(marker)

            # Stomp the rest of the data.
            new_data = data[:start]
            for i in range(start, len(data)):
                # Stomp with random bytes.
                new_data += os.urandom(1)
            
            # Write out the garbage data.
            ole.write_stream(stream_name, new_data) 
开发者ID:haroldogden,项目名称:adb,代码行数:27,代码来源:stomp_vba.py

示例5: is_encrypted

# 需要导入模块: import olefile [as 别名]
# 或者: from olefile import OleFileIO [as 别名]
def is_encrypted(self):
        # Heuristic
        if isinstance(self.file, olefile.OleFileIO):
            return True
        else:
            return False 
开发者ID:nolze,项目名称:msoffcrypto-tool,代码行数:8,代码来源:ooxml.py

示例6: __init__

# 需要导入模块: import olefile [as 别名]
# 或者: from olefile import OleFileIO [as 别名]
def __init__(self, file):
        self.file = file
        ole = olefile.OleFileIO(file)  # do not close this, would close file
        self.ole = ole
        self.format = "xls97"
        self.keyTypes = ['password']
        self.key = None
        self.salt = None

        workbook = ole.openstream('Workbook')    # closed in destructor

        Data = namedtuple('Data', ['workbook'])
        self.data = Data(
            workbook=workbook,
        ) 
开发者ID:nolze,项目名称:msoffcrypto-tool,代码行数:17,代码来源:xls97.py

示例7: _open

# 需要导入模块: import olefile [as 别名]
# 或者: from olefile import OleFileIO [as 别名]
def _open(self):

        # read the OLE directory and see if this is a likely
        # to be a Microsoft Image Composer file

        try:
            self.ole = olefile.OleFileIO(self.fp)
        except IOError:
            raise SyntaxError("not an MIC file; invalid OLE file")

        # find ACI subfiles with Image members (maybe not the
        # best way to identify MIC files, but what the... ;-)

        self.images = []
        for path in self.ole.listdir():
            if path[1:] and path[0][-4:] == ".ACI" and path[1] == "Image":
                self.images.append(path)

        # if we didn't find any images, this is probably not
        # an MIC file.
        if not self.images:
            raise SyntaxError("not an MIC file; no image entries")

        self.__fp = self.fp
        self.frame = None

        if len(self.images) > 1:
            self.category = Image.CONTAINER

        self.seek(0) 
开发者ID:tp4a,项目名称:teleport,代码行数:32,代码来源:MicImagePlugin.py

示例8: _open

# 需要导入模块: import olefile [as 别名]
# 或者: from olefile import OleFileIO [as 别名]
def _open(self):
        #
        # read the OLE directory and see if this is a likely
        # to be a FlashPix file

        try:
            self.ole = olefile.OleFileIO(self.fp)
        except IOError:
            raise SyntaxError("not an FPX file; invalid OLE file")

        if self.ole.root.clsid != "56616700-C154-11CE-8553-00AA00A1F95B":
            raise SyntaxError("not an FPX file; bad root CLSID")

        self._open_index(1) 
开发者ID:tp4a,项目名称:teleport,代码行数:16,代码来源:FpxImagePlugin.py

示例9: _open

# 需要导入模块: import olefile [as 别名]
# 或者: from olefile import OleFileIO [as 别名]
def _open(self):

        # read the OLE directory and see if this is a likely
        # to be a Microsoft Image Composer file

        try:
            self.ole = olefile.OleFileIO(self.fp)
        except OSError:
            raise SyntaxError("not an MIC file; invalid OLE file")

        # find ACI subfiles with Image members (maybe not the
        # best way to identify MIC files, but what the... ;-)

        self.images = []
        for path in self.ole.listdir():
            if path[1:] and path[0][-4:] == ".ACI" and path[1] == "Image":
                self.images.append(path)

        # if we didn't find any images, this is probably not
        # an MIC file.
        if not self.images:
            raise SyntaxError("not an MIC file; no image entries")

        self.__fp = self.fp
        self.frame = None

        if len(self.images) > 1:
            self.category = Image.CONTAINER

        self.seek(0) 
开发者ID:tp4a,项目名称:teleport,代码行数:32,代码来源:MicImagePlugin.py

示例10: _open

# 需要导入模块: import olefile [as 别名]
# 或者: from olefile import OleFileIO [as 别名]
def _open(self):
        #
        # read the OLE directory and see if this is a likely
        # to be a FlashPix file

        try:
            self.ole = olefile.OleFileIO(self.fp)
        except OSError:
            raise SyntaxError("not an FPX file; invalid OLE file")

        if self.ole.root.clsid != "56616700-C154-11CE-8553-00AA00A1F95B":
            raise SyntaxError("not an FPX file; bad root CLSID")

        self._open_index(1) 
开发者ID:tp4a,项目名称:teleport,代码行数:16,代码来源:FpxImagePlugin.py

示例11: __init__

# 需要导入模块: import olefile [as 别名]
# 或者: from olefile import OleFileIO [as 别名]
def __init__(self, filename):
        OleFile.OleFileIO.__init__(self, filename) 
开发者ID:doomedraven,项目名称:VirusTotalApi,代码行数:4,代码来源:outlook_parser.py

示例12: ole_parser

# 需要导入模块: import olefile [as 别名]
# 或者: from olefile import OleFileIO [as 别名]
def ole_parser(s):
    ole = olefile.OleFileIO(s)
    meta = ole.get_metadata()
    attrs = meta.DOCSUM_ATTRIBS + meta.SUMMARY_ATTRIBS
    #meta.dump()
    result = {}
    for attr in attrs:
        if hasattr(meta, attr):
            result[attr] = getattr(meta, attr)
    ole.close()
    return result 
开发者ID:lanmaster53,项目名称:recon-ng-marketplace,代码行数:13,代码来源:metacrawler.py

示例13: scan

# 需要导入模块: import olefile [as 别名]
# 或者: from olefile import OleFileIO [as 别名]
def scan(self, payload: Payload, request: Request) -> WorkerResponse:
        extracted: List[ExtractedPayload] = []
        errors: List[Error] = []
        ole_object = olefile.OleFileIO(payload.content)
        streams = ole_object.listdir(streams=True)
        for stream in streams:
            try:
                stream_buffer = ole_object.openstream(stream).read()
                name = ''.join(
                    filter(lambda x: x in string.printable, '_'.join(stream))
                )
                if stream_buffer.endswith(b'\x01Ole10Native'):
                    ole_native = oleobj.OleNativeStream(stream_buffer)
                    if ole_native.filename:
                        name = f'{name}_{str(ole_native.filename)}'
                    else:
                        name = f'{name}_olenative'
                    meta = PayloadMeta(
                        should_archive=False,
                        extra_data={'index': streams.index(stream), 'name': name},
                    )
                    extracted.append(ExtractedPayload(ole_native.data, meta))
                else:
                    meta = PayloadMeta(
                        should_archive=False,
                        extra_data={'index': streams.index(stream), 'name': name},
                    )
                    extracted.append(ExtractedPayload(stream_buffer, meta))
            except Exception as err:
                errors.append(
                    Error(
                        error=str(err),
                        plugin_name=self.plugin_name,
                        payload_id=payload.payload_id,
                    )
                )
        return WorkerResponse(extracted=extracted, errors=errors) 
开发者ID:PUNCH-Cyber,项目名称:stoq-plugins-public,代码行数:39,代码来源:ole.py

示例14: extract_ole_metadata

# 需要导入模块: import olefile [as 别名]
# 或者: from olefile import OleFileIO [as 别名]
def extract_ole_metadata(self, file_path):
        with open(file_path, 'rb') as fh:
            if not isOleFile(fh):
                return
            fh.seek(0)
            try:
                ole = OleFileIO(fh)
                self.extract_olefileio_metadata(ole)
            except (RuntimeError, IOError):
                # OLE reading can go fully recursive, at which point it's OK
                # to just eat this runtime error quietly.
                log.warning("Failed to read OLE data: %s", self.result)
            except Exception:
                log.exception("Failed to read OLE data: %s", self.result) 
开发者ID:occrp-attic,项目名称:ingestors,代码行数:16,代码来源:ole.py

示例15: ole_parser

# 需要导入模块: import olefile [as 别名]
# 或者: from olefile import OleFileIO [as 别名]
def ole_parser(s):
    ole = olefile.OleFileIO(s)
    meta = ole.get_metadata()
    #meta.dump()
    result = {
        'author': meta.author,
        'last saved by': meta.last_saved_by,
        'company': meta.company,
    }
    ole.close()
    return result 
开发者ID:praetorian-code,项目名称:pentestly,代码行数:13,代码来源:parsers.py


注:本文中的olefile.OleFileIO方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。