Subversion Repositories ALCASAR

Rev

Rev 2864 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 2864 Rev 2865
Line 1... Line 1...
1
<?php
1
<?php
2
# $Id: security.php 2864 2020-10-18 09:06:17Z rexy $
2
# $Id: security.php 2865 2020-10-18 22:21:46Z rexy $
3
 
3
 
4
$language = 'en';
4
$language = 'en';
5
if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
5
if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
6
    $langue = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
6
    $langue = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
7
    $language = strtolower(substr(chop($langue[0]), 0, 2));
7
    $language = strtolower(substr(chop($langue[0]), 0, 2));
Line 9... Line 9...
9
if ($language === 'fr') {
9
if ($language === 'fr') {
10
    $l_title = 'Sécurité';
10
    $l_title = 'Sécurité';
11
    $l_spoofing = "Adresse(s) MAC usurpée(s) (Watchdog)";
11
    $l_spoofing = "Adresse(s) MAC usurpée(s) (Watchdog)";
12
    $l_virus = "Virus bloqué(s) (CLAMAV)";
12
    $l_virus = "Virus bloqué(s) (CLAMAV)";
13
    $l_fail2ban = "Adresse(s) IP bloquée(s) (Fail2Ban)";
13
    $l_fail2ban = "Adresse(s) IP bloquée(s) (Fail2Ban)";
-
 
14
    $l_ban_date = "Date de bloquage";
-
 
15
    $l_unban_date = "Date de débloquage";
14
    $l_ipAddress="Adresse IP";
16
    $l_ipAddress="Adresse IP";
15
    $l_user = "L'utilisateur";
17
    $l_user = "L'utilisateur";
16
    $l_empty="Vide";
18
    $l_empty="Vide";
17
    $l_rule="Règle";
19
    $l_rule="Règle";
-
 
20
} else if ($language === 'es') {
-
 
21
    $l_title = 'Seguridad';
-
 
22
    $l_spoofing = "Direcciones MAC usurpadas (Watchdog)";
-
 
23
    $l_virus = "Virus bloqueado (CLAMAV)";
-
 
24
    $l_fail2ban = "Dirección(es) IP bloqueada(s) (Fail2Ban)";
-
 
25
    $l_ban_date = "Fecha de bloqueo"; 
-
 
26
    $l_unban_date = "Fecha de desembolso";
-
 
27
    $l_ipAddress="Dirección ip";
-
 
28
    $l_user = "El usuario";
-
 
29
    $l_empty="Vacío";
-
 
30
    $l_rule="Regla";
18
} else {
31
} else {
19
    $l_title = 'Security';
32
    $l_title = 'Security';
20
    $l_spoofing = "MAC address spoofed (Watchdog)";
33
    $l_spoofing = "MAC address spoofed (Watchdog)";
21
    $l_virus = "Virus blocked (CLAMAV)";
34
    $l_virus = "Virus blocked (CLAMAV)";
22
    $l_fail2ban = "IP address blocked (Fail2Ban)";
35
    $l_fail2ban = "IP address blocked (Fail2Ban)";
-
 
36
    $l_ban_date = "Lock date";
-
 
37
    $l_unban_date = "Unlock date";
23
    $l_ipAddress="IP address";
38
    $l_ipAddress="IP address";
24
    $l_user = "User";
39
    $l_user = "User";
25
    $l_empty="Empty";
40
    $l_empty="Empty";
26
    $l_rule="Rule";
41
    $l_rule="Rule";
27
}
42
}
Line 52... Line 67...
52
	$regex = '/^\[(?P<date>[0-9\/\-: ]+)\] : alcasar-watchdog : (?P<ip>(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])) is usurped \((?P<mac>(?:[0-9A-Fa-f]{2}[:-]){5}[0-9A-Fa-f]{2})\)\. Alcasar disconnect the user \((?P<user>.+)\)\.$/';
67
	$regex = '/^\[(?P<date>[0-9\/\-: ]+)\] : alcasar-watchdog : (?P<ip>(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])) is usurped \((?P<mac>(?:[0-9A-Fa-f]{2}[:-]){5}[0-9A-Fa-f]{2})\)\. Alcasar disconnect the user \((?P<user>.+)\)\.$/';
53
	$file = fopen('/var/Save/security/watchdog.log', 'r');
68
	$file = fopen('/var/Save/security/watchdog.log', 'r');
54
	if ($file) {
69
	if ($file) {
55
		while (!feof($file)) {
70
		while (!feof($file)) {
56
			$line = fgets($file);
71
			$line = fgets($file);
-
 
72
 
57
			if (preg_match($regex, $line, $matches)) {
73
			if (preg_match($regex, $line, $matches)) {
58
				if (preg_match('/[0-9]{2}\/[0-9]{2}\/[0-9]{4}-[0-9]{2}:[0-9]{2}:[0-9]{2}/', $matches['date'], $matches_date)) {
74
				if (preg_match('/[0-9]{2}\/[0-9]{2}\/[0-9]{4}-[0-9]{2}:[0-9]{2}:[0-9]{2}/', $matches['date'], $matches_date)) {
59
					$matches['date'] = DateTime::createFromFormat('d/m/Y-H:i:s', $matches['date'])->format('Y-m-d H:i:s');
75
					$matches['date'] = DateTime::createFromFormat('d/m/Y-H:i:s', $matches['date'])->format('Y-m-d H:i:s');
60
				}
76
				}
61
				$spoofs[] = (object) [
77
				$spoofs[] = (object) [
Line 123... Line 139...
123
		</table>
139
		</table>
124
	</div>
140
	</div>
125
<?php
141
<?php
126
} else if ($tab === 3) {
142
} else if ($tab === 3) {
127
	$bans = [];
143
	$bans = [];
128
	$regex = '/^(?P<date>[0-9]{4}-[0-9]{2}-[0-9]{2}\ [0-9]{2}:[0-9]{2}:[0-9]{2}),[0-9]{3} fail2ban\.actions\[[0-9]+\]: NOTICE \[(?P<rule>[a-zA-Z0-9_-]+)\] (?P<type>Ban|Unban) (?P<ip>[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})$/';
144
	$regex = '/^(?P<date>[0-9]{4}-[0-9]{2}-[0-9]{2}[ \t]+[0-9]{2}:[0-9]{2}:[0-9]{2}),[0-9]{3}[ \t]+fail2ban\.actions[ \t]+\[[0-9]+\]:[ \t]+NOTICE[ \t]+\[(?P<rule>[a-zA-Z0-9_-]+)\][ \t]+(?P<type>Ban|Unban)[ \t]+(?P<ip>[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})/';
129
	$file = fopen('/var/log/fail2ban.log', 'r');
145
	$file = fopen('/var/log/fail2ban.log', 'r');
130
	if ($file) {
146
	if ($file) {
131
		while (!feof($file)) {
147
		while (!feof($file)) {
132
			$line = fgets($file);
148
			$line = fgets($file);
133
 
-
 
134
			if (preg_match($regex, $line, $matches)) {
149
			if (preg_match($regex, $line, $matches)) {
135
				if ($matches['type'] === 'Ban') {
150
				if ($matches['type'] === 'Ban') {
136
					$bans[] = (object) [
151
					$bans[] = (object) [
137
						'date_ban'   => $matches['date'],
152
						'date_ban'   => $matches['date'],
138
						'date_unban' => null,
153
						'date_unban' => null,
Line 156... Line 171...
156
	<h3><?= $l_fail2ban ?></h3>
171
	<h3><?= $l_fail2ban ?></h3>
157
	<div class="container" border="1">
172
	<div class="container" border="1">
158
		<table  class="table table-striped table-hover" border="1">
173
		<table  class="table table-striped table-hover" border="1">
159
				<tr >
174
				<tr >
160
					<th>
175
					<th>
161
						Date
176
						<?= $l_ban_date ?>
162
					</th>
177
					</th>
163
					<th>
178
					<th>
164
						Date Unban
179
						<?= $l_unban_date ?>
165
					</th>
180
					</th>
166
					<th>
181
					<th>
167
						<?= $l_rule ?>
182
						<?= $l_rule ?>
168
					</th>
183
					</th>
169
					<th>
184
					<th>