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

Add oleobj arg to just find external relations #772

Open
wants to merge 15 commits into
base: master
Choose a base branch
from

Conversation

christian-intra2net
Copy link
Contributor

@christian-intra2net christian-intra2net commented Jun 17, 2022

Analyses of the attacks using ms-msdt links show that there is a multitude of attack vectors based on links or general "external relations" in office documents. It is therefore prudent to check for these and there is code in oleobj that helps doing that.

However, oleobj also dumps embedded files to disc which may not be the intended behaviour when using it as "link finder". The commits in this PR therefore add an option to skip all dumping and just report what could be dumped and what external relations were found.

We could take an alternative approach and instead create a separate "link_finder.py", moving this functionality there, but since more and more people rely on oletools I did not want to break compatibility with existing behaviour. I can implement that as well if you wish.

This branch is based on one other branch, therefore the PR contains 10 commits from #771 (log-helper and json in oleobj) to avoid trouble when merging. Hope that is ok.

@decalage2 decalage2 self-requested a review June 19, 2022 20:27
@decalage2 decalage2 self-assigned this Jun 19, 2022
@christian-intra2net christian-intra2net changed the title Add oleobj to just find external relations Add oleobj arg to just find external relations Jun 20, 2022
Not needed any more when using log_helper
People (like me) might think that when they give "-r" as argument they
could give a directory with samples as input, e.g.

oleobj -r /path/to/samples

when actually they need to specify that with a glob and -r is
independent of that

oleobj /path/to/samples\*

Clarify that in the help-string of "-r".

Also, giving a glob did result in an error saying that this is not an
existing file. Fixed that.
Should not matter but this is safer and consistent with other tests.
When testing json-output we need to run samples through the "main"
functions of modules, not just their "process_file" functions that would
accept the extracted and decrypted data from the existing helper
function "loop_over_files". They need a filename as input, so add helper
to create a temp dir and extract&decrypt samples to that temporarily.
Since this test runs 3 scripts over all samples it takes pretty long.
Therefore, disable it per default, enable with a environment variable
OLETOOLS_TEST_JSON=1

Also, decrypting and extracting malware samples onto the disc might
cause trouble, another reason for not enabling this test per default.
oleobj also serves as finder for external relationships. If users want just
that behaviour and no dumping of embedded objects, give them the option to
get that. Also clarify this double-purpose in the doc string.

There is a TODO that might be aimed for exactly that, but I am uncertain
whether I interpret it correctly
Do not just rely on return value.

Also avoid dumping stuff when just checking links.
Do not abuse the "did dump"-flag for "did find external relationship", add
an extra flag and return value for that
Branch that fixed this has been merged Oct 2019.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants