Cyber Anakins Lightsaber - A Minishell-based backdoor

Current Path : /home/bjb2293782/xn--80abaeoqbbrbgf8aea5a2a2z.xn--p1ai/docs/
Upload File :
Current File : /home/bjb2293782/xn--80abaeoqbbrbgf8aea5a2a2z.xn--p1ai/docs/getevents.php

<?php

require("std2.php");

$mysql = mysqlopen();

$filial = _GET_('filial');

function json_encode2($a=false, $level=0)
{
        if (is_null($a)) return 'null';
        if ($a === false) return 'false';
        if ($a === true) return 'true';
        if (is_scalar($a))
        {
            if (is_float($a))
            {
                // Always use "." for floats.
                return floatval(str_replace(",", ".", strval($a)));
            }

            if (is_string($a))
            {
                //static $jsonReplaces = array(array("\\", "/", "\n", "\t", "\r", "\b", "\f", '"'), array('\\\\', '\\/', '\\n', '\\t', '\\r', '\\b', '\\f', '\"'));
                static $jsonReplaces = array(array("\\",  "\n", "\t", "\r", "\b", "\f", '"'), array('\\\\',  '\\n', '\\t', '\\r', '\\b', '\\f', '\"'));
                return '"' . str_replace($jsonReplaces[0], $jsonReplaces[1], $a) . '"';
            }
            else
            return $a;
        }
        $isList = true;
        for ($i = 0, reset($a); $i < count($a); $i++, next($a))
        {
            if (key($a) !== $i)
            {
                $isList = false;
                break;
            }
        }
        $spacer = "  ";
        $result = array();
        if ($isList)
        {
            foreach ($a as $v) $result[] = json_encode2($v, $level + 1);
            return "[\n".str_repeat($spacer,$level+1) . join(",\n".str_repeat($spacer,$level+1), $result) . "\n". str_repeat($spacer,$level). "]";
        }
        else
        {
            foreach ($a as $k => $v) $result[] = json_encode2($k).': '.json_encode2($v, $level+1);
            return "{\n".str_repeat($spacer,$level+1) . join(",\n".str_repeat($spacer,$level+1), $result) . "\n" . str_repeat($spacer,$level). "}";
        }
}


$result = mysqli_query($mysql,
	"(SELECT  
		  `id`+10000000 as `id`,
		  CONCAT(`title`, ' (', DATE_FORMAT(`date`,'%e.%m.%Y'),')') as `title`
	FROM
		`libEvents`
	WHERE
		`filial`=$filial
		AND DATE(`date`) BETWEEN DATE_ADD(CURRENT_DATE(),INTERVAL -7 DAY) AND DATE_ADD(CURRENT_DATE(), INTERVAL 7 DAY)
	ORDER BY `desc` DESC		
	)
	UNION
	(
		SELECT
			`id` as `id`,
			 IF (`subname`<>'',
			 	CONCAT(`name`,' (',`subname`,')'),
			 `name`) as `title`
		FROM
			libProgDescriptions
		WHERE
			`filial`=$filial
	)
");
if (mysqli_errno($mysql)) die("ERROR: ".mysqli_error($mysql)." at line ".__LINE__." of file ".__FILE__."\n");

$json = array();
while($row = mysqli_fetch_assoc($result))
{
	$row['id'] = intval($row['id']);
	array_push($json, $row);
}
mysqli_free_result($result);

die(json_encode2($json));

?>

May the force be with you, always.