Files
librenms-librenms/html/netcmd.php
T

73 lines
1.5 KiB
PHP
Raw Normal View History

2007-04-03 14:10:23 +00:00
<?php
/**
2013-10-29 05:38:12 +10:00
* Observium
*
2013-10-29 05:38:12 +10:00
* This file is part of Observium.
*
2013-10-29 05:38:12 +10:00
* @package observium
* @subpackage webinterface
* @author Adam Armstrong <adama@memetic.org>
* @copyright (C) 2006 - 2012 Adam Armstrong
*
*/
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
2011-03-14 12:02:23 +00:00
if ($_GET[debug])
{
2011-03-23 09:54:56 +00:00
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
}
include("../includes/defaults.inc.php");
2008-11-13 17:28:13 +00:00
include("../config.php");
include_once("../includes/definitions.inc.php");
2011-03-14 12:02:23 +00:00
include("includes/functions.inc.php");
2008-11-13 17:28:13 +00:00
include("../includes/functions.php");
2010-02-20 17:37:42 +00:00
include("includes/authenticate.inc.php");
2009-03-11 14:50:24 +00:00
2011-03-14 12:02:23 +00:00
if (!$_SESSION['authenticated']) { echo("unauthenticated"); exit; }
2008-11-13 17:28:13 +00:00
2014-02-23 15:08:06 +10:00
$output = '';
2011-03-23 09:54:56 +00:00
if ($_GET['query'] && $_GET['cmd'])
{
$host = $_GET['query'];
if (Net_IPv6::checkIPv6($host)||Net_IPv4::validateip($host)||preg_match("/^[a-zA-Z0-9.-]*$/", $host))
{
switch ($_GET['cmd'])
{
case 'whois':
2011-09-20 14:37:54 +00:00
$cmd = $config['whois'] . " $host | grep -v \%";
2011-03-23 09:54:56 +00:00
break;
case 'ping':
$cmd = $config['ping'] . " -c 5 $host";
break;
case 'tracert':
$cmd = $config['mtr'] . " -r -c 5 $host";
break;
case 'nmap':
if ($_SESSION['userlevel'] != '10')
2011-03-22 20:27:39 +00:00
{
2011-03-23 09:54:56 +00:00
echo("insufficient privileges");
} else {
$cmd = $config['nmap'] . " $host";
2011-03-22 20:27:39 +00:00
}
2011-03-23 09:54:56 +00:00
break;
}
if (!empty($cmd))
{
$output = `$cmd`;
2010-03-22 22:13:45 +00:00
}
2011-03-23 09:54:56 +00:00
}
2007-04-03 14:10:23 +00:00
}
2008-11-13 17:19:43 +00:00
2007-04-03 14:10:23 +00:00
$output = trim($output);
echo("<pre>$output</pre>");
?>