Install
openclaw skills install sys-guard-linux-remediatorHost-based Linux incident response and remediation skill focused on precise threat detection, forensic-safe data collection, firewall control (iptables/nftables), integrity validation, and controlled remediation while preserving system stability.
openclaw skills install sys-guard-linux-remediatorThis skill provides a structured, forensically-aware framework for analyzing and securing a Linux host during or after a security event.
It emphasizes:
bash or POSIX sh⚠️ If running inside Docker, Kubernetes, LXC, or other containers, firewall, audit, and service commands may not reflect the host system.
Modern Linux systems may use:
iptables-legacyiptables-nft (compatibility wrapper)nftablesfirewalld (RHEL-family default)iptables --version
which nft
systemctl status firewalld
If nftables is active:
nft list ruleset
Do NOT assume iptables -L represents the full firewall state.
| Distribution | Primary Log File |
|---|---|
| Ubuntu/Debian | /var/log/syslog |
| RHEL/CentOS/Fedora | /var/log/messages |
| All modern systemd | journalctl |
Always prefer:
journalctl -xe
ss -tulpn
ss -antp | grep ESTABLISHED
iptables -L -n -v --line-numbers
iptables -S
nft list ruleset
ss -lntup
Avoid unnecessary full scans of localhost unless required.
nmap -sV -T3 -p- localhost
tcpdump -i any -nn -c 100
ps auxww --forest
top
lsof -p <PID>
strace -p <PID>
⚠️
stracemay change process behavior. Use carefully during live compromise.
lsmod
dmesg | tail -50
rkhunter --check
chkrootkit
May produce false positives. Validate findings manually.
clamscan -r /home
Use selectively; large scans increase I/O and may alter access timestamps.
lynis audit system
Install:
apt install aide
# or
dnf install aide
Initialize:
aideinit
mv /var/lib/aide/aide.db.new.gz /var/lib/aide/aide.db.gz
Run Check:
aide --check
rpm -Va
apt install debsums
debsums -s
Install:
sudo mkdir -p /opt/forensics
sudo wget -P /opt/forensics https://raw.githubusercontent.com/DidierStevens/DidierStevensSuite/master/base64dump.py
sudo wget -P /opt/forensics https://raw.githubusercontent.com/DidierStevens/DidierStevensSuite/master/re-search.py
sudo wget -P /opt/forensics https://raw.githubusercontent.com/DidierStevens/DidierStevensSuite/master/zipdump.py
sudo wget -P /opt/forensics https://raw.githubusercontent.com/DidierStevens/DidierStevensSuite/master/1768.py
sudo wget -P /opt/forensics https://raw.githubusercontent.com/DidierStevens/DidierStevensSuite/master/pdf-parser.py
sudo wget -P /opt/forensics https://raw.githubusercontent.com/DidierStevens/DidierStevensSuite/master/oledump.py
sudo chmod +x /opt/forensics/*.py
python3 /opt/forensics/base64dump.py file.txt
python3 /opt/forensics/re-search.py -n ipv4 logfile
python3 /opt/forensics/zipdump.py suspicious.zip
python3 /opt/forensics/1768.py payload.bin
python3 /opt/forensics/pdf-parser.py file.pdf
python3 /opt/forensics/oledump.py file.doc
Static inspection only. Never execute suspicious files.
who -a
last -a
Ubuntu/Debian:
journalctl -u ssh.service | grep "Failed password"
RHEL/Fedora:
journalctl -u sshd.service | grep "Failed password"
journalctl _COMM=sudo
ausearch -m USER_AUTH,USER_LOGIN,USER_CHAUTHTOK
iptables -I INPUT 1 -s <IP> -j DROP
nft add rule inet filter input ip saddr <IP> drop
If firewalld is active:
firewall-cmd --add-rich-rule='rule family="ipv4" source address="<IP>" drop'
iptables (Debian):
netfilter-persistent save
iptables (manual save):
iptables-save > /etc/iptables/rules.v4
firewalld:
firewall-cmd --runtime-to-permanent
nftables:
nft list ruleset > /etc/nftables.conf
Preferred escalation:
kill -TERM <PID>kill -STOP <PID> for analysiskill -KILL <PID> only if necessaryAvoid killall or broad pkill.
systemctl stop <service>
systemctl disable <service>
systemctl mask <service>
crontab -l
ls -lah /etc/cron*
ls -lah /etc/systemd/system/
cat /etc/rc.local
Check status:
getenforce
Review denials:
ausearch -m AVC
sha256sum file
mkdir -p /root/quarantine
mv file /root/quarantine/file.vir
date -u
Document:
lynis audit systemtcpdumpzipdumpThese guardrails are mandatory and apply to all remediation activity. Their purpose is to prevent self-inflicted outages, preserve forensic integrity, and ensure reversible, controlled incident response.
Before executing any remediation command:
Record timestamp (UTC):
date -u
Run a discovery command to capture current state:
ss -tulpnss -antpiptables -L -n -vnft list rulesetfirewall-cmd --list-allAfter remediation:
Never assume a command succeeded without verifying its effect.
To prevent catastrophic system damage:
NEVER use:
rm -rf *rm -rf /killallpkill patternsAlways:
/tmp/malware.bin)kill -TERM <PID>)ls -lah <file>sha256sum <file>
Wildcard deletions and pattern-based termination are prohibited during incident response.
After containment of a malicious process or service, immediately inspect for persistence mechanisms.
crontab -l
ls -lah /etc/cron*
systemctl list-unit-files --type=service
systemctl list-timers --all
ls -lah /etc/systemd/system/
ls -lah /etc/init.d/
cat /etc/rc.local
ls -lah ~/.config/systemd/user/
cat ~/.ssh/authorized_keys
After removal of malicious artifacts:
aide --check
rpm -Va
debsums -s
Do not consider a threat eradicated until persistence mechanisms are eliminated.
Before modifying firewall rules:
Confirm SSH listening port:
ss -tulpn | grep ssh
Confirm an explicit ACCEPT rule exists for:
NEVER:
iptables -F
NEVER set a default DROP policy without verifying SSH access rule exists.
Firewall rule changes are runtime by default and may not survive reboot.
Runtime only until saved:
iptables-save > /etc/iptables/rules.v4
If using netfilter-persistent:
netfilter-persistent save
service iptables save
Runtime-to-permanent:
firewall-cmd --runtime-to-permanent
Persist ruleset:
nft list ruleset > /etc/nftables.conf
Document:
Before deleting or killing:
Hash the artifact:
sha256sum <file>
Move to quarantine:
mkdir -p /root/quarantine
mv <file> /root/quarantine/<file>.vir
Record:
Avoid kill -9 unless absolutely required. Prefer:
kill -TERM <PID>kill -STOP <PID> (if forensic inspection needed)kill -KILL <PID> only as last resortEvery remediation action must include:
date -uRemediation without documentation is non-compliant.
All actions must follow:
Contain first. Eradicate methodically. Recover cautiously.