Skip to content

Commit 6eaa3c2

Browse files
committed
Land rapid7#4763, LSBackgroundOnly for safari_user_assisted_download_launch
2 parents e08206d + 49c9c02 commit 6eaa3c2

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

lib/msf/util/exe.rb

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -734,16 +734,27 @@ def self.to_osx_x64_macho(framework, code, opts = {})
734734
# @param [Hash] opts the options hash
735735
# @option opts [String] :exe_name (random) the name of the macho exe file (never seen by the user)
736736
# @option opts [String] :app_name (random) the name of the OSX app
737+
# @option opts [String] :hidden (true) hide the app when it is running
737738
# @option opts [String] :plist_extra ('') some extra data to shove inside the Info.plist file
738739
# @return [String] zip archive containing an OSX .app directory
739740
def self.to_osx_app(exe, opts = {})
740-
exe_name = opts[:exe_name] || Rex::Text.rand_text_alpha(8)
741-
app_name = opts[:app_name] || Rex::Text.rand_text_alpha(8)
742-
plist_extra = opts[:plist_extra] || ''
741+
exe_name = opts.fetch(:exe_name) { Rex::Text.rand_text_alpha(8) }
742+
app_name = opts.fetch(:app_name) { Rex::Text.rand_text_alpha(8) }
743+
hidden = opts.fetch(:hidden, true)
744+
plist_extra = opts.fetch(:plist_extra, '')
743745

744746
app_name.chomp!(".app")
745747
app_name += ".app"
746748

749+
visible_plist = if hidden
750+
%Q|
751+
<key>LSBackgroundOnly</key>
752+
<string>1</string>
753+
|
754+
else
755+
''
756+
end
757+
747758
info_plist = %Q|
748759
<?xml version="1.0" encoding="UTF-8"?>
749760
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
@@ -754,7 +765,7 @@ def self.to_osx_app(exe, opts = {})
754765
<key>CFBundleIdentifier</key>
755766
<string>com.#{exe_name}.app</string>
756767
<key>CFBundleName</key>
757-
<string>#{exe_name}</string>
768+
<string>#{exe_name}</string>#{visible_plist}
758769
<key>CFBundlePackageType</key>
759770
<string>APPL</string>
760771
#{plist_extra}

0 commit comments

Comments
 (0)