From 38972a7b3171210699a842c9774d3ddea5dd52d9 Mon Sep 17 00:00:00 2001 From: jvoisin Date: Sat, 14 Sep 2024 20:48:49 +0200 Subject: [PATCH 1/2] Add an `Auto` option to live_compile Co-authored-by: zeroSteiner --- lib/msf/core/post/linux/compile.rb | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/lib/msf/core/post/linux/compile.rb b/lib/msf/core/post/linux/compile.rb index ccc35229800b..562f962a1bd6 100644 --- a/lib/msf/core/post/linux/compile.rb +++ b/lib/msf/core/post/linux/compile.rb @@ -11,10 +11,20 @@ def initialize(info = {}) super register_options( [ OptEnum.new('COMPILE', [true, 'Compile on target', 'Auto', ['Auto', 'True', 'False']]), - OptEnum.new('COMPILER', [true, 'Compiler to use on target', 'gcc', ['gcc', 'clang']]), + OptEnum.new('COMPILER', [true, 'Compiler to use on target', 'Auto', ['Auto', 'gcc', 'clang']]), ], self.class) end + def get_compiler + if has_gcc? + return 'gcc' + elsif has_clang? + return 'clang' + else + return nil + end + end + def live_compile? return false unless %w{ Auto True }.include?(datastore['COMPILE']) @@ -24,6 +34,8 @@ def live_compile? elsif datastore['COMPILER'] == 'clang' && has_clang? vprint_good 'clang is installed' return true + elsif datastore['COMPILER'] == 'Auto' && get_compiler.present? + return true end unless datastore['COMPILE'] == 'Auto' @@ -36,7 +48,13 @@ def live_compile? def upload_and_compile(path, data, compiler_args='') write_file "#{path}.c", strip_comments(data) - compiler_cmd = "#{datastore['COMPILER']} -o '#{path}' '#{path}.c'" + compiler = datastore['COMPILER'] + if datastore['COMPILER'] == 'Auto' + compiler = get_compiler + fail_with(Module::Failure::BadConfig, "Unable to find a compiler on the remote target.") unless compiler.present? + end + + compiler_cmd = "#{compiler} -o '#{path}' '#{path}.c'" if session.type == 'shell' compiler_cmd = "PATH=\"$PATH:/usr/bin/\" #{compiler_cmd}" end From 80f050a5f5f358fb5f608734c75358211c88c258 Mon Sep 17 00:00:00 2001 From: adfoster-r7 Date: Thu, 19 Sep 2024 15:44:04 +0100 Subject: [PATCH 2/2] Bump version of framework to 6.4.28 --- Gemfile.lock | 2 +- lib/metasploit/framework/version.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 12247023041a..f7ab1e88be29 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - metasploit-framework (6.4.27) + metasploit-framework (6.4.28) aarch64 abbrev actionpack (~> 7.0.0) diff --git a/lib/metasploit/framework/version.rb b/lib/metasploit/framework/version.rb index 8aa7675e81d7..59d2e6c04e1d 100644 --- a/lib/metasploit/framework/version.rb +++ b/lib/metasploit/framework/version.rb @@ -32,7 +32,7 @@ def self.get_hash end end - VERSION = "6.4.27" + VERSION = "6.4.28" MAJOR, MINOR, PATCH = VERSION.split('.').map { |x| x.to_i } PRERELEASE = 'dev' HASH = get_hash