Skip to content

Commit dc88f3f

Browse files
committed
fixes review
Signed-off-by: RAMELLA Sebastien <[email protected]>
1 parent 0da43ef commit dc88f3f

File tree

1 file changed

+7
-21
lines changed

1 file changed

+7
-21
lines changed

modules/auxiliary/fileformat/maldoc_in_pdf_polyglot.rb

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,15 @@ def initialize(info = {})
3434
'Notes' => {
3535
'Stability' => [CRASH_SAFE],
3636
'Reliability' => [],
37-
'SideEffects' => [IOC_IN_LOGS]
37+
'SideEffects' => []
3838
}
3939
)
4040
)
4141

4242
register_options(
4343
[
4444
OptPath.new('FILENAME', [true, 'The input MHT filename with macro embedded']),
45-
OptPath.new('INJECTED_PDF', [false, 'The input PDF filename to be injected (optional)']),
45+
OptPath.new('INJECTED_PDF', [false, 'The input PDF filename to inject in (optional)']),
4646
OptString.new('MESSAGE_PDF', [false, 'The message to display in the local PDF template (if INJECTED_PDF is NOT used)', 'You must open this document in Microsoft Word'])
4747
]
4848
)
@@ -93,12 +93,9 @@ def create_pdf(mht)
9393
# calculation of dynamic offsets
9494
offsets = []
9595
offsets << 0
96-
offsets << pdf.index('1 0 obj')
97-
offsets << pdf.index('2 0 obj')
98-
offsets << pdf.index('3 0 obj')
99-
offsets << pdf.index('4 0 obj')
100-
offsets << pdf.index('5 0 obj')
101-
offsets << pdf.index('6 0 obj')
96+
for i in 1..6 do
97+
offsets << pdf.index("#{i} 0 obj")
98+
end
10299

103100
# XREF section
104101
xref_start = pdf.length
@@ -193,35 +190,24 @@ def inject_pdf(pdf_path, mht)
193190
end
194191

195192
def rand_pdfheader
196-
# List of recognized PDF versions
197-
pdf_versions = [
198-
'1.0', '1.1', '1.2', '1.3', '1.4', '1.5', '1.6', '1.7', '2.0'
199-
]
200-
# random verion selection
201-
selected_version = pdf_versions.sample
193+
selected_version = ['1.0', '1.1', '1.2', '1.3', '1.4', '1.5', '1.6', '1.7', '2.0'].sample
202194

203195
"%PDF-#{selected_version}"
204196
end
205197

206198
def run
207-
if datastore['FILENAME'].nil? || datastore['FILENAME'].empty?
208-
fail_with(Failure::BadConfig, 'No FILENAME provided')
209-
end
210-
211199
content = File.read(datastore['FILENAME'])
212200
if content.nil? || content.empty?
213201
fail_with(Failure::BadConfig, 'The MHT file content is empty')
214202
end
215203

216204
# if no pdf injected is provided, create new PDF from template
217205
if datastore['INJECTED_PDF'].nil? || datastore['INJECTED_PDF'].empty?
218-
print_status('PDF creation using local template')
206+
print_status('INJECTED_PDF not provided, creating the PDF from scratch')
219207
if datastore['MESSAGE_PDF'].nil? || datastore['MESSAGE_PDF'].empty?
220208
fail_with(Failure::BadConfig, 'No MESSAGE_PDF provided')
221209
end
222210
create_pdf(content)
223-
224-
# else if injected pdf is provided
225211
else
226212
print_status("PDF creation using '#{File.basename(datastore['INJECTED_PDF'])}' as template")
227213

0 commit comments

Comments
 (0)