Repository navigation
Expand file tree
/
Copy pathfixprivate.php
More file actions
58 lines (43 loc) · 2.05 KB
/
Copy pathfixprivate.php
File metadata and controls
58 lines (43 loc) · 2.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
chdir('../../');
include_once('./include/cli_check.php');
include_once($config['base_path'] . '/plugins/flowview/functions.php');
include_once($config['base_path'] . '/lib/time.php');
$tables = db_fetch_assoc('SELECT TABLE_NAME FROM information_schema.TABLES WHERE TABLE_NAME LIKE "plugin_flowview_raw%"');
if (sizeof($tables)) {
foreach($tables as $table) {
print "Checking Table: " . $table['TABLE_NAME'] . PHP_EOL;
$src_ips = db_fetch_assoc('SELECT DISTINCT INET6_NTOA(src_addr) AS src_addr
FROM ' . $table['TABLE_NAME'] . '
WHERE INET6_NTOA(src_addr) LIKE "192.%"
AND INET6_NTOA(src_addr) NOT LIKE "192.168.%"');
if (sizeof($src_ips)) {
print "There are " . sizeof($src_ips) . " Source DNS records to fix" . PHP_EOL;
foreach($src_ips as $ip) {
$dns = flowview_get_dns_from_ip($ip['src_addr']);
$parts = array_reverse(explode('.', $dns));
$rdns = $parts[1] . '.' . $parts[0];
print "Repair: " . $ip['src_addr'] . ", To: " . $dns . ", RDNS: " . $rdns . PHP_EOL;
$sql = 'UPDATE ' . $table['TABLE_NAME'] . ' SET src_domain = ' . db_qstr($dns) . ', src_rdomain = ' . db_qstr($rdns) . ' WHERE INET6_NTOA(src_addr) = ' . db_qstr($ip['src_addr']);
db_execute($sql);
//print $sql . PHP_EOL;
}
}
$dst_ips = db_fetch_assoc('SELECT DISTINCT INET6_NTOA(dst_addr) AS dst_addr
FROM ' . $table['TABLE_NAME'] . '
WHERE INET6_NTOA(dst_addr) LIKE "192.%"
AND INET6_NTOA(dst_addr) NOT LIKE "192.168.%"');
if (sizeof($dst_ips)) {
print "There are " . sizeof($src_ips) . " Destination DNS records to fix" . PHP_EOL;
foreach($dst_ips as $ip) {
$dns = flowview_get_dns_from_ip($ip['dst_addr']);
$parts = array_reverse(explode('.', $dns));
$rdns = $parts[1] . '.' . $parts[0];
print "Repair: " . $ip['dst_addr'] . ", To: " . $dns . ", RDNS: " . $rdns . PHP_EOL;
$sql = 'UPDATE ' . $table['TABLE_NAME'] . ' SET dst_domain = ' . db_qstr($dns) . ', dst_rdomain = ' . db_qstr($rdns) . ' WHERE INET6_NTOA(dst_addr) = ' . db_qstr($ip['dst_addr']);
db_execute($sql);
//print $sql . PHP_EOL;
}
}
}
}