Skip to content

Add Maldoc in PDF polyglot fileformat module #20072

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

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

Conversation

mekhalleh
Copy link
Contributor

The technique is called "MalDoc in PDF". This technique hides malicious Word documents in PDF files, which is why malicious code contained in them cannot be detected by many analysis tools.

The document can be opened in both Microsoft Word and a PDF reader.

However, for the macro to run, you must open this document in Microsoft Word. The attack does not bypass configured macro locks. The malicious macros are also not executed when the file is opened in PDF readers or similar software.

Verification

List the steps needed to make sure this thing works

  • Start msfconsole
  • use auxiliary/fileformat/maldoc_in_pdf_polyglot
  • set FILENAME /tmp/macro.htm
  • run

Options

FILENAME

The input MHT filename with macro embedded.

INJECTED_PDF

The input PDF filename to be injected. (optional)

MESSAGE_PDF

The message to display in the local PDF template (if INJECTED_PDF is NOT used). Default: You must open this document in Microsoft Word

Results

The document can be opened in both Microsoft Word and a PDF reader.

image

A malicious MHT file created can be opened in Microsoft Word even though it has magic numbers and file
structure of PDF.

image

Signed-off-by: RAMELLA Sebastien <[email protected]>
Signed-off-by: RAMELLA Sebastien <[email protected]>
Signed-off-by: RAMELLA Sebastien <[email protected]>
Signed-off-by: RAMELLA Sebastien <[email protected]>
Copy link
Contributor

@msutovsky-r7 msutovsky-r7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @mekhalleh, reviewed your module and left some comments. The module itself seems to be working fine.

Signed-off-by: RAMELLA Sebastien <[email protected]>
@mekhalleh
Copy link
Contributor Author

Hey @mekhalleh, reviewed your module and left some comments. The module itself seems to be working fine.

hello @msutovsky-r7 thanks for the review. and sorry for the time taken to reply :)

all is done.

@msutovsky-r7 msutovsky-r7 self-assigned this May 28, 2025
This will look better in Metasploit wrapup blog

Co-authored-by: Julien Voisin <[email protected]>
@msutovsky-r7 msutovsky-r7 changed the title Add: Maldoc in PDF polyglot fileformat module Add Maldoc in PDF polyglot fileformat module May 29, 2025
'Notes' => {
'Stability' => [CRASH_SAFE],
'Reliability' => [],
'SideEffects' => []
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
'SideEffects' => []
'SideEffects' => [ARTIFACTS_ON_DISK]

@msutovsky-r7
Copy link
Contributor

I'm considering one additional change: is there any way to only have a docx as template, add payload from Metasploit as macro and then do the final conversion to PDF? It would provide bit better usability as there would be no need to add macro payload manually.

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.

3 participants