Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
certcc-ghbot committed Sep 19, 2024
2 parents fe742a8 + 2305fc4 commit 1be4812
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
metasploit-framework (6.4.27)
metasploit-framework (6.4.28)
aarch64
abbrev
actionpack (~> 7.0.0)
Expand Down
2 changes: 1 addition & 1 deletion lib/metasploit/framework/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 20 additions & 2 deletions lib/msf/core/post/linux/compile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'])

Expand All @@ -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'
Expand All @@ -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
Expand Down

0 comments on commit 1be4812

Please sign in to comment.