Skip to content

Commit 3af8bd9

Browse files
committed
Consistently use the same technique for exe-service
1 parent 0e95f25 commit 3af8bd9

File tree

3 files changed

+7
-23
lines changed

3 files changed

+7
-23
lines changed

data/templates/src/pe/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# PE Source Code
22
This directory contains the source code for the PE executable templates.
33

4-
## Building DLLs
5-
Use the provided `build_dlls.bat` file, and run it from within the Visual Studio
4+
## Building
5+
Use the provided `build_all.bat` file, and run it from within the Visual Studio
66
developer console. The batch file requires that the `%VCINSTALLDIR%` environment
77
variable be defined (which it should be by default). The build script will
88
create both the x86 and x64 templates before moving them into the correct

lib/msf/core/exploit/exe.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ def initialize(info = {})
2121
OptPath.new('EXE::Path', [false, 'The directory in which to look for the executable template']),
2222
OptPath.new('EXE::Template', [false, 'The executable template file name.']),
2323
OptBool.new('EXE::Inject', [false, 'Set to preserve the original EXE function']),
24-
OptBool.new('EXE::OldMethod',[false, 'Set to use the substitution EXE generation method.']),
2524
OptBool.new('EXE::FallBack', [false, 'Use the default template in case the specified one is missing']),
2625
OptBool.new('MSI::EICAR', [false, 'Generate an EICAR file instead of regular payload msi']),
2726
OptPath.new('MSI::Custom', [false, 'Use custom msi instead of automatically generating a payload msi']),
@@ -185,7 +184,7 @@ def exe_init_options(opts)
185184
:template => datastore['EXE::Template'],
186185
:inject => datastore['EXE::Inject'],
187186
:fallback => datastore['EXE::FallBack'],
188-
:sub_method => datastore['EXE::OldMethod']
187+
:sub_method => false
189188
})
190189

191190
# NOTE: If code and platform/arch are supplied, we use those values and skip initialization.

lib/msf/util/exe.rb

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ def self.to_win32pe(framework, code, opts = {})
248248
end
249249

250250
# use
251-
self.to_win32pe_exe_sub(framework, code, opts)
251+
return self.to_win32pe_exe_sub(framework, code, opts)
252252
end
253253

254254
# Allow the user to specify their own EXE template
@@ -630,7 +630,6 @@ def self.to_win32pe_exe_sub(framework, code, opts = {})
630630
opts[:exe_type] = :exe_sub
631631
exe_sub_method(code,opts)
632632
end
633-
634633
# self.to_win64pe
635634
#
636635
# @param framework [Msf::Framework] The framework of you want to use
@@ -674,24 +673,10 @@ def self.to_win64pe(framework, code, opts = {})
674673
#
675674
# @return [String] Windows Service PE file
676675
def self.to_win32pe_service(framework, code, opts = {})
676+
# Allow the user to specify their own service EXE template
677677
set_template_default(opts, "template_x86_windows_svc.exe")
678-
if opts[:sub_method]
679-
# Allow the user to specify their own service EXE template
680-
opts[:exe_type] = :service_exe
681-
return exe_sub_method(code,opts)
682-
else
683-
ENV['MSF_SERVICENAME'] = opts[:servicename]
684-
685-
opts[:framework] = framework
686-
opts[:payload] = 'stdin'
687-
opts[:encoder] = '@x86/service,'+(opts[:serviceencoder] || '')
688-
689-
# XXX This should not be required, it appears there is a dependency inversion
690-
# See https://github.com/rapid7/metasploit-framework/pull/9851
691-
venom_generator = Msf::PayloadGenerator.new(opts)
692-
code_service = venom_generator.multiple_encode_payload(code)
693-
return to_winpe_only(framework, code_service, opts)
694-
end
678+
opts[:exe_type] = :service_exe
679+
exe_sub_method(code,opts)
695680
end
696681

697682
# self.to_win64pe_service

0 commit comments

Comments
 (0)