eurysco

eurysco is a free and open source project based on PHP language, in order to enhance and simplify the remote administration of Microsoft operating systems with an intuitive, fast and responsive web interface

view my linkedin profileview my linkedin profile :)

Privacy Policy
     

Total sweet donations $23
Help me to support eurysco (^_^) !

Source index





0001 <?php include(str_replace('\\server', '', $_SERVER['DOCUMENT_ROOT']) . '\\include\\init_server.php'); ?>
0002 
0003 <?php
0004 
0005 $corepath = $euryscoinstallpath . '\\core';
0006 $nodespath = $euryscoinstallpath . '\\nodes';
0007 
0008 if (isset($_POST['configstatus']) && isset($_POST['agentversion']) && isset($_POST['refreshrate']) && isset($_POST['computername']) && isset($_POST['coreport']) && isset($_POST['executorport']) && isset($_POST['cpuusage']) && isset($_POST['cpumanufacturer']) && isset($_POST['cpumodel']) && isset($_POST['cpucurrentclock']) && isset($_POST['cpumaxclock']) && isset($_POST['cpuarchitecture']) && isset($_POST['cpucores']) && isset($_POST['cputhreads']) && isset($_POST['cpusockettype']) && isset($_POST['osname'])0009 
0010 	echo '<refreshrate>' . $nodesrrsetting . '</refreshrate>' . "\n";
0011 
0012 	$envcomputername = 'localhost';
0013 	if (isset($_ENV["COMPUTERNAME"])) {
0014 		$envcomputername = strtolower($_ENV["COMPUTERNAME"]);
0015 	}
0016 
0017 	if (file_exists($nodespath . '\\' . $_POST['computername'] . '\\exec.on')) { echo '<exec>on</exec>' . "\n"; } else { echo '<exec>off</exec>' . "\n"; }
0018 
0019 	$db = new SQLite3($euryscoinstallpath . '\\sqlite\\euryscoServer');
0020 	$db->busyTimeout(30000);
0021 	$db->query('PRAGMA page_size = 2048; PRAGMA cache_size = 4000; PRAGMA temp_store = 2; PRAGMA journal_mode = OFF; PRAGMA synchronous = 0;');
0022 
0023 	$hashnodesxml = '<inventory>0null</inventory>' . "\n" . '<programs>0null</programs>' . "\n" . '<processes>0null</processes>' . "\n" . '<services>0null</services>' . "\n" . '<netstat>0null</netstat>' . "\n" . '<scheduler>0null</scheduler>' . "\n" . '<events>0null</events>' . "\n" . '<nagios>0null</nagios>' . "\n";
0024 	$hashnodes = $db->query('SELECT * FROM nodesHash WHERE node = "' . strtolower($_POST['computername']) . '"');
0025 	while ($hashnode = $hashnodes->fetchArray()) {
0026 		$hashnodesxml = '<inventory>' . $hashnode['inventory'] . '</inventory>' . "\n" . '<programs>' . $hashnode['programs'] . '</programs>' . "\n" . '<processes>' . $hashnode['processes'] . '</processes>' . "\n" . '<services>' . $hashnode['services'] . '</services>' . "\n" . '<netstat>' . $hashnode['netstat'] . '</netstat>' . "\n" . '<scheduler>' . $hashnode['scheduler'] . '</scheduler>' . "\n" . '<events>' . $hashnode['events'] . '</events>' . "\n" . '<nagios>' . $hashnode['nagios'] . '</nagios>' . "\n0027 	}
0028 	echo $hashnodesxml;
0029 
0030 	echo '<settings>';
0031 	if (!file_exists($nodespath . '\\' . $_POST['computername'] . '\\config_settings.xml')) { echo '0null'; } else { echo hash_file('md5', $nodespath . '\\' . $_POST['computername'] . '\\config_settings.xml'); }
0032 	echo '</settings>' . "\n";
0033 
0034 	if (!file_exists($nodespath . '\\' . strtolower($_POST['computername']) . '\\')) { mkdir($nodespath . '\\' . strtolower($_POST['computername']) . '\\', 0777); @copy($euryscoinstallpath . '\\conf\\config_settings.xml', $nodespath . '\\' . strtolower($_POST['computername']) . '\\config_settings.xml'); }
0035 	if ($_POST['configstatus'] == 0 && file_exists($config_settings)) { @copy($euryscoinstallpath . '\\conf\\config_settings.xml', $nodespath . '\\' . strtolower($_POST['computername']) . '\\config_settings.xml'); }
0036 	$lastcom = date('Y-m-d H:i:s');
0037 	if (strtolower($_POST['computername']) == strtolower($envcomputername)) { $nodeip = '127.0.0.1'; } else { $nodeip = $_SERVER['HTTP_X_FORWARDED_FOR']; }
0038 	if (is_null($db->querySingle('SELECT node FROM nodesStatus WHERE node = "' . strtolower($_POST['computername']) . '"'))) {
0039 		$db->query('INSERT INTO nodesStatus (node, agentversion, refreshrate, computername, coreport, executorport, lastcom, computerip, cpuusage, cpumanufacturer, cpumodel, cpucurrentclock, cpumaxclock, cpuarchitecture, cpucores, cputhreads, cpusockettype, osname, osversion, osservicepack, osserialnumber, manufacturer, model, domain, totalprocesses, localdatetime, lastbootuptime, uptime, memoryusage, totalmemory, usedmemory, freememory, sysdiskuspc, sysdiskfree, sysdisksize, sysdiskused, sysdisktype, services_total, services_running, services_error, scheduler_total, scheduler_error, events_warning, events_error, nagios_status, nagiostotalcount, nagiosnormacount, nagioswarnicount, nagioscriticount, nagiosunknocount, netstatestcount, netstatliscount, netstattimcount, netstatclocount, netstat_status, inventory_status, programs_status) VALUES ("' . strtolower($_POST['computername']) . '", "' . $_POST['agentversion'] . '", "' . $_POST['refreshrate'] . '", "' . strtolower($_POST['computername']) . '", "' . strtolower($_POST['coreport']) . '", "' . strtolower($_POST['executorport']) . '", "' . $lastcom . '", "' . $nodeip . '", "' . $_POST['cpuusage'] . '", "' . $_POST['cpumanufacturer'] . '", "' . $_POST['cpumodel'] . '", "' . $_POST<0040 	} else {
0041 		$db->query('UPDATE nodesStatus SET agentversion = "' . $_POST['agentversion'] . '", refreshrate = "' . $_POST['refreshrate'] . '", computername = "' . strtolower($_POST['computername']) . '", coreport = "' . strtolower($_POST['coreport']) . '", executorport = "' . strtolower($_POST['executorport']) . '", lastcom = "' . $lastcom . '", computerip = "' . $nodeip . '", cpuusage = "' . $_POST['cpuusage'] . '", cpumanufacturer = "' . $_POST['cpumanufacturer'] . '", cpumodel = "' . $_POST['cpumodel'] . '", cpucurrentclock = "' . $_POST['cpucurrentclock'] . '", cpumaxclock = "' . $_POST['cpumaxclock'] . '", cpuarchitecture = "' . $_POST['cpuarchitecture'] . '", cpucores = "' . $_POST['cpucores'] . '", cputhreads = "' <0042 	}
0043 	$xml = '<system>' . "\n" . '	<status>' . "\n" . '		<agentversion>' . $_POST['agentversion'] . '</agentversion>' . '<refreshrate>' . $_POST['refreshrate'] . '</refreshrate>' . '<computername>' . strtolower($_POST['computername']) . '</computername>' . '<coreport>' . strtolower($_POST['coreport']) . '</coreport>' . '<executorport>' . strtolower($_POST['executorport']) . '</executorport>' . '<lastcom>' . $lastcom . '</lastcom>' . '<computerip>' . $nodeip . '</computerip>' . '<cpuusage>' . $_POST['cpuusage'] . '</cpuusage>' . '<cpumanufacturer>' . $_POST['cpumanufacturer'] . '</cpumanufacturer>' . '<cpumodel>' . $_POST['cpumodel'0044 	if (is_null($db->querySingle('SELECT node FROM xmlStatus WHERE node = "' . strtolower($_POST['computername']) . '"'))) {
0045 		$db->query('INSERT INTO xmlStatus (node, xml) VALUES ("' . strtolower($_POST['computername']) . '", "' . $xml . '")');
0046 	} else {
0047 		$db->query('UPDATE xmlStatus SET xml = "' . $xml . '" WHERE node = "' . strtolower($_POST['computername']) . '"');
0048 	}
0049 	
0050 	echo '<groups>' . "\n";
0051 	$grouplist = scandir($euryscoinstallpath . '\\groups\\');
0052 	$grouplistcheck = 'Administrators;Auditors;Operators;Users;';
0053 	foreach($grouplist as $group) {
0054 		if(pathinfo($group)['extension'] == 'xml') {
0055 			if (filesize($euryscoinstallpath . '\\groups\\' . $group) == 0) {
0056 				@unlink($euryscoinstallpath . '\\groups\\' . $group);
0057 			} else {
0058 				$groupxml = simplexml_load_string(base64_decode(base64_decode(base64_decode(file_get_contents($euryscoinstallpath . '\\groups\\' . $group, true)))));
0059 				if (hash('sha512', $groupxml->settings->groupname . 'Distributed') == $groupxml->settings->groupauth) {
0060 					$mcrykey = pack('H*', hash('sha256', hash('sha512', str_replace('.xml', '', $group))));
0061 					$groupsxml = simplexml_load_string(base64_decode(base64_decode(base64_decode(file_get_contents($euryscoinstallpath . '\\groups\\' . $group, true)))));
0062 					$usersett = unserialize(trim(mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $mcrykey, substr(base64_decode($groupsxml->settings->groupsettings), $iv_size), MCRYPT_MODE_CBC, substr(base64_decode($groupsxml->settings->groupsettings), 0, $iv_size))));
0063 					$checkprefilter = 0;
0064 					if ($usersett['nodesstatusf'] != '') {
0065 						$wl_xmlstatus = strtolower('<computername>' . $_POST['computername'] . '</computername><osname>' . $_POST['osname'] . '</osname><osversion>' . $_POST['osversion'] . '</osversion><osservicepack>' . $_POST['osservicepack'] . '</osservicepack><osserialnumber>' . $_POST['osserialnumber'] . '</osserialnumber><manufacturer>' . $_POST['manufacturer'] . '</manufacturer><model>' . $_POST['model'] . '</model><domain>' . $_POST['domain'] . '</domain>');
0066 						$prefilter = $usersett['nodesstatusf'];
0067 						$checkprefilter = 1;
0068 						if (substr($prefilter, 0, 1) != '-') {
0069 							if (preg_match_all('/' . str_replace('\\', '.', str_replace('/', '.', strtolower($prefilter))) . '/', $wl_xmlstatus) || strpos($wl_xmlstatus, strtolower($prefilter)) > -1) {
0070 								$checkprefilter = 0;
0071 							} else {
0072 								$checkprefilter = 1;
0073 							}
0074 						} else {
0075 							$notprefilter = substr($prefilter, 1);
0076 							if (!preg_match_all('/' . str_replace('\\', '.', str_replace('/', '.', strtolower($notprefilter))) . '/', $wl_xmlstatus) && !strpos($wl_xmlstatus, strtolower($notprefilter))) {
0077 								$checkprefilter = 0;
0078 							} else {
0079 								$checkprefilter = 1;
0080 							}
0081 						}
0082 					}
0083 					if ($checkprefilter == 0) {
0084 						echo '<' . str_replace('.xml', '', str_replace(' ', '', $group)) . '>';
0085 						echo '<file>' . $group . '</file>';
0086 						echo '<hash>' . hash_file('md5', $euryscoinstallpath . '\\groups\\' . $group) . '</hash>';
0087 						echo '</' . str_replace('.xml', '', str_replace(' ', '', $group)) . '>' . "\n";
0088 						$grouplistcheck = $grouplistcheck . str_replace('.xml', '', $group) . ';';
0089 					}
0090 				}
0091 			}
0092 		}
0093 	}
0094 	$grouplistcheck = trim($grouplistcheck, ';');
0095 	echo '</groups>' . "\n";
0096 
0097 	echo '<users>' . "\n";
0098 	$userlist = scandir($euryscoinstallpath . '\\users\\');
0099 	foreach($userlist as $user) {
0100 		if(pathinfo($user)['extension'] == 'xml') {
0101 			if (filesize($euryscoinstallpath . '\\users\\' . $user) == 0) {
0102 				@unlink($euryscoinstallpath . '\\users\\' . $user);
0103 			} else {
0104 				$userxml = simplexml_load_string(base64_decode(base64_decode(base64_decode(file_get_contents($euryscoinstallpath . '\\users\\' . $user, true)))));
0105 				if (hash('sha512', $userxml->settings->username . 'Distributed') == $userxml->settings->userauth) {
0106 					$grouplist = explode(';', $grouplistcheck);
0107 					foreach ($grouplist as $group) {
0108 						if (hash('sha512', $userxml->settings->username . $group) == $userxml->settings->usertype) {
0109 							echo '<' . str_replace('.xml', '', $user) . '>';
0110 							echo '<file>' . $user . '</file>';
0111 							echo '<hash>' . hash_file('md5', $euryscoinstallpath . '\\users\\' . $user) . '</hash>';
0112 							echo '</' . str_replace('.xml', '', $user) . '>' . "\n";
0113 						}
0114 					}
0115 				}
0116 			}
0117 		}
0118 	}
0119 	echo '</users>' . "\n";
0120 
0121 	echo '</euryscoServer>';
0122 
0123 }
0124 
0125 $db->close();
0126 
0127 
0128 foreach (get_defined_vars() as $key=>$val) {
0129 	if ($key != '_GET' && $key != '_POST' && $key != '_COOKIE' && $key != '_FILES' && $key != '_SERVER' && $key != '_SESSION' && $key != '_ENV') {
0130 		$$key = null;
0131 		unset($$key);
0132 	}
0133 }
0134 
0135 if (extension_loaded('zlib')) { ob_end_flush(); }
0136 
0137 ?>