Linux: Compliance and Audit
Detection and Response
Anti-malware tools
-
CalmAV
: an open-source anti-malware option for Linux systems. Runclamscan -r /usr
to scan each file against recent virus database. -
Linux Malware Detect
(LMD): LMD is built on ClamAV to automatically scan uploads for PHP backdoors and known malware families -
rkhunter
: used for rootkit detection. Run it withrkhunter --check
to check for rootkits. -
chkrootkit
: is used to inspect the system for hidden binaries, suspicious configurations, and tampered libraries
Indicators of Compromise (IoCs)
IoCs are things bad actors leave behind such as unexpected processes, odd network connections, unauthorized file changes, and more.
# to hunt for brute force login attempts
grep -i 'failed password' /var/log/auth.log
# to see open ports
ss -tulnp
We can use specialized tools like YARA
, auditd
, and Wazuh
to hunt for IoCs.
Vulnerability Categorization
Vulnerability categorization is the practice of systematically identifying and describing software flaws.
CVE
: Common Vulnerabilities and Exposures
CVE-YYYY-NNNNN:
-
YYYY: Year of the CVE
-
NNNNN: Sequence number of the year
CVSS
Common Vulnerability Scoring System
CVSS Categorization:
-
0.0: None
-
0.1-3.9: Low
-
4.0-6.9 Medium
-
7.0-8.9 High
-
9.0.10.0 Critical
Vulnerability Management
Service Misconfigurations
A service misconfiguration occurs when a Linux daemon is left with unsafe defaults or overly permissive settings. For example:
-
leaving SSH configured to allow password-based root user login
-
binding critical services to all network interfaces (0.0.0.0) instead of localhost
Backporting Patches
Backporting patches is the process of taking security fixes from a newer version of a package and applying them to the older version running on the system.
Vulnerability Detection
Port Scanners
Port scanners detect open network ports and services running on those ports.
-
Nmap
: runnmap -sS -sV 10.0.0.0/24
to process a stealth scan -
Zenmap
: GUI version of Nmap
Protocol analyzers (or packet sniffers)
Protocol analyzers allow deeper inspection of the data moving through these ports by capturing and examining the network traffic.
-
Wireshark
: a GUI tool that offers advanced packet analysis for many network protocols -
Tshark
: The CLI version of Wireshark -
tcpdump
: useful for remote management.tcpdump -i eth0 port 443 -w capture.pcap
Standards and Audit
Center for Internet Security Benchmarks
CIS provide detailed, expert-developed best practices for configuring systems securely. From password policies to disabling unnecessary services. It gives a standardized way to protect systems and prove compliance.
OpenSCAP - Open Security Content Automation Protocol
OpenSCAP allows admins to scan systems for compliance, identify security gaps, and even apply fixes, all based on recognized standards. It is a free and open-source tool that uses SCAP content to scan systems and tell how secure they are.
File Integrity Verification
Signed Package Verification
Signed Package Verification
helps confirmed that the package being installed originates from a trusted source and has not been modified since its publication.
Installed File Verification
Installed File Verification
allows periodic checks to ensure that none of the system files have been changed unexpectedly.
File Integrity Tools
Rootkit Humber krhumter
rkhunter
is a lightweight tool that scans systems for signs of rootkits, backdoors, and known vulnerabilities by comparing system files and settings against a database of suspicious patterns.
# to do an interactive check for issues
rkhunter --check
# to do a non-interactive check
rkhunter --check --skip-keypress
# to update the toolkit database up to date
rkhunter --update
It is common to schedule rkhunter as a cron job to scan system and alert admin if anything suspicious is found.
Advanced Intrusion Detection Environment (AIDE)
AIDE builds a baseline snapshot of selected files and directories, captures details, and then compares the system to the snapshot during regular scans.
# to init AIDE
aide --init
# to detect changes
aide --check
Data Destruction Overwriting Tools
Data destruction overwriting tools overwrite deleted data with random or specific patterns to prevent recovery, used in sensitive and enterprise environments.
shred
shred
securely deletes individual files by overwriting them with random data multiple times.
# to destroy a file
shred -u -v -n 5 old_secrets.txt
dd if=/dev/urandom
This command is used to overwrite entire disks or partitions with random bits, preventing recovery of any previous contents.
# to overwrite a disk or partition with random bits
dd if=/dev/urandom of=/dev/sdc1 bs=1M status=progress
badblocks -W
badblocks
is used to check disk errors, but in write mode it can also destroy data by repeatedly overwriting the disk with test patterns.
# to erase a device
badblocks -wsv /dev/sdc2
Cryptographic Data Destruction
cryptsetup with LUKS
cryptsetup
is used to encrypt an entire disk or partition. It can also be used to permanently destroy encrypted data by simply erasing the encryption header or one or more keyslots. The keyslots stores and encrypted copy of the master key.
# to erase cryptsetup header
cryptsetup luksErase /dev/sdb
zuluCrypt
zuluCrypt
is a GUI and CLI tool for managing encrypted volumes. It supports LUKS volumes.
# to wipe en encrypted device
zuluCrypt-cli -z -d /dev/sdb1
Software Supply Chain
GPG - GNU Privacy Guard
GPS ensures that software comes from a trusted source and hasn't been tampered with.
SBOM - Software Bill of Materials
SBOM is the detailed ingredient list for software, listing libraries, dependencies, and open-source components included in the application.
CI/CD
CI/CD is the process that automates how code is built, tested, and released, and it's the engine that keeps the modern software supply chain moving. Popular tools that is used in CI/CD are Jenknis GitLab CI, and GitHub Actions.
Security Banners
Tools used to show banners:
/etc/issue
/etc/issue
show messages before login on local terminals
example of message: Authorized access only. This is Service 1 - Production
# to change the message
echo "Authorized access only!" | sudo tee /etc/issue
/etc/issue.net
/etc/issue.net
show messages before login over remote access like SSH. It is often used for legal warnings o policy notices.
example of message: Warning: Unauthorized access to this system is prohibited and will be prosecuted.
/etc/motd`
/etc/motd
(motd
= message of the day) show messages after successful login. It is commonly used to communicate helpful information to users.
example of message: System maintenance scheduled for Saturday at 11 PM. Please save your work.
# to change the message
echo "System maintenance scheduled for Saturday at 11 PM. Please save your work." | sudo tee /etc/motd