Skip to content

Commit

Permalink
Add an Auto option to live_compile
Browse files Browse the repository at this point in the history
Ass suggested by @zeroSteiner
  • Loading branch information
jvoisin committed Sep 14, 2024
1 parent 7db428c commit 781c3d1
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lib/msf/core/post/linux/compile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ 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

Expand All @@ -36,6 +36,16 @@ def live_compile?
def upload_and_compile(path, data, compiler_args='')
write_file "#{path}.c", strip_comments(data)

if datastore['COMPILER'] == 'Auto'
if has_gcc?
datastore['COMPILER'] = 'gcc'
elsif has_clang?
datastore['COMPILER'] = 'clang'
else
fail_with Module::Failure::BadConfig, "Unable to find gcc nor clang on the remote target."
end
end

compiler_cmd = "#{datastore['COMPILER']} -o '#{path}' '#{path}.c'"
if session.type == 'shell'
compiler_cmd = "PATH=\"$PATH:/usr/bin/\" #{compiler_cmd}"
Expand Down

0 comments on commit 781c3d1

Please sign in to comment.