@@ -734,16 +734,27 @@ def self.to_osx_x64_macho(framework, code, opts = {})
734
734
# @param [Hash] opts the options hash
735
735
# @option opts [String] :exe_name (random) the name of the macho exe file (never seen by the user)
736
736
# @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
737
738
# @option opts [String] :plist_extra ('') some extra data to shove inside the Info.plist file
738
739
# @return [String] zip archive containing an OSX .app directory
739
740
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 , '' )
743
745
744
746
app_name . chomp! ( ".app" )
745
747
app_name += ".app"
746
748
749
+ visible_plist = if hidden
750
+ %Q|
751
+ <key>LSBackgroundOnly</key>
752
+ <string>1</string>
753
+ |
754
+ else
755
+ ''
756
+ end
757
+
747
758
info_plist = %Q|
748
759
<?xml version="1.0" encoding="UTF-8"?>
749
760
<!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 = {})
754
765
<key>CFBundleIdentifier</key>
755
766
<string>com.#{ exe_name } .app</string>
756
767
<key>CFBundleName</key>
757
- <string>#{ exe_name } </string>
768
+ <string>#{ exe_name } </string>#{ visible_plist }
758
769
<key>CFBundlePackageType</key>
759
770
<string>APPL</string>
760
771
#{ plist_extra }
0 commit comments