> For the complete documentation index, see [llms.txt](https://edu.noirchapeau.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://edu.noirchapeau.com/shells-and-payloads-shell-overview/shells-and-payloads-detection-and-prevention.md).

# Shells & Payloads: Detection & Prevention

## **Monitoring Active Shells**

* Utilize the **MITRE ATT\&CK Framework** to identify tactics and techniques:
  * **Initial Access**: Exploiting public-facing services (e.g., web apps, SMB).
  * **Execution**: Executing commands on the victim system via exploits, shells, or payloads.
  * **Command & Control (C2)**: Maintaining interactive access, often over encrypted channels.
* **Events to Monitor**:
  * **File uploads**: Logs can reveal malicious file uploads; pair with AV/firewall for detection.
  * **User anomalies**: Look for unexpected CLI usage (e.g., `whoami`, SMB access).
  * **Network traffic**: Unusual patterns (e.g., port 4444, new sites, bulk requests). Use tools like SIEMs and NetFlow.

## **Establishing Network Visibility**

* Maintain updated **network topology diagrams** using tools like NetBrain.
* Leverage **Layer 7 firewalls** for application-level traffic monitoring.
* Establish traffic baselines to spot deviations quickly.
* Use **deep packet inspection** to analyze cleartext and encrypted traffic.

## **End Device Protection**

* Key Devices: Workstations, servers, printers, NAS, IoT devices.
* Ensure **anti-virus** and **Windows Defender** are active with firewalls enabled.
* Implement **patch management** to secure devices against exploits.

## **Mitigation Strategies**

* **Application Sandboxing**: Limit damage from compromised apps.
* **Least Privilege Access**: Grant minimum permissions needed for tasks.
* **Host Segmentation & Hardening**: Place exposed systems (e.g., web servers) in a DMZ.
* **Firewall Policies**: Block unauthorized ports and traffic; enforce NAT to disrupt reverse shells.
* A **defense-in-depth strategy** incorporating monitoring, mitigation, and visibility strengthens security posture.
