3.0 KiB
3.0 KiB
LPIC-3 332.2: Host intrusion detection
Audit rules and searches, package verification, AIDE with a scheduled check, OpenSCAP, and rootkit scanners.
Before you start
The lab has changed one configuration file that belongs to one of the
packages logrotate, sudo, or the OpenSSH client (openssh-clients on
the RHEL family, openssh-client on Ubuntu), for you to find in task 2.
Write answers to the files in /root/lab-answers/.
Do task 1's test as your own login user (not root), from your SSH or console session, so that the audit system knows who you are.
Tasks
- Install the audit tools if they're missing (
audit-ruleson the RHEL family,auditdon Ubuntu). Add two audit rules, permanently, with a file in/etc/audit/rules.d/andaugenrules: a watch on/etc/hostsfor writes and attribute changes with the keyhosts-change, and a rule, keyaccess-denied, foropenatcalls that fail withEACCESby users with a login UID of 1000 or more. Then change/etc/hosts(and put it back), try to read/etc/shadowas your login user, and find both events withausearch. - Find the changed file with your package manager's verify function, and
write its full path to
/root/lab-answers/2. - Install AIDE and write your own configuration,
/root/aide/lab.conf, that reads the database from/root/aide/aide.db, writes new ones to/root/aide/aide.db.new, uncompressed, and covers/etc/sshand/usr/sbinwith permissions, owner, group, size, mtime and SHA-256. Build the database as/root/aide/aide.db. Plant a file in/usr/sbin, change a file in/etc/ssh, see AIDE report both, and put things back. - Schedule that check nightly at 3:30 with a file in
/etc/cron.d, mailing its output to root. - RHEL family: evaluate the CIS Level 1 server profile's rules
package_aide_installedandsshd_disable_root_loginwithoscap, saving the results to/root/oscap-results.xml. - Ubuntu: install
chkrootkit,rkhunteranddebsums, record rkhunter's baseline of file properties, and run both scanners.
Hints
auditctl -w PATH -p wa -k KEY;-a always,exit -F arch=b64 -S openat -F exit=-EACCES -F 'auid>=1000' -F auid!=unset -k KEY;augenrules --load,auditctl -l;ausearch -k KEY -i,-f FILE,aureport -k --summary.rpm -Vaorrpm -V PACKAGE;dpkg --verify,debsums -as.database_in=file:...,database_out=file:...,gzip_dbout=no, a rule line such asLabRule = p+u+g+s+m+sha256, then/etc/ssh LabRule;aide --init -c FILE,aide --check -c FILE.MAILTO=root, thenminute hour day month weekday user command./usr/share/xml/scap/ssg/content/(pick the data stream for your distribution);oscap info --profiles;oscap xccdf eval --profile ... --rule xccdf_org.ssgproject.content_rule_NAME --results FILE.apt-get install --no-install-recommends;rkhunter --propupd,rkhunter --check --sk,chkrootkit -q;/var/log/rkhunter.log.