Subversion Repositories ALCASAR

Rev

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

Rev 2292 Rev 2405
Line 1... Line 1...
1
<?php
1
<?php
2
# $Id: security.php 2292 2017-06-20 14:09:37Z tom.houdayer $
2
# $Id: security.php 2405 2017-08-28 18:20:43Z tom.houdayer $
3
 
3
 
4
//gestion de la langue
4
//gestion de la langue
5
require('../lib/langues.php');
5
require('../lib/langues.php');
6
 
6
 
7
$language = 'en';
7
$language = 'en';
Line 41... Line 41...
41
<br>
41
<br>
42
 
42
 
43
 
43
 
44
<?php
44
<?php
45
if ($tab === 1) {
45
if ($tab === 1) {
-
 
46
	$spoofs = [];
46
	$filePath = '/var/Save/security/watchdog.log';
47
	$regex = '/^\[(?P<date>[0-9]{2}\/[0-9]{2}\/[0-9]{4}-[0-9]{2}:[0-9]{2}:[0-9]{2})\] : 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>.+)\)\.$/';
-
 
48
	$file = fopen('/var/Save/security/watchdog.log', 'r');
-
 
49
	if ($file) {
-
 
50
		while (!feof($file)) {
47
	$lines = file($filePath);
51
			$line = fgets($file);
-
 
52
 
-
 
53
			if (preg_match($regex, $line, $matches)) {
48
	if ($lines === false) {
54
				$spoofs[] = (object) [
-
 
55
					'date' => DateTime::createFromFormat('d/m/Y-H:i:s', $matches['date'])->format('Y-m-d H:i:s'),
-
 
56
					'ip'   => $matches['ip'],
49
		exit("Cannot open '$filePath'.");
57
					'mac'  => $matches['mac'],
-
 
58
					'user' => $matches['user']
-
 
59
				];
-
 
60
			}
-
 
61
		}
-
 
62
		fclose($file);
50
	}
63
	}
51
 
64
 
52
	$lines = array_reverse($lines);
65
	$spoofs = array_reverse($spoofs);
53
?>
66
?>
54
	<h3 style="text-align: center;"><?= $l_spoofing ?></h3>
67
	<h3 style="text-align: center;"><?= $l_spoofing ?></h3>
55
	<div class="container">
68
	<div class="container">
56
		<table class="table table-striped table-hover">
69
		<table class="table table-striped table-hover">
-
 
70
			<thead>
-
 
71
				<tr><th>Date</th><th><?= $l_ipAddress ?></th><th>MAC</th><th><?= $l_user ?></th></tr>
-
 
72
			</thead>
57
			<tbody>
73
			<tbody>
58
				<?php if (!empty($lines)): ?>
74
				<?php if (!empty($spoofs)): ?>
59
					<?php foreach ($lines as $line): ?>
75
					<?php foreach ($spoofs as $spoof): ?>
60
						<tr><td><?= $line ?></td></tr>
76
						<tr><td><?= $spoof->date ?></td><td><?= $spoof->ip ?></td><td><?= $spoof->mac ?></td><td><?= $spoof->user ?></td></tr>
61
					<?php endforeach; ?>
77
					<?php endforeach; ?>
62
				<?php else: ?>
78
				<?php else: ?>
63
					<tr><td style="text-align: center;"><?= $l_empty ?></td></tr>
79
					<tr><td colspan="4" style="text-align: center;"><?= $l_empty ?></td></tr>
64
				<?php endif; ?>
80
				<?php endif; ?>
65
			</tbody>
81
			</tbody>
66
		</table>
82
		</table>
67
	</div>
83
	</div>
68
<?php
84
<?php