2007-04-03 14:10:23 +00:00
|
|
|
<?php
|
|
|
|
|
2015-07-13 20:10:26 +02:00
|
|
|
/*
|
2016-08-20 12:16:55 +01:00
|
|
|
* LibreNMS
|
2012-05-09 10:01:42 +00:00
|
|
|
*
|
2016-08-20 12:16:55 +01:00
|
|
|
* This file is part of LibreNMS.
|
2012-05-09 10:01:42 +00:00
|
|
|
*
|
2016-08-20 12:16:55 +01:00
|
|
|
* @package librenms
|
2013-10-29 05:38:12 +10:00
|
|
|
* @subpackage webinterface
|
|
|
|
* @copyright (C) 2006 - 2012 Adam Armstrong
|
2012-05-09 10:01:42 +00:00
|
|
|
*/
|
|
|
|
|
2008-11-13 17:28:13 +00:00
|
|
|
ini_set('allow_url_fopen', 0);
|
|
|
|
ini_set('display_errors', 0);
|
2008-11-13 17:19:43 +00:00
|
|
|
|
2015-07-13 20:10:26 +02:00
|
|
|
if ($_GET[debug]) {
|
|
|
|
ini_set('display_errors', 1);
|
|
|
|
ini_set('display_startup_errors', 1);
|
|
|
|
ini_set('log_errors', 1);
|
|
|
|
ini_set('error_reporting', E_ALL);
|
2008-11-13 17:19:43 +00:00
|
|
|
}
|
|
|
|
|
2016-11-21 14:12:59 -06:00
|
|
|
$init_modules = array('web', 'auth');
|
|
|
|
require realpath(__DIR__ . '/..') . '/includes/init.php';
|
2009-03-11 14:50:24 +00:00
|
|
|
|
2015-07-13 20:10:26 +02:00
|
|
|
if (!$_SESSION['authenticated']) {
|
|
|
|
echo 'unauthenticated';
|
|
|
|
exit;
|
|
|
|
}
|
2008-11-13 17:28:13 +00:00
|
|
|
|
2014-02-23 15:08:06 +10:00
|
|
|
$output = '';
|
2015-07-13 20:10:26 +02:00
|
|
|
if ($_GET['query'] && $_GET['cmd']) {
|
2016-10-15 20:45:18 +01:00
|
|
|
$host = clean($_GET['query']);
|
|
|
|
if (filter_var($host, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) || filter_var($host, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) || filter_var('http://'.$host, FILTER_VALIDATE_URL)) {
|
2015-07-13 20:10:26 +02:00
|
|
|
switch ($_GET['cmd']) {
|
2016-08-18 20:28:22 -05:00
|
|
|
case 'whois':
|
|
|
|
$cmd = $config['whois']." $host | grep -v \%";
|
|
|
|
break;
|
2011-03-23 09:54:56 +00:00
|
|
|
|
2016-08-18 20:28:22 -05:00
|
|
|
case 'ping':
|
|
|
|
$cmd = $config['ping']." -c 5 $host";
|
|
|
|
break;
|
2008-11-13 17:19:43 +00:00
|
|
|
|
2016-08-18 20:28:22 -05:00
|
|
|
case 'tracert':
|
|
|
|
$cmd = $config['mtr']." -r -c 5 $host";
|
|
|
|
break;
|
2007-04-03 14:10:23 +00:00
|
|
|
|
2016-08-18 20:28:22 -05:00
|
|
|
case 'nmap':
|
|
|
|
if ($_SESSION['userlevel'] != '10') {
|
|
|
|
echo 'insufficient privileges';
|
|
|
|
} else {
|
|
|
|
$cmd = $config['nmap']." $host";
|
|
|
|
}
|
|
|
|
break;
|
2015-07-13 20:10:26 +02:00
|
|
|
}//end switch
|
|
|
|
|
|
|
|
if (!empty($cmd)) {
|
|
|
|
$output = `$cmd`;
|
|
|
|
}
|
|
|
|
}//end if
|
|
|
|
}//end if
|
|
|
|
|
2016-06-02 06:56:45 +00:00
|
|
|
$output = htmlentities(trim($output), ENT_QUOTES);
|
2015-07-13 20:10:26 +02:00
|
|
|
echo "<pre>$output</pre>";
|