Shell script for security auditing on Linux systems. Identifies misconfigurations, privilege escalation vectors, and hardening failures.
Lightweight offline tool for quick security audits on Linux systems, focused on:
- Detection of suspicious privileged accounts
- Files with dangerous permissions
- Insecure SSH configurations
- High-risk open ports
- SUID/SGID binaries
- Sudoers configuration
- System package integrity
- Brute force login attempts
- Persistence mechanisms (cron, systemd)
- Orphaned files
- Firewall and update status
Detects non-root accounts with UID 0 (full privileges).
awk -F: '$3 == 0 { print $1 }' /etc/passwd | awk '!/root/'Risk: Backdoor accounts, persistence after compromise.
Searches for files writable by any user on the system.
find / -xdev -type f -perm -0002Excludes: /proc, /sys, /dev, /run, /tmp, /var/tmp
Risk: Code injection, modification of binaries or critical configs.
Validates critical OpenSSH configurations using sshd -T:
| Directive | Secure Value |
|---|---|
PermitRootLogin |
no / prohibit-password |
PasswordAuthentication |
no |
MaxAuthTries |
≤ 4 |
X11Forwarding |
no |
Also detects:
- Presence of
sshddaemon - Service state (
systemctl) - Support for
sshandsshdas unit names
Risk: Brute-force, unauthorized remote access, lateral movement.
Enumerates TCP/UDP ports with ss -tulpn.
Risk Classification:
| Level | Ports |
|---|---|
| High | 21, 22, 23, 139, 445, 3389, 5900, 3306, 5432, 6379, 27017, 11211 |
| Medium | 25, 53, 8080 |
Risk: Increased attack surface, unnecessarily exposed services.
Checks active firewalls:
ufwfirewalldnftablesiptables
Logic:
- No firewall installed →
CRITICAL - Firewall installed but inactive →
CRITICAL
Risk: Unfiltered traffic, direct service exposure.
Searches for binaries with SUID/SGID bits:
find / -xdev -type f -perm /6000Analysis:
- Compares against whitelist of known binaries
- Flags binaries in
/tmpor/var/tmp - Detects non-root ownership
Output Format:
| Field | Description |
|---|---|
| PATH | Binary path |
| TYPE | SUID / SGID |
| OWNER | File owner |
| STATUS | OK / WARNING |
Risk: Privilege escalation via local exploits.
Parses /etc/os-release to identify family:
debian→ Debian, Ubunturhel→ RHEL, CentOS, Rocky, AlmaLinux, Fedoraunknown→ Other distros
Checks for pending updates:
| OS Family | Command |
|---|---|
| Debian | apt update |
| RHEL | dnf check-update |
Limitation: Output parsing can be inconsistent.
Risk: Known vulnerabilities not patched.
Detects accounts in /etc/shadow with empty password field:
awk -F: '$2 == "" { print $1 }' /etc/shadowRisk: Login without authentication, control bypass.
Searches for files without valid user or group owner in:
/etc,/home,/root,/var/usr/local,/opt,/srv/tmp,/var/tmp
Separated by type:
-nouser(no owner)-nogroup(no group)
Risk: Remnants of deleted accounts, potential payload persistence.
Analyzes /etc/sudoers and files in /etc/sudoers.d/ for dangerous configurations.
Checks:
NOPASSWD: Users who can execute commands as root without a password.- Broad
ALLpermissions: Users or groups withALL=(ALL:ALL) ALL(excluding root).
Risk: Privilege escalation, unauthorized administrative actions.
Terminal:
- Colored output (OK, WARNING, CRITICAL, INFO)
- Hierarchical structure
File:
Directory: ./reports/
Generated files:
result_YYYY-MM-DD_HH-MM-SS.txt(clean output)hash_result_YYYY-MM-DD_HH-MM-SS.txt(SHA256)
Security:
chmod 700 reports/chmod 600on reports- SHA256 hash for integrity
git clone https://github.com/rodrigo-tripa/linux-security-audit-tool.git
cd linux-security-audit-tool
chmod +x audit.shGenerates report file only:
sudo ./audit.shTerminal output + file:
sudo ./audit.sh -vReports saved in: ./reports/result_<timestamp>.txt
| Component | Required? | Notes |
|---|---|---|
| Linux | ✅ | Debian/Ubuntu or RHEL-based |
| Bash | ✅ | Version 4+ |
| Root | ✅ | Recommended for full visibility |
systemctl |
✅ | For service checks |
ss |
✅ | Package iproute2 |
find, stat |
✅ | Coreutils |
sha256sum |
✅ | Coreutils |
sshd |
Optional (skipped if not installed) |
- Scans without root will have reduced visibility
- Some checks may fail (
/etc/shadow, etc)
- SUID/SGID scan can be slow on large systems
- World-writable scan uses
-xdev(doesn't cross mount points)
apt updateanddnf check-updatecan have unstable outputs- Depends on specific text format
- Assumes systemd for state verification
- May not detect custom firewalls
- Risk classification is static
ss -tulpnrequires root to see PIDs- Fallback
ss -tulnloses process mapping
- Support for kernel logs (dmesg)
- Audit of suspicious cron jobs
- Verification of loaded kernel modules
- SELinux/AppArmor status check
- Scan for known backdoors (rootkits)
- JSON/CSV report output for parsing
- Diff mode (compare 2 reports)
- Protected directory (
700) - Files with
600(owner-only) - SHA256 hash to verify integrity
- Don't share reports without sanitizing hostnames/IPs
- Delete old reports (
./reports/) - Run in controlled environment for testing
Pull requests are welcome. For large changes:
- Open an issue first to discuss
- Test on both Debian and RHEL-based if possible
- Keep code comments in English
- Follow existing output style
MIT License - see LICENSE
This tool is for auditing legitimate systems where you have authorization. I'm not responsible for misuse.