Export PST and OST with pypff / libpff

前端 未结 1 1505
眼角桃花
眼角桃花 2020-12-21 14:45

I need to do in python a module to export PST and OST files and I am trying to use pypff to do so. Can someone give me some tips how can I use pypff to extract messages and

相关标签:
1条回答
  • 2020-12-21 15:38

    To read messages in pst or ost files, in python, refer to the following functions in https://github.com/PacktPublishing/Learning-Python-for-Forensics/blob/master/Chapter%2010/pst_indexer.py

    folderTraverse(base)
    checkForMessages(folder)
    processMessage(message)

    To read the attachments also, you could modify processMessage(message)

    def processMessage(message, folder):
        attachments = []
        total_attachment_size_bytes = 0
        if message.number_of_attachments > 0:
            for i in range(message.number_of_attachments):
                total_attachment_size_bytes = total_attachment_size_bytes + (message.get_attachment(i)).get_size()
                # get the content of the attachment file
                attachments.append(((message.get_attachment(i)).read_buffer((message.get_attachment(i)).get_size())).decode('ascii', errors="ignore"))
        return {
            "subject": message.subject,
            "sender": message.sender_name,
            "header": message.transport_headers,
            "body": message.plain_text_body,
            "creation_time": message.creation_time,
            "submit_time": message.client_submit_time,
            "delivery_time": message.delivery_time,
            "attachment_count": message.number_of_attachments,
            "total_attachment_size": total_attachment_size_bytes,
            "attachments": attachments
        }
    
    0 讨论(0)
提交回复
热议问题