Skip to content

Commit 9b17b63

Browse files
author
HD Moore
committed
Switch to append mode for x86 service templates, fixes rapid7#5403
1 parent ea9059f commit 9b17b63

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

lib/msf/util/exe.rb

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -525,9 +525,6 @@ def self.to_win64pe(framework, code, opts = {})
525525
return injector.generate_pe
526526
end
527527

528-
#opts[:exe_type] = :exe_sub
529-
#return exe_sub_method(code,opts)
530-
531528
# Append a new section instead
532529
appender = Msf::Exe::SegmentAppender.new({
533530
:payload => code,
@@ -549,9 +546,9 @@ def self.to_win64pe(framework, code, opts = {})
549546
#
550547
# @return [String] Windows Service PE file
551548
def self.to_win32pe_service(framework, code, opts = {})
549+
set_template_default(opts, "template_x86_windows_svc.exe")
552550
if opts[:sub_method]
553551
# Allow the user to specify their own service EXE template
554-
set_template_default(opts, "template_x86_windows_svc.exe")
555552
opts[:exe_type] = :service_exe
556553
return exe_sub_method(code,opts)
557554
else
@@ -610,7 +607,12 @@ def self.to_win32pe_service(framework, code, opts = {})
610607
"\x79\xFF\xD5\x8B\x0E\x51\x68\xC6\x96\x87\x52\xFF\xD5\x8B\x4E\x04" +
611608
"\x51\x68\xC6\x96\x87\x52\xFF\xD5#{code_service_stopped}"
612609

613-
to_winpe_only(framework, code_service + code, opts)
610+
# Append a new section to the template
611+
Msf::Exe::SegmentAppender.new({
612+
:payload => code_service + code,
613+
:template => opts[:template],
614+
:arch => :x86
615+
}).generate_pe
614616
end
615617
end
616618

0 commit comments

Comments
 (0)