Scenario
A TrueNAS server and a Kali Linux host run on a segmented lab network. Kali performs reconnaissance, finds SSH (port 22) open, and launches a brute-force attempt with the ssh-brute NSE script. On defense, the activity is detected in /var/log/auth.log and the source IP is immediately blocked with the system firewall.
Offensive
Port 22 (SSH) Discovered Open
Brute-force with NSE ssh-brute
Defensive
Incident Detection
Review authentication logs on the server to confirm repeated failures and the source IP.
1) Ensure pf is Enabled
# enable pf (if not already)
sudo pfctl -e
# check status / rules
sudo pfctl -sr
2) Add a Block Rule for the Attacker IP
Edit /etc/pf.conf and add a line replacing ATTACKER_IP with the source:
block in quick from ATTACKER_IP to any
pf.conf.3) Load the Updated Rules and Verify
sudo pfctl -f /etc/pf.conf
sudo pfctl -sr # confirm rule is present
This immediately cuts off the brute-force source while you proceed with standard IR: scoping, additional log review, credential hygiene, and hardening.