Reverse Shell
Last updated
Last updated
Reverse shells are a common tool in an attacker’s arsenal, enabling remote command execution on compromised systems. This guide explores methods used to establish reverse shells, detection strategies, and forensic analysis techniques.
The bash command can establish reverse shells by leveraging /dev/tcp
or /dev/udp
.
Example:
Detection:
Audit Logs:
Command History:
EDR/XDR Logs:
Monitor for bash process creation or network events involving /dev/tcp
or /dev/udp
.
Netcat is a versatile utility often used for reverse shells.
Example:
Detection:
Focus on -e
or -l
parameters.
Audit Logs:
Command History:
EDR/XDR Logs: Monitor nc process creation and check for unusual outbound connections.
socat offers more flexibility than nc, making it a preferred choice for advanced reverse shells.
Example:
Detection:
Investigate commands using exec
and tcp-connect
.
Audit Logs:
Command History:
EDR/XDR Logs: Analyze socat processes for suspicious parameters and unexpected network activity.
Continuously monitor /var/log/audit/audit.log
for specific commands and associated parameters:
Commands to Track: bash
, nc
, socat
Example:
Regularly inspect command history files for traces of suspicious commands:
Interactive Sessions:
Persistent Logs:
Employ EDR or XDR tools to:
Track Process Creation: Identify the origin of reverse shell tools.
Analyze Network Activity: Monitor outbound connections, especially to uncommon ports or suspicious IP addresses.
Set up alerts for:
Unusual Outbound Connections: Look for high-frequency requests to external IPs.
Known Malicious Indicators: Monitor outbound traffic to flagged domains or IPs.
Reverse shells exploit legitimate utilities like bash, nc, and socat for remote control.
Detection relies on monitoring suspicious process creation, command execution, and network connections.
Forensic Analysis requires correlating data from:
Audit logs (/var/log/audit/audit.log
).
Command histories (history
or .bash_history
).
EDR/XDR telemetry for process and network activity.
By continuously monitoring system activity and analyzing logs for anomalies, defenders can effectively detect and respond to reverse shell threats.