Skip to content

Commit 1281f47

Browse files
authored
Land rapid7#19209, update fileformat modules to show the default template datastore values
2 parents 3e75c42 + 847b291 commit 1281f47

File tree

5 files changed

+10
-15
lines changed

5 files changed

+10
-15
lines changed

modules/exploits/linux/fileformat/unrar_cve_2022_30333.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def initialize(info = {})
5959
OptString.new('FILENAME', [ false, 'The file name.', 'payload.rar']),
6060
OptString.new('CUSTOM_PAYLOAD', [ false, 'A custom payload to encode' ]),
6161
OptString.new('TARGET_PATH', [ true, 'The location the payload should extract to (can, and should, contain path traversal characters - "../../" - as well as a filename).']),
62-
OptString.new('SYMLINK_FILENAME', [ false, 'The name of the symlink file to use (must be 12 characters or less; default: random)'])
62+
OptString.new('SYMLINK_FILENAME', [ true, 'The name of the symlink file to use (must be 12 characters or less; default: random)', Rex::Text.rand_text_alpha_lower(4..12)])
6363
]
6464
)
6565
end
@@ -80,7 +80,7 @@ def exploit
8080
end
8181

8282
begin
83-
rar = encode_as_traversal_rar(datastore['SYMLINK_FILENAME'] || Rex::Text.rand_text_alpha_lower(4..12), datastore['TARGET_PATH'], payload_data)
83+
rar = encode_as_traversal_rar(datastore['SYMLINK_FILENAME'], datastore['TARGET_PATH'], payload_data)
8484
rescue StandardError => e
8585
fail_with(Failure::BadConfig, "Failed to encode RAR file: #{e}")
8686
end

modules/exploits/multi/fileformat/office_word_macro.rb

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def initialize(info={})
5656
))
5757

5858
register_options([
59-
OptPath.new("CUSTOMTEMPLATE", [false, 'A docx file that will be used as a template to build the exploit']),
59+
OptPath.new("CUSTOMTEMPLATE", [true, 'A docx file that will be used as a template to build the exploit', File.join(macro_resource_directory, 'template.docx')]),
6060
OptString.new('FILENAME', [true, 'The Office document macro file (docm)', 'msf.docm'])
6161
])
6262
end
@@ -256,11 +256,7 @@ def macro_resource_directory
256256
end
257257

258258
def get_template_path
259-
if datastore['CUSTOMTEMPLATE']
260-
datastore['CUSTOMTEMPLATE']
261-
else
262-
File.join(macro_resource_directory, 'template.docx')
263-
end
259+
datastore['CUSTOMTEMPLATE']
264260
end
265261

266262
def exploit

modules/exploits/windows/fileformat/winrar_cve_2023_38831.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def initialize(info = {})
4949
])
5050

5151
register_advanced_options([
52-
OptString.new('PAYLOAD_NAME', [false, 'The filename for the payload executable.', nil])
52+
OptString.new('PAYLOAD_NAME', [true, 'The filename for the payload executable.', Rex::Text.rand_text_alpha(8) + '.exe'])
5353
])
5454
end
5555

@@ -59,8 +59,7 @@ def exploit
5959
input_file = datastore['INPUT_FILE']
6060
decoy_name = File.basename(input_file)
6161
decoy_ext = ".#{File.extname(input_file)[1..]}"
62-
payload_name = datastore['PAYLOAD_NAME'] || Rex::Text.rand_text_alpha(8) + '.exe'
63-
62+
payload_name = datastore['PAYLOAD_NAME']
6463
decoy_dir = File.join(temp_dir, "#{decoy_name}A")
6564
Dir.mkdir(decoy_dir)
6665

modules/exploits/windows/fileformat/word_msdtjs_rce.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def initialize(info = {})
6262
)
6363

6464
register_options([
65-
OptPath.new('CUSTOMTEMPLATE', [false, 'A DOCX file that will be used as a template to build the exploit.']),
65+
OptPath.new('CUSTOMTEMPLATE', [true, 'A DOCX file that will be used as a template to build the exploit.', File.join(Msf::Config.data_directory, 'exploits', 'word_msdtjs.docx')]),
6666
OptEnum.new('OUTPUT_FORMAT', [true, 'File format to use [docx, rtf].', 'docx', %w[docx rtf]]),
6767
OptBool.new('OBFUSCATE', [true, 'Obfuscate JavaScript content.', true])
6868
])
@@ -79,7 +79,7 @@ def get_file_in_docx(fname)
7979
end
8080

8181
def get_template_path
82-
datastore['CUSTOMTEMPLATE'] || File.join(Msf::Config.data_directory, 'exploits', 'word_msdtjs.docx')
82+
datastore['CUSTOMTEMPLATE']
8383
end
8484

8585
def generate_html

modules/exploits/windows/fileformat/word_mshtml_rce.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def initialize(info = {})
6363
OptBool.new('OBFUSCATE', [true, 'Obfuscate JavaScript content.', true])
6464
])
6565
register_advanced_options([
66-
OptPath.new('DocxTemplate', [ false, 'A DOCX file that will be used as a template to build the exploit.' ]),
66+
OptPath.new('DocxTemplate', [ true, 'A DOCX file that will be used as a template to build the exploit.', File.join(Msf::Config.data_directory, 'exploits', 'CVE-2021-40444', 'cve-2021-40444.docx') ]),
6767
])
6868
end
6969

@@ -211,7 +211,7 @@ def get_file_in_docx(fname)
211211
end
212212

213213
def get_template_path
214-
datastore['DocxTemplate'] || File.join(Msf::Config.data_directory, 'exploits', 'CVE-2021-40444', 'cve-2021-40444.docx')
214+
datastore['DocxTemplate']
215215
end
216216

217217
def inject_docx

0 commit comments

Comments
 (0)