-
Notifications
You must be signed in to change notification settings - Fork 14.3k
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
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: RAMELLA Sebastien <[email protected]>
}, | ||
'License' => MSF_LICENSE, | ||
'Author' => [ | ||
'mekhalleh (RAMELLA Sebastien)' # module author powered by EXA Reunion (https://www.exa.re/) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'mekhalleh (RAMELLA Sebastien)' # module author powered by EXA Reunion (https://www.exa.re/) | |
'RAMELLA "mekhalleh" Sebastien from XA Reunion (https://www.exa.re/)' # module author |
Signed-off-by: RAMELLA Sebastien <[email protected]>
Signed-off-by: RAMELLA Sebastien <[email protected]>
Signed-off-by: RAMELLA Sebastien <[email protected]>
There was a problem hiding this 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.
end | ||
|
||
# if no pdf injected is provided, create new PDF from template | ||
if datastore['INJECTED_PDF'].nil? || datastore['INJECTED_PDF'].empty? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if datastore['INJECTED_PDF'].nil? || datastore['INJECTED_PDF'].empty? | |
if datastore['INJECTED_PDF'].blank? |
if datastore['MESSAGE_PDF'].nil? || datastore['MESSAGE_PDF'].empty? | ||
fail_with(Failure::BadConfig, 'No MESSAGE_PDF provided') | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if datastore['MESSAGE_PDF'].nil? || datastore['MESSAGE_PDF'].empty? | |
fail_with(Failure::BadConfig, 'No MESSAGE_PDF provided') | |
end | |
fail_with(Failure::BadConfig, 'No MESSAGE_PDF provided') if datastore['MESSAGE_PDF'].blank? |
if content&.empty? | ||
fail_with(Failure::BadConfig, 'The MHT file content is empty') | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if content&.empty? | |
fail_with(Failure::BadConfig, 'The MHT file content is empty') | |
end | |
fail_with(Failure::BadConfig, 'The MHT file content is empty') if content&.empty? |
|
||
# saving the file | ||
ltype = "auxiliary.fileformat.#{shortname}" | ||
fname = File.basename(datastore['FILENAME']).sub(File.extname(datastore['FILENAME']), datastore['OUTPUT_EXT']) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this can be simplified:
fname = File.basename(datastore['FILENAME']).sub(File.extname(datastore['FILENAME']), datastore['OUTPUT_EXT']) | |
fname = File.basename(datastore['FILENAME'],'*')+datastore['OUTPUT_EXT'] |
|
||
# saving the file | ||
ltype = "auxiliary.fileformat.#{shortname}" | ||
fname = File.basename(datastore['FILENAME']).sub(File.extname(datastore['FILENAME']), datastore['OUTPUT_EXT']) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fname = File.basename(datastore['FILENAME']).sub(File.extname(datastore['FILENAME']), datastore['OUTPUT_EXT']) | |
fname = File.basename(datastore['FILENAME'],'*')+datastore['OUTPUT_EXT'] |
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
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.
A malicious MHT file created can be opened in Microsoft Word even though it has magic numbers and file
structure of PDF.