Cyber Anakins Lightsaber - A Minishell-based backdoor
<?php
require("_config.php");
define("FAKE_PASSWORD","********");
function _GET_($param)
{
if (!isset($_GET[$param])) die("ERROR: Нет параметра `$param` в запросе!");
return $_GET[$param];
}
function _POST_($param)
{
if (!isset($_POST[$param])) die("ERROR: Нет параметра `$param` в запросе!");
return $_POST[$param];
}
function _GD_($param, $def="")
{
if (isset($_GET[$param])) return $_GET[$param];
return $def;
}
function _CD_($param, $def="")
{
if (isset($_COOKIE[$param])) return $_COOKIE[$param];
return $def;
}
function _slashes_($text)
{
return str_replace("\\","/",$text);
}
function Win1251ToUTF8($s)
{
return mb_convert_encoding($s, "utf-8", "windows-1251");
}
/*
$len = strlen($s);
$result = "";
for($i=0;$i<$len;$i++)
{
$c = substr($s,$i,1);
if (ord($c)==168) $c = 'Ё';
else
if (ord($c)==184) $c = 'ё';
else
if (ord($c)>=192 && ord($c)<=239)
{
$c=chr(208).chr(ord($c) - 192 + 144);
}
else
if (ord($c)>=240 && ord($c)<=255)
{
$c=chr(209).chr(ord($c) - 240 + 128);
}
else
if (ord($c)>=128)
{
$c=" ";
}
$result.=$c;
}
return $result;
}
*/
function UTF8ToWin1251($text)
{
return mb_convert_encoding($s, "windows-1251", "utf-8");
}
/*
$w = 0;
$L = strlen($text);
$res = "";
while($w < $L)
{
$c = substr($text,$w,1);
$code = ord($c);
if ($code == 208)
{
$w++;
$c = strstr($text, $w,1);
$code = ord($c);
if ($code == 129)
$c = chr(168);
else
$c = chr( $code + 192 - 144);
}
else
if ($code == 209)
{
$w++;
$c = strstr($text, $w, 1);
$code = ord($c);
if ($code == 145)
$c = chr(184);
else
$c = chr($code + 240 - 128);
}
else
if ($code == 194)
{
$c="";
}
else
if ($code == 226)
{
$w++;
$c = strstr($text,$w,1);
if (ord($c)==128)
{
$w++;
$c = strstr($text,$w,1);
if (ord($c)==147)
{
$c = "—";
}
}
}
$res.=$c;
$w++;
}
return $res;
}
*/
function Uppercase1251($string)
{
$result = '';
$len = strlen($string);
for($i=0; $i<$len; $i++)
{
$c = substr($string,$i,1);//{$i};
$code = ord($c);
if ($code == 184 || $code == 168)
{
$result.=chr(197);
}
else
if (($code >=97 && $code < 122) ||
($code >=224 && $code <=255))
{
$c = chr($code-32);
$result.=$c;
}
else
$result.=$c;
}
return $result;
}
/*
function _html_($text)
{
return htmlspecialchars($text);
}
function _html_br_($text)
{
return str_replace(array("\n","\r"),array("<br>",""),htmlspecialchars($text));
}
*/
function _cell_($text)
{
if ($text == "") return " ";
return $text;
}
function _html_($text)
{
$text = str_replace(array('&','<','>'), array('&','<','>'), $text);
return $text;
}
function _html_br_($text)
{
return str_replace(array("\n","\r"),array("<br>",""),_html_($text));
}
function _html_p_($text)
{
return str_replace(array("\n","\r"),array("</p><p>",""),_html_($text));
}
function _para_($text)
{
$text = str_replace(array("\n","\r"),array("</p><p>",""),$text);
return $text;
}
function _input_($text)
{
return htmlspecialchars(str_replace(array("\n","\r"),array(" ",""),$text),ENT_COMPAT, "UTF-8");
}
function _script_($text)
{
return str_replace(array("\\","\"","\n","\r"),array('\\\\','\\"'," ",""),$text);
}
function _script_br_($s)
{
return str_replace(array("\\","\"","\n","\r"),array('\\\\','\\"',"\\n","\\r"), $s);
}
function SQLtoDate($date)
{
return preg_replace("/(\d+)-(\d+)-(\d+).*/","$3.$2.$1",$date);
}
function SQLtoDateTime($date)
{
return preg_replace("/(\d+)-(\d+)-(\d+)/","$3.$2.$1",$date);
}
function SQLtoTime($date)
{
return preg_replace("/(\d+-\d+-\d+)\s+/","",$date);
}
function DateToSQL($date)
{
return preg_replace("/(\d+)\.(\d+)\.(\d+)/","$3-$2-$1",$date);
}
function SQLToTimestamp($date)
{
// Y:1 M:2 D:3 H:4 N:5 S:6
if (preg_match("/(\d+)-(\d+)-(\d+)[\sT]+(\d+):(\d+):(\d+)/",$date, $g))
{
return gmmktime($g[4],$g[5],$g[6], $g[2], $g[3], $g[1]);
}
return 0;
}
function validateEmail($email)
{
return preg_match("/^[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]+.[a-zA-Z0-9-.]+$/", $email);
}
function WordCase($n, $case1, $case2, $case5='')
{
if ($case5=='')
{
if ($n==1) return $case1; else return $case2;
}
$n%=100;
if (intval($n/10)==1) $n = 0;
switch($n%10)
{
case 1: return $case1;
case 2:
case 3:
case 4: return $case2;
default: return $case5;
}
}
function GetSiteURL()
{
if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS']!='') $protocol="https"; else $protocol="http";
//$host = "$protocol://".$_SERVER['HTTP_HOST'];
$host = "$protocol://библиотекикоролёва.рф";
return $host;
}
$GLOBALS['mysql'] = null;
function mysqlopen()
{
if ($GLOBALS['mysql']) return $GLOBALS['mysql'];
$mysql = mysqli_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASSWORD);
if (!$mysql) die("ERROR: Can't open mysql");
mysqli_select_db($mysql, MYSQL_DATABASE);
if (mysqli_errno($mysql)) die("ERROR: ".mysqli_error($mysql)." at line ".__LINE__." of file ".__FILE__."\n");
mysqli_query($mysql, "SET NAMES 'utf8' COLLATE 'utf8_general_ci'");
mysqli_query($mysql, "SET CHARACTER SET 'UTF-8'");
mysqli_query($mysql, "SET GLOBAL time_zone = '+3:00';'");
$GLOBALS['mysql'] = $mysql;
return $mysql;
}
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). "}";
}
}
?>
May the force be with you, always.