You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
**X-Protect is Apple’s built in malware scanner.** It keeps track of known malware hashes and patterns.
67
+
68
+
## Sandbox
65
69
66
70
MacOS Sandbox makes applications run inside the sandbox **need to request access to resources outside of the limited sandbox**. This helps to ensure that **the application will be accessing only expected resources** and if it wants to access anything else it will need to ask for permissions to the user.
67
71
72
+
You can get information about the latest XProtect update running:
73
+
68
74
Important **system services** also run inside their own custom **sandbox** such as the mdnsresponder service. You can view these custom **sandbox profiles** inside the **`/usr/share/sandbox`** directory.
Check some of the **already given permissions** to apps in `System Preferences --> Security & Privacy --> Privacy --> Files and Folders`.
71
81
82
+
## Common users
83
+
72
84
### SIP - System Integrity Protection
73
85
74
86
This protection was enabled to **help keep root level malware from taking over certain parts** of the operating system. Although this means **applying limitations to the root user** many find it to be worthwhile trade off.
@@ -611,6 +623,44 @@ The **kcpassword** file is a file that holds the **user’s login password**, bu
611
623
The password is stored in the file **`/etc/kcpassword`** xored with the key **`0x7D 0x89 0x52 0x23 0xD2 0xBC 0xDD 0xEA 0xA3 0xB9 0x1F`**. If the users password is longer than the key, the key will be reused.
612
624
This makes the password pretty easy to recover, for example using scripts like [**this one**](https://gist.github.com/opshope/32f65875d45215c3677d).
613
625
626
+
## **Library injection**
627
+
628
+
### Dylib Hijacking
629
+
630
+
As in Windows, in MacOS you can also **hijack dylibs** to make **applications****execute****arbitrary****code**.
631
+
However, the way **MacOS** applications **load** libraries is **more restricted** than in Windows. This implies that **malware** developers can still use this technique for **stealth**, but the probably to be able to **abuse this to escalate privileges is much lower**.
632
+
633
+
First of all, is **more common** to find that **MacOS binaries indicates the full path** to the libraries to load. And second, **MacOS never search** in the folders of the **$PATH** for libraries.
634
+
635
+
However, there are 2 types of dylib hijacking:
636
+
637
+
***Missing weak linked libraries**: This means that the application will try to load a library that doesn't exist configured with **LC\_LOAD\_WEAK\_DYLIB**. Then, **if an attacker places a dylib where it's expected it will be loaded**.
638
+
* The fact that the link is "weak" means that the application will continue running even if the library isn't found.
639
+
***Configured with @rpath**: The path to the library configured contains "**@rpath**" and it's configured with **multiple****LC\_RPATH** containing **paths**. Therefore, **when loading** the dylib, the loader is going to **search**\(in order\)**through all the paths** specified in the **LC\_RPATH****configurations**. If anyone is missing and **an attacker can place a dylib there** and it will be loaded.
640
+
641
+
The way to **escalate privileges** abusing this functionality would be in the rare case that an **application** being executed **by****root** is **looking** for some **library in some folder where the attacker has write permissions.**
642
+
643
+
**A nice scanner to find missing libraries in applications is**[**Dylib Hijack Scanner**](https://objective-see.com/products/dhs.html)**.
644
+
A nice report with technical details about this technique can be found**[**here**](https://www.virusbulletin.com/virusbulletin/2015/03/dylib-hijacking-os-x)**.**
645
+
646
+
### **DYLD\_INSERT\_LIBRARIES**
647
+
648
+
> This is a colon separated **list of dynamic libraries** to l**oad before the ones specified in the program**. This lets you test new modules of existing dynamic shared libraries that are used in flat-namespace images by loading a temporary dynamic shared library with just the new modules. Note that this has no effect on images built a two-level namespace images using a dynamic shared library unless DYLD\_FORCE\_FLAT\_NAMESPACE is also used.
649
+
650
+
This is like the [**LD\_PRELOAD on Linux**](../../linux-unix/privilege-escalation/#ld_preload).
651
+
652
+
This technique may be also **used as an ASEP technique** as every application installed has a plist called "Info.plist" that allows for the **assigning of environmental variables** using a key called `LSEnvironmental`.
653
+
654
+
## Crons
655
+
656
+
In MacOS several folders executing scripts with **certain frequency** can be found in:
657
+
658
+
```bash
659
+
ls -lR /usr/lib/cron/tabs/ /private/var/at/jobs /etc/periodic/
660
+
```
661
+
662
+
There you can find the regular **cron****jobs**, the **at****jobs**\(not very used\) and the **periodic****jobs**\(mainly used for cleaning temporary files\). The daily periodic jobs can be executed for example with: `periodic daily`.
0 commit comments