Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[Feature Request] Ability to create new OleFile storage files #128

Open
TheElementalOfDestruction opened this issue Mar 10, 2020 · 3 comments

Comments

@TheElementalOfDestruction
Copy link
Contributor

Hello there, I am the current manager of the Msg Extractor repository and would be interested in the ability to create new msg files. When it comes to the data that would fill the msg file, I can handle that on my own, but I would need to have the ability to create new OleFile storages where I can add streams of any size on a whim.

Now, I understand this is a hard thing to do (I have seen you make mention of such a feature and it's difficulties in other issues), and as such would like to do two things. One, I would like to leave this as an open feature request to one day (hopefully) be closed when it is completed. In doing that I would also like to make it known I don't consider this to be a horribly important and can live without this feature.

The second thing I would like to do is offer my help in creating this feature, as it would both greatly expand the functionality of this library and allow me to greatly expand the functionality of msg extractor as well.

If you would like to get in touch to potentially work on the creation of this feature and let me know if you have any pre-existing progress or information on how to do this, you can contact me at arceusthe@gmail.com.

Thank you for your time.

@decalage2
Copy link
Owner

Hi, having the possibility to edit OLE files is one of the oldest feature requests on this project: see issue #6 for all the details on what needs to be implemented.
It would be great to have it for sure, I just lack the time (and motivation) to do it, as these days I am more focused on the oletools project.
Of course, any help would be greatly appreciated, and if you are motivated to work on this I will participate.

@TheElementalOfDestruction
Copy link
Contributor Author

TheElementalOfDestruction commented Jan 10, 2023

Been a bit (around 2.5 years or so) and I did (in a way) make some progress on this. extract-msg can now create its own OLE files from scratch, which it mainly uses for the purpose of extracting embedded MSG files. It also has enough functions that a user could (and I in fact have) create their own OLE file without an existing one at all, though it would take a decent amount of work to make it very user friendly. More methods to make things easier (and make modification of streams already added to the writer possible) are in the works.

The class used for writing can be seen here on the msg-extractor GitHub. The class used for writing is OleWriter and the public methods that are most important are OleWriter.addOleEntry , OleWriter.fromMsg, OleWriter.fromOleFile, and OleWriter.write. OleWriter.fromOleFile is being updated to allow the user to specify a directory in the file they want to copy instead of only allowing the entire file to be copied.

Unfortunately, it also required having a red-black tree module (a binary tree module may have worked, but I was having enough issues that I wasn't able to get around to trying it), and not wanting to have to write one myself I was forced to add another dependency. I'm not particulatly happy with the one I ended up with, though it did have all the required features like being able to go through each node, know what the left and right of each node are, and knowing the color of each node, all from an external perspective.

@TheElementalOfDestruction
Copy link
Contributor Author

Further update, a large number of new functions were added in 0.39.0, the most recent version while writing this message, which make the OleWriter class a lot more functional, allowing it to be completely independent from and existing OleFileIO instance. You can now:

  • Delete entries (OleWriter.deleteEntry)
  • Get an entry's data (OleWriter.getEntry)
  • Edit entries that have already been added (OleWriter.editEntry)
  • Add an entry with a path (and bytes if it is a stream) (OleWriter.addEntry)
  • Set the storage to use when copying from an existing OleFileIO instance (the new rootPath argument of OleWriter.fromOleFile)
  • Rename an entry that has already been added (This only changes the name of the entry, not it's position in the file) (OleWriter.renameEntry)
  • Get a list of all the current entries (OleWriter.listItems)
  • Iterate over the current file-structure in an os.walk like way (OleWriter.walk)

Using these I have been able to create OLE files from scratch that appear to be without issue as far as I can tell.

@decalage2 decalage2 self-assigned this Jan 20, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

2 participants