Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

oletools and olefile should be dependencies #100

Closed
decalage2 opened this issue Sep 5, 2018 · 23 comments
Closed

oletools and olefile should be dependencies #100

decalage2 opened this issue Sep 5, 2018 · 23 comments

Comments

@decalage2
Copy link

I just noticed that CAPE includes copies of the files olefile.py, olevba, oleid, etc. (which is great, I'm glad they are useful)
As those tools are regularly updated to fix bugs and to support new formats and new obfuscation tricks, it would be better not to include old copies here, but to install the latest versions with pip.
Is there a specific reason why they are copied rather than imported?

@doomedraven
Copy link
Contributor

maybe just to prevent when something is changed in oletools internals and to not break the rest, but apart of that no

@decalage2
Copy link
Author

BTW I just noticed oletools is listed in requirements.txt, so it may also be installed outside of CAPE, ending up with two versions. I guess the copy could be removed from the lib directory, as long as import statements in CAPE point to the version installed by pip.

A specific version of oletools can be fixed in requirements.txt, to avoid breaking changes.

@doomedraven
Copy link
Contributor

yes i added that as i have added vba2graph and now it accepts a file with macros so it can generate graph and it uses oletools, but yes make sense to update

@doomedraven
Copy link
Contributor

PR is done for that, if @kevoreilly is fine with that after merge there is only need to remove unused files,

  • msgextract can be handled by sflock
  • remove pyparsing.py
  • DridexURLDecoder - is kinda for historical data only as that is useless nowdays

the vbadeobf is done already in oletools as iocs

so if we cleanup that folder we can move vba2graph to common and wipe office folder

@kevoreilly
Copy link
Contributor

All sounds good to me, merged PR.

@kevoreilly
Copy link
Contributor

(@decalage2 many thanks for all your hard work with oletools by the way!)

@doomedraven
Copy link
Contributor

ok fully moved everything to oletools and iocs extract in my last PR

@kevoreilly
Copy link
Contributor

I'm having some issues which I think might be related...

officeresults["Metadata"] = meta.get_meta()
AttributeError: OleMetadata instance has no attribute 'get_meta'

This is on line 1108 of static.py. olefile is installed at version 0.44 (won't update).

@kevoreilly
Copy link
Contributor

The get_meta() function is no longer present in olefile from 0.44, I will try and update static.py accordingly,

@doomedraven
Copy link
Contributor

@enzok
Copy link
Contributor

enzok commented Sep 6, 2018

I thought I commented with a warning about the get_meta function last night. Apparently my phone didn't send. I have that commit in my fork I will do a PR.

@doomedraven
Copy link
Contributor

the fix is
replace

officeresults["Metadata"] = meta.get_meta()

with

meta.SUMMARY_ATTRIBS

just tested in local

@kevoreilly
Copy link
Contributor

I think the meta.SUMMARY_ATTRIBS is the more concise, assuming they both perform the same?

@doomedraven
Copy link
Contributor

meta.SUMMARY_ATTRIBS is just the dict as before it was, they just removed an extra subcall

@doomedraven
Copy link
Contributor

meta.SUMMARY_ATTRIBS
['codepage', 'title', 'subject', 'author', 'keywords', 'comments', 'template', 'last_saved_by', 'revision_number', 'total_edit_time', 'last_printed', 'create_time', 'last_saved_time', 'num_pages', 'num_words', 'num_chars', 'thumbnail', 'creating_application', 'security']
```

@doomedraven
Copy link
Contributor

yes is the same, at least looks like

@kevoreilly
Copy link
Contributor

Ok I merged that one. I have found a problem in quarantine.py:

import lib.cuckoo.common.office.olefile as olefile

Is import olefile enough or is import oletools.thirdparty.olefile as olefile better?

@doomedraven
Copy link
Contributor

oletools.thirdparty.olefile

@doomedraven
Copy link
Contributor

im checking this one

<td>{{analysis.static.office.Metadata.DocumentSummaryInformation.company}}</td>

as the @enzok restore that structure, but maybe it just also requires a cleanup, will bring update in few mins

@enzok
Copy link
Contributor

enzok commented Sep 6, 2018

I forgot at some point I added support to handle Office metadata from newer XML .doc files. The SummaryInfo doesn't match up 1 for 1 from the OLE docs. @doomedraven has the better fix.

@doomedraven
Copy link
Contributor

basically we need this

# attribute names for SummaryInformation stream properties:
    # (ordered by property id, starting at 1)
    SUMMARY_ATTRIBS = ['codepage', 'title', 'subject', 'author', 'keywords', 'comments',
        'template', 'last_saved_by', 'revision_number', 'total_edit_time',
        'last_printed', 'create_time', 'last_saved_time', 'num_pages',
        'num_words', 'num_chars', 'thumbnail', 'creating_application',
        'security']

    # attribute names for DocumentSummaryInformation stream properties:
    # (ordered by property id, starting at 1)
    DOCSUM_ATTRIBS = ['codepage_doc', 'category', 'presentation_target', 'bytes', 'lines', 'paragraphs',
        'slides', 'notes', 'hidden_slides', 'mm_clips',
        'scale_crop', 'heading_pairs', 'titles_of_parts', 'manager',
        'company', 'links_dirty', 'chars_with_spaces', 'unused', 'shared_doc',
        'link_base', 'hlinks', 'hlinks_changed', 'version', 'dig_sig',
        'content_type', 'content_status', 'language', 'doc_version']

im checking if something else, and we need to make sure it's forced to printable

@decalage2
Copy link
Author

I am going to remove the copy of olefile from oletools.thirdparty quite soon (olefile will be a dependency of oletools, that needs to be installed on its own), so I would advise to add olefile to your requirements.txt, and to use import olefile instead of import oletools.thirdparty.olefile as olefile.

@doomedraven
Copy link
Contributor

ok, thanks i will fix imports and update reqs.txt

kevoreilly added a commit that referenced this issue Sep 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants