iptables
rules and some other intricacies of filtering traffic in Linux.logcheck
utility logcheck
designed to monitor log files, which it, by default, hourly scans and sends unusual log entries to the administrator's email for further analysis./etc/logcheck/logcheck.logfiles
file. The default settings allow logcheck
to work normally, provided that the /etc/rsyslog.conf
file has not been completely changed.Logcheck
supports three levels of filtering: paranoid
, server
and workstation
. Using the paranoid
level results in logcheck
sending extremely long reports to the administrator. Probably, it should be used only on separate servers, such as those that play the role of firewalls. The server
level is the default; it is recommended to use it on most servers. The workstation
level, which is quite obvious from its name, was created for workstations; thanks to its use, the program produces brief reports, filtering much more messages than when using other levels of filtering.logcheck
should be configured to exclude from the reports some clearly redundant messages (which ones depend on the services installed on the system). Otherwise, be prepared for the fact that every hour you will receive long uninteresting emails. The mechanism for selecting messages for inclusion in reports is rather complicated, so it is recommended to be patient and master /usr/share/doc/logcheck-database/README.logcheck-database.gz
./etc/logcheck/cracking.d/
directory;/etc/logcheck/cracking.ignore.d/
;/etc/logcheck/violations.d/
;/etc/logcheck/violations.ignore.d/
;ignore.d
files ignore.d
used to ignore messages. For example, a message marked as a hacking attempt or a security warning (according to the rule stored in the /etc/logcheck/violations.d/myfile
file) can be ignored only when applying the rule that is stored in the /etc/logcheck/violations.ignore.d/myfile
file /etc/logcheck/violations.ignore.d/myfile
, or in the /etc/logcheck/violations.ignore.d/myfile-extension
file.Logcheck
always reports system events, unless the directories whose naming scheme is shown below indicate that these events should be ignored: /etc/logcheck/ignore.d.{paranoid,server,workstation}/
top —
program top —
an interactive tool that lists the running processes. The standard sorting of the process list is based on the amount of CPU resources consumed. If necessary, it can be activated using the key P
Other ways of sorting processes include sorting by the occupied memory (key M
), total processor usage time (key T
), and process identifier (key N
). The key k
allows you to complete the process by entering its identifier. Key r
allows you to change the priority of the process.top —
an excellent tool that helps you know which processes consume the most CPU time or take up too much memory. In particular, it is usually useful to check whether the consumption of resources by the processes corresponds to the role played by the computer, to the services it is intended to support. For example, an unknown process running under the user “www-data” is worth paying attention to. It needs to be investigated, as it may be some kind of program installed and running on the system through a vulnerability in the web application.top
tool is very flexible; from its help you can find out details on how to customize the data it displays and adapt it to your personal needs and preferences.gnome-system-monitor
graphical tool is similar to top
, it has about the same capabilities.dpkg --verify
(or dpkg -V
) command is an interesting tool that allows you to output information about system files that have been modified (perhaps by attackers), but the output of this command should be viewed with skepticism. In order to do its job, the dpkg
utility relies on the checksums stored in its own database on the hard disk (you can find it on the path /var/lib/dpkg/info/package.md5sums
). A qualified hacker can easily modify these files so that they contain new checksums for modified files. If the attacker goes even further, he will replace the package on your Debian mirror. In order to protect against such attacks, use the APT digital signature confirmation system (for more on this, see Section 8.3.6. “ Package Authentication ”) for reliable packet checking.▍What is a checksum file?
We want to remind you that a checksum is a value, often a number (albeit in hexadecimal notation) that contains something like a signature for the contents of a file. The signature is calculated using some algorithm (among them are the widely known MD5 and SHA1), which, in general, ensure that even the smallest change in the file will lead to a change in the checksum. This phenomenon is known as the avalanche effect. A simple digital signature then serves as a means to check if the contents of the file have changed. These algorithms are not amenable to inverse transformation. In other words, for most of them, knowledge of the signature does not allow restoring the data on the basis of which this signature was created. Recent studies in mathematics call into question the absoluteness of this principle, but so far in practice this is not used, since the creation of various data sets having the same checksum is still a very difficult task.
dpkg -V
command will check all installed packages and display information about those that have failed. Each character in the package information line indicates that some metadata has been checked. Unfortunately, dpkg
does not store the metadata needed for most tests, and thus displays question marks for them. At present, only if the package fails the checksum test, the figure 5 appears at the third position. # dpkg -V ??5?????? /lib/systemd/system/ssh.service ??5?????? c /etc/libvirt/qemu/networks/default.xml ??5?????? c /etc/lvm/lvm.conf ??5?????? c /etc/salt/roster
dpkg
reports a change in the ssh.service
file that the administrator made, instead of using the rules override for /etc/systemd/system/ssh.service
, (which would be stored in the /etc
directory, where the files should be stored specifying configuration changes). In addition, the command displays several configuration files (for such files, the letter “c” is displayed in the second column of the report), which were modified quite reasonably./var/lib/aide/aide.db
) and contains the relevant data (checksums, permissions, time /var/lib/aide/aide.db
) about all the system files. apt update apt install aide
aideinit
command. This operation will then be performed daily (using the /etc/cron.daily/aide
script) to check that the system files have not changed. If changes are detected, AIDE writes them to log files ( /var/log/aide/*.log
) and sends the report to the administrator by email.▍ Protection of the AIDE database
Since AIDE uses a local database to compare the state of files, the correctness of such comparisons is completely tied to the state of the database. If an attacker gains superuser rights on a compromised system, he will be able to replace the database and hide the traces of the hack. One way to prevent such an attack is to store the reference data on read-only media.
aide
package, you can use the parameters in /etc/default/aide
. Namely, the internal settings of the program are stored in the /etc/aide/aide.conf
and /etc/aide/aide.conf.d/
(in fact, these are the only files used by update-aide.conf
to form /var/lib/aide/aide.conf.autogenerated
). The configuration indicates which properties of which files should be checked. For example, the state of the log files is constantly changing, such changes can be ignored, as long as the permissions set for these files do not change. However, in the case of executable files, both their content and permissions must remain unchanged. Although these settings are not so complicated, the syntax of AIDE configuration files cannot be called completely intuitive, so for those who want to understand the AIDE configuration, we recommend reading man
aide.conf(5)
./var/lib/aide/aide.db.new
. If all committed changes are valid, it can replace the reference database.tripwire
gives is the mechanism for signing the configuration file, with the result that the attacker cannot change it so that it points to a different version of the reference database.▍Packs checksecurity and chkrootkit / rkhunter
Thechecksecurity
package is a collection of small scripts that perform basic system checks (searching for empty passwords, newsetuid
files, and so on) and issue warnings if you can find something suspicious. The package name,checksecurity
, can give the administrator the impression that by checking the system with this package, you can guarantee its security. However, do not fully rely on this package.
Thechkrootkit
andrkhunter
are designed to detect specific rootkits that can be installed in the system. Rootkits are programs that are created in order to not attract the attention of the administrator, to use the computer imperceptibly. The tests that perform the aforementioned packages cannot be called 100% reliable, but usually if they find something, it is worth paying attention to.
Source: https://habr.com/ru/post/338668/
All Articles