A host-based intrusion detection system.
Project description
pyHIDS
Presentation
pyHIDS is a HIDS (host-based intrusion detection system) for verifying the integrity of a system.
It is possible to use an RSA signature to check the integrity of its database.
Alerts are written in the logs of the system and can be sent via email to a list of users. You can define rules to specify files to be checked.
It is recommended to use Python >= 3.11.
Features
- checks the integrity of system's files with a list of rules;
- checks the output of commands (iptables, ...);
- uses an RSA signature to check the integrity of its database;
- alerts are written in the logs of the system;
- alerts can be sent via email to a list of users;
- alerts can be sent on IRC channels through the irker IRC client (which should be running as a daemon).
Installation
Installation as a command line tool
You can simply use pipx.
$ pipx install pyHIDS
$ export PYHIDS_CONFIG=~/.pyHIDS/conf.cfg
$ pyhids gen-keys --size 2048
Generating 2048 bits RSA keys ...
Dumping Keys
Done.
$ pyhids gen-base --sign
Generating database...
2427 files in the database.
$ pyhids run --check-signature
Verifying the integrity of the base of hashes...
Database integrity verified.
Verifying the integrity of the files...
As you can see you can skip the first step (generation of the keys) if you do not want to sign the database with the solution provided with pyHIDS (RSA) or if you simply do not want to sign the database.
As an example you can modify a character in a monitored file and relaunch the program:
$ pyhids run
Verifying the integrity of the files...
[07/19/23 15:05:31] [warning] /etc/httpd/conf/httpd.conf changed.
The program warns that the file has changed. When this happens, a warning is generated in the logs /var/log/syslog and a mail is sent to the administrator. If no change is detected only the log file is updated.
Log file generated:
$ tail log
[18/07/23 22:34:25] [notice] /bin/tload ok
[18/07/23 22:34:25] [notice] /bin/mbim-network ok
[18/07/23 22:34:25] [notice] /bin/preparetips5 ok
[18/07/23 22:34:25] [notice] /bin/grub-file ok
[18/07/23 22:34:25] [notice] /bin/xclip ok
[18/07/23 22:34:25] [notice] /bin/pamperspective ok
[18/07/23 22:34:25] [notice] /bin/pod2usage ok
[18/07/23 22:34:25] Error(s) : 0
[18/07/23 22:34:25] Warning(s) : 0
[18/07/23 22:34:25] HIDS finished.
From the repository
Get pyHIDS source code and copy the sample configuration file:
$ git clone https://github.com/cedricbonhomme/pyHIDS.git
$ cd pyHIDS/
$ cp ./conf.cfg-sample ./conf.cfg
$ poetry install
The same as explained above applies.
Configuration
The configuration file of pyHIDS looks like the following:
[irc]
channel = irc://irc.libera.chat/#testpyHIDS
host = localhost
port = 6697
[email]
enabled = 0
mail_from = pyHIDS@no-reply.com
mail_to = you_address
smtp = SMTP_server
username = your_username
password = your_password
[files]
file1 = /etc/crontab
file2 = /boot/grub/grub.cfg
file3 = /etc/shadow
file4 = /etc/networks
[rules]
rule1 = conf$ /etc
rule2 = list /etc/apt
rule3 = .* /bin
[commands]
iptables = /sbin/iptables -L
Description of the sections:
- irc: configure notifications sent via IRC;
- email: configure the email notifications. Set the value of "enabled" to 1 to activate notifications;
- files: list of files to scan;
- rules: regular expression to specify files in a folder;
- commands: command's output to check.
Automatic execution
Use the time-based job scheduler, Cron, in order to schedule system scans. In your shell enter the command:
$ crontab -e
And add the following line to check the integrity of the system every fifty minutes:
*/50 * * * * pyhids run
After each system check, pyHIDS sends a report to the administrators. In the case of an attacker who has deleted the cron line, for example.
License
pyHIDS is under GPLv3 license.
Copyright (C) 2010-2023 Cédric Bonhomme
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pyhids-0.5.3.tar.gz
.
File metadata
- Download URL: pyhids-0.5.3.tar.gz
- Upload date:
- Size: 21.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.11.4 Linux/6.1.0-10-amd64
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 74b2cd48f8d3e8eafe894b42cc257a0dfda6941b9e59fce07384c29c3eee4eb4 |
|
MD5 | 64d019f19b116550ccb2234e67c0462c |
|
BLAKE2b-256 | a230da10d2c719d56f7e6438c34bdbae66bc078d416015c07f9cab1820c8b8a5 |
Provenance
File details
Details for the file pyhids-0.5.3-py3-none-any.whl
.
File metadata
- Download URL: pyhids-0.5.3-py3-none-any.whl
- Upload date:
- Size: 38.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.11.4 Linux/6.1.0-10-amd64
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0ed297eae79a2c5264f9b4e6e1a8ad067ba394d39c12a7b4f8ba7b994e4fde9e |
|
MD5 | 02c5bb1be1bc60b9483dfa9c4a92f573 |
|
BLAKE2b-256 | b2056406b17335037dccf75a3c86a28d1a2fb5493e128177100e5867b5665f0d |