Scripts
Reverse shell detection:
Dependency:
ssScript:
#!/bin/bash
# Log file path
LOG_FILE="/var/log/reverse_shell_detection_ss.log"
# Initialize log file
initialize_log() {
echo "Initializing Reverse Shell Detection Log with ss" > "$LOG_FILE"
echo "Monitoring started at $(date)" >> "$LOG_FILE"
echo "---------------------------------------------" >> "$LOG_FILE"
}
# Function to check for suspicious connections
check_connections() {
# Define common reverse shell ports
local COMMON_PORTS="4444 5555 6666"
# Use ss to list active connections
ss -tunap | grep -E "ESTAB" | awk '{print $5, $6}' | while read -r line; do
for port in $COMMON_PORTS; do
if [[ "$line" == *":$port "* ]]; then
echo "[ALERT] Potential reverse shell detected on port $port: $line" | tee -a "$LOG_FILE"
fi
done
done
}
# Main monitoring loop
initialize_log
while true; do
check_connections
# Sleep for a specified interval before checking again
sleep 60
doneLock down users:
Usage:
Script:
Last updated