Browse code

Changed three file names and added four images.

DoubleBastionAdmin authored on 28/11/2024 02:16:32
Showing 10 changed files
... ...
@@ -2,5 +2,9 @@
2 2
 
3 3
 Versions:
4 4
 
5
-= 1.0.0 - 2024-11-28 =
5
+== 1.0.0 - 2024-11-28 ==
6 6
 * Initial Release.
7
+
8
+== 1.0.1 - 2024-11-28 ==
9
+* Changed README.txt to README.md, CONTRIBUTORS.txt to Contributors.txt, LICENSE.txt to COPYING.txt.
10
+* Added four images to show how email reports look.
7 11
\ No newline at end of file
8 12
similarity index 100%
9 13
rename from LICENSE.txt
10 14
rename to COPYING.txt
11 15
similarity index 100%
12 16
rename from CONTRIBUTORS.txt
13 17
rename to Contributors.txt
14 18
new file mode 100644
... ...
@@ -0,0 +1,141 @@
1
+<span style="display:block;height:15px!important"></span>
2
+<p align="center"><img src="https://git.doublebastion.com/shas-probe/raw/develop/img/System_Health_and_Security_Probe_logo_simple.svg" alt="System Health and Security Probe" width="300px" height="187px"/></p>
3
+
4
+<span style="display:block;height:20px!important"></span>
5
+
6
+**System Health and Security Probe is a program that runs periodically to investigate general system health and security problems and to send report emails to admins.**
7
+
8
+This program runs periodically and sends report emails to administrator(s) if it detects at least
9
+one of the following problems:
10
+
11
+* One or more services running on the host server are in failed state.
12
+
13
+* The periodic ClamAV scan has detected any viruses in the mail directories or in the Nextcloud upload
14
+  directories or the logs show recent virus detections in the incoming emails or in the files uploaded
15
+  to Nextcloud.
16
+
17
+* Any new IP address has been banned during the last run interval due to repeated failed log in
18
+  attempts against one of the applications monitored by Fail2ban.
19
+
20
+* The free disk space on all partitions is less than a threashold established by the admin.
21
+
22
+* The average CPU load in the last 15 minutes exceeded 100% utilization of all the CPU cores.
23
+
24
+All the IP addresses banned by Fail2ban are stored in the database and if one IP has been
25
+banned more than once, the 'whois' data for that IP is included in the email report. System Health 
26
+and Security Probe searches for the 'abuse' email address in the 'whois' data and writes a draft 
27
+email that can be sent manually or automatically to the entity that owns the offending IP. The draft 
28
+email includes the log lines containing the failed log in attepts of the respective IP. The text of 
29
+the draft email is included in the periodic email report sent to the admin, below the 'whois' data of 
30
+each IP that was banned more than once. If the 'automatic\_emails\_to\_isp' parameter in the 
31
+'shsp-config.php' file is set to 'yes', the program will automatically send the abuse report email 
32
+to the entity that owns the offending IP, at the moment its ban number increases by 1, if it has 
33
+been banned at least once in the past.
34
+
35
+Before sending the email report to the admin, the program compares it with the last sent report, and if 
36
+there is nothing important or new to report, the new email will not be sent, since it is assumed that
37
+the admin has already been informed about the current problems in the previous email. This is to avoid
38
+flooding admins with too many emails. For example, if at a particular moment it detects that the only
39
+problem of the server is that there are 75 banned IPs, and at the moment of the next run it detects that
40
+4 of those IPs have been debaned due to their bantime being over, it won't send the email report, because
41
+the debanning of the 4 IPs is not important enough to deserve a new email. However, if it detects that
42
+since the last run a new IP has been banned, the email report will be sent.
43
+
44
+<span style="display:block;height:20px!important"></span>
45
+
46
+### Donations
47
+
48
+* 🎁 [Donate](https://www.doublebastion.com/donations/)
49
+
50
+<span style="display:block;height:20px!important"></span>
51
+
52
+<p align="center">Extract from email report 1</p>
53
+<span style="display:block;height:10px!important"></span>
54
+<span style="display:block;margin:auto;width:412px;">![Extract from email report 1](https://git.doublebastion.com/shas-probe/raw/develop/img/shas-probe-1.png)</span>
55
+<span style="display:block;height:40px!important"></span>
56
+<p align="center">Extract from email report 2</p>
57
+<span style="display:block;height:10px!important"></span>
58
+<span style="display:block;margin:auto;width:412px;">![Extract from email report 2](https://git.doublebastion.com/shas-probe/raw/develop/img/shas-probe-2.png)</span>
59
+<span style="display:block;height:40px!important"></span>
60
+<p align="center">Extract from email report 3</p>
61
+<span style="display:block;height:10px!important"></span>
62
+<span style="display:block;margin:auto;width:412px;">![Extract from email report 3](https://git.doublebastion.com/shas-probe/raw/develop/img/shas-probe-3.png)</span>
63
+<span style="display:block;height:40px!important"></span>
64
+<p align="center">Extract from email report 4</p>
65
+<span style="display:block;height:10px!important"></span>
66
+<span style="display:block;margin:auto;width:412px;">![Extract from email report 4](https://git.doublebastion.com/shas-probe/raw/develop/img/shas-probe-4.png)</span>
67
+<span style="display:block;height:40px!important"></span>
68
+
69
+## Programming Languages
70
+<span style="display:block;height:10px!important"></span>
71
+
72
+System Health and Security Probe only uses PHP, SQL and HTML. This means it's efficient, light-weight and easy to maintain and debug.
73
+
74
+<span style="display:block;height:20px!important"></span>
75
+
76
+## Minimum Requirements
77
+<span style="display:block;height:10px!important"></span>
78
+
79
+This program is designed to be used as part of 'RED SCARF Suite'. It requires at least an abridged version 
80
+of RED SCARF Suite and Postfix, installed and configured on a Debian server as described in the 
81
+<a href="https://www.doublebastion.com/free-server/complete-guide-to-a-complete-linux-server/" rel="noreferrer noopener" target="_blank">Complete Guide to a Complete Linux Server.</a> 
82
+At least the following jails need to be configured in '/etc/fail2ban/jail.local': sshd, postfix and postfix-sasl.
83
+
84
+The user 'root' has to be allowed to send emails from command line, by specifying it in the
85
+'/etc/postfix/main.cf' file, in the 'authorized\_submit\_users' parameter.
86
+
87
+The log files written by the programs installed on the server should be rotated only when 
88
+they reach about 2M in size (with the exception of WordPress websites, whose logs need to be rotated 
89
+once every day because of Matomo), which can be configured in their respective logrotate files located 
90
+in the '/etc/logrotate.d' directory. This is because 'System Health and Security Probe' needs to read 
91
+a large number of log lines in order to find enough failed log in attempts that can be included in the 
92
+draft abuse report emails.
93
+
94
+Important !!! The ban time set for all the jails in '/etc/fail2ban/jail.local' (in seconds) must be 
95
+greater than the interval between two consecutive runs of the program, that you set in the 
96
+'shsp-config.php' file in the '$time\_in\_hours' parameter. If the run interval is set to 8 hours,
97
+which is the default, all the jails in Fail2ban must have a ban time greater than 8 hours (which
98
+means greater than 28800 seconds). Also, in '/etc/fail2ban/jail.local' it's necessary to specify a 
99
+ban time (in seconds) for each and every jail, even for the jails who use the default ban time, for 
100
+which it's not required. So, in every jail block, a 'bantime' parameter should be included.
101
+
102
+Important !!! If the run interval is changed in the 'shsp-config.php' file (in the '$time\_in\_hours' 
103
+parameter), the cron job should be changed accordingly. To run the script every 8 hours, at 5 minutes 
104
+past, the cron job should be:
105
+
106
+   5 */8 * * * php /srv/scripts/shas-probe/system-health-and-security-probe.php > /dev/null 2>&1
107
+
108
+To read the email reports sent by System Health and Security Probe you will also need an email client
109
+capable of displaying HTML emails: either a standalone email client like Thunderbird, or a web-based 
110
+client, like Roundcube.
111
+
112
+<span style="display:block;height:20px!important"></span>
113
+
114
+## Installation
115
+<span style="display:block;height:10px!important"></span>
116
+
117
+<a href="https://www.doublebastion.com/install-system-health-and-security-probe/" rel="noreferrer noopener" target="_blank">This chapter</a> of our Complete Guide to a Complete Linux Server 
118
+explains in detail how to install and use this application.
119
+
120
+<span style="display:block;height:20px!important"></span>
121
+
122
+## Contribute
123
+<span style="display:block;height:10px!important"></span>
124
+
125
+This is the official git repository of System Health and Security Probe. The <a href="https://github.com/DoubleBastionAdmin/shas-probe" rel="noreferrer noopener" target="_blank">GitHub 
126
+System Health and Security Probe repository</a> is just a pointer to this repository. We don’t use GitHub for developing System Health and Security Probe because GitHub is owned by one 
127
+of the companies that proved their disrespect for digital freedom over the years and because centralized services create autonomy and privacy issues, in spite of all their advantages.
128
+
129
+If you want to contribute code to this project, please submit <a href="https://git.doublebastion.com/shas-probe/pullrequests/contrib" rel="noreferrer noopener" target="_blank">this form</a>, 
130
+mentioning your intended changes. We'll send you the credentials needed to push code to the "contrib" branch of this repository. After we review the changes, we can include them in the 
131
+project.
132
+
133
+Please post any bugs that are not security related, or feature requests, on the <a href="https://git.doublebastion.com/shas-probe/issues/develop" rel="noreferrer noopener" target="_blank">
134
+issue tracker</a>. If you notice bugs related to security, don’t post them on the issue tracker; instead, send them to manager [at] doublebastion [dot] com .
135
+
136
+<span style="display:block;height:20px!important"></span>
137
+
138
+## License
139
+<span style="display:block;height:10px!important"></span>
140
+
141
+System Health and Security Probe is licensed under the GNU General Public License Version 3 or any later version.
0 142
deleted file mode 100644
... ...
@@ -1,129 +0,0 @@
1
-/**
2
- *  "System Health and Security Probe" is a program that runs periodically to 
3
- *  investigate general system health and security problems and to send report
4
- *  emails to admins. It's designed to be used as part of RED SCARF Suite.
5
- *  It requires at least an abridged version of RED SCARF Suite and Postfix, 
6
- *  installed and configured on a Debian server as described in the "Complete
7
- *  Guide to a Complete Linux Server". For more details, please see the
8
- *  "README.txt" file.         
9
- *                                                                                         
10
- *  Copyright (C) 2024  Double Bastion LLC <www.doublebastion.com>           
11
- *                                                                                         
12
- *  This file is part of "System Health and Security Probe".                               
13
- *                                                                                         
14
- *  "System Health and Security Probe" is free software: you can redistribute
15
- *  it and/or modify it under the terms of the GNU General Public License as                  
16
- *  published by the Free Software Foundation, either version 3 of the License,            
17
- *  or (at your option) any later version.                                                 
18
- *                                                                                         
19
- *  This program is distributed in the hope that it will be useful,                        
20
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of                         
21
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                          
22
- *  GNU General Public License for more details.                                           
23
- *                                                                                         
24
- *  You should have received a copy of the GNU General Public License                      
25
- *  along with this program.  If not, see <http://www.gnu.org/licenses/>.                 
26
- */
27
-
28
-
29
-
30
-DESCRIPTION:
31
-
32
- This program runs periodically and sends a report email to the administrator(s) if it detects at least
33
- one of the following problems:
34
-
35
- - One or more services running on the host server is in failed state.
36
-
37
- - The periodic ClamAV scan has detected any viruses in the mail directories or in the Nextcloud upload
38
-   directories or the logs show recent virus detections in the incoming emails or in the files uploaded
39
-   to Nextcloud.
40
-
41
- - Any new IP address has been banned during the last run interval due to repeated failed log in
42
-   attempts against one of the applications monitored by Fail2ban.
43
-
44
- - The free disk space on all partitions is less than a threashold established by the admin.
45
-
46
- - The average CPU load in the last 15 minutes exceeded 100% utilization of all the CPU cores.
47
-
48
- It stores all the IP addresses banned by Fail2ban in the database and if one IP has been
49
- banned more than once, it includes the 'whois' data for that IP in the email report. It searches
50
- for the 'abuse' email address in the 'whois' data and writes a draft email that can be manually sent
51
- by the admin to the entity that owns the offending IP, to report the repeated attacks. The draft email
52
- includes the log lines containing the failed log in attepts of that IP. The text of the draft email is
53
- included in the periodic email report sent to the admin, below the 'whois' data of each IP that was
54
- banned more than once. If the 'automatic_emails_to_isp' parameter in the 'config' file is set to 'yes',
55
- the program will automatically send the abuse report email to the entity that owns the offending IP,
56
- at the moment its number of bans increases by 1, if it has been banned at least once in the past.
57
-
58
- Before sending the email report to the admin, the program compares it with the last sent report, and if 
59
- there is nothing important or new to report, the new email will not be sent, since it is assumed that
60
- the admin has already been informed about the current problems in the previous email. This is to avoid
61
- flooding the admin with too many emails. For example, if at a particular moment it detects that the only
62
- problem of the server is that there are 75 banned IPs, and at the moment of the next run it detects that
63
- 4 of those IPs have been debaned due to their bantime being over, it won't send the email report, because
64
- the debanning of the 4 IPs is not important enough to deserve a new email. However, if it detects that
65
- since the last run a new IP has been banned, the email report will be sent.
66
-
67
-
68
-REQUIREMENTS:
69
-
70
- This program is designed to be used as part of 'RED SCARF Suite'. It may work in other contexts but
71
- only if heavily modified. It requires at least an abridged version of RED SCARF Suite and Postfix, 
72
- installed and configured on a Debian server as described in the "Complete Guide to a Complete Linux 
73
- Server". At least the following jails need to be set in '/etc/fail2ban/jail.local':
74
-
75
-    sshd, postfix, postfix-sasl
76
-
77
- In general, the log files written by the programs installed on the server should be rotated only when 
78
- they reach about 2M in size (with the exception of WordPress websites, whose logs need to be rotated 
79
- once every day because of Matomo), which can be configured in their respective logrotate files located 
80
- in the '/etc/logrotate.d' directory. This is because 'System Health and Security Probe' needs to read 
81
- a large number of log lines in order to find enough failed log in attempts that can be included in the 
82
- draft abuse report emails.
83
-
84
- Important !!! The ban time set for all the jails in '/etc/fail2ban/jail.local' (in seconds) must be 
85
-    greater than the interval between two consecutive runs of the program, that you set in the 
86
-    'shsp-config.php' file in the '$time_in_hours' parameter. If the run interval is set to 8 hours,
87
-    which is the default, all the jails in Fail2ban must have a ban time greater than 8 hours (which
88
-    means greater than 28800 seconds). Also, in '/etc/fail2ban/jail.local' it's necessary to specify a 
89
-    ban time (in seconds) for each and every jail, even for the jails who use the default ban time, for 
90
-    which it's not required. So, in every jail block, a 'bantime' parameter should be included.
91
-
92
- Important !!! If you change the run interval in the 'shsp-config.php' file (in the '$time_in_hours' 
93
-    parameter), you should change the cron job accordingly. To run the script every 8 hours, at 5 minutes 
94
-    past, the cron job should be:
95
-
96
-    5 */8 * * * php /srv/scripts/shas-probe/system-health-and-security-probe.php > /dev/null 2>&1
97
-
98
-
99
-INSTALLATION:
100
-
101
- Once the applications that make up RED SCARF Suite are installed (at least the 10 kernel components of 
102
- the suite and Postfix), to start using this program just copy all its files and directories to 
103
- '/srv/scripts/shas-probe' (or in another suitable location of your choice), then create a MariaDB database, 
104
- user and password, give the user all the priviledges over that database, except GRANT, then copy the 
105
- database name, user and password in the corresponding parameters of the 'shsp-config.php' file. Also, set 
106
- the value of all the other parameters in the 'shsp-config.php' file.
107
-
108
- Add a cronjob to crontab (use the 'crontab -e' command) like the following:
109
-
110
-    # Run System Health and Security Probe every 8 hours
111
-    5 */8 * * * php /srv/scripts/shas-probe/system-health-and-security-probe.php > /dev/null 2>&1
112
-
113
- Next, create the directory to store the periodic ClamAV scan reports. The default name and location for this
114
- directory is '/srv/scripts/detections' but you can change it and mention it as such in the 'shsp-config.php' 
115
- file. Then set up two cronjobs to get ClamAV to scan two sensitive directories. Keep the file names 
116
- 'clamav_nextcloud_report' and 'clamav_mail_report' unchanged, as shown below. You can change the directory 
117
- for these files ('/srv/scripts/detections') and the time and frequency of scanning, according to your needs.
118
- Replace 'example.com' with your domain:
119
-
120
-    # Scan the '/var/www/cloud.example.com/data' directory and the '/var/vmail' directory with ClamAV every three days
121
-    5 3 */3 * * cat /dev/null > /srv/scripts/detections/clamav_nextcloud_report && clamdscan --fdpass --quiet /var/www/cloud.example.com/data -l /srv/scripts/detections/clamav_nextcloud_report
122
-    40 3 */3 * * cat /dev/null > /srv/scripts/detections/clamav_mail_report && clamdscan --fdpass --quiet /var/vmail -l /srv/scripts/detections/clamav_mail_report
123
- 
124
- That's it, the program is ready to fulfill its mission. To be able to see the email reports properly, your email client should accept html emails.
125
-
126
-
127
-LICENCE:
128
- GNU GENERAL PUBLIC LICENSE v3+
129
-
130 0
new file mode 100644
131 1
Binary files /dev/null and b/img/shas-probe-1.png differ
132 2
new file mode 100644
133 3
Binary files /dev/null and b/img/shas-probe-2.png differ
134 4
new file mode 100644
135 5
Binary files /dev/null and b/img/shas-probe-3.png differ
136 6
new file mode 100644
137 7
Binary files /dev/null and b/img/shas-probe-4.png differ
... ...
@@ -1333,7 +1333,7 @@ if (file_exists(dirname(__FILE__) . '/shsp-config.php')) {
1333 1333
  <div style='background-color:#f1f9ff;padding:4px 8px;'>
1334 1334
  <div style='display: block; margin: 6px auto; width: 229px; height: 170px;'><img src='cid:logo-". $separator ."'></div>
1335 1335
  <p>Hello,</p>
1336
- <p>This is an automated message sent by System Health and Security Probe v. 1.0.0. Host: " . $nameofhost  . ".<br><br>
1336
+ <p>This is an automated message sent by System Health and Security Probe v. 1.0.1. Host: " . $nameofhost  . ".<br><br>
1337 1337
  System Health and Security Probe runs regularly and investigates if any service running on the server is in failed state, if ClamAV
1338 1338
  antivirus has detected any virus in the incoming emails or in the files uploaded to Nextcloud, if any IP address has been banned due to repeated
1339 1339
  failed log in attempts against one of the applications monitored by Fail2ban, if the free storage space on all partitions is under a certain