【2022-04-03 03:33:45】 正在扫描网站 【www.****t.cn】
/www/wwwroot/www.******.cn/zb_system/function/c_system_common.php文件为木马 hash:9a4cc45514a81f265f400455c5eb7c1b034f6cac
【2022-04-03 03:33:45】 扫描完毕!本次扫描耗时35秒,发现1个木马
这个是zblog php 1.7的官方文件,没有任何更改
<?php
/**
* 辅助通用函数.
*/
if (!defined('ZBP_PATH')) {
exit('Access denied');
}
/**
* 得到请求协议(考虑到不正确的配置反向代理等原因,未必准确)
* 如果想获取准确的值,请zbp->Load后使用$zbp->isHttps.
*
* @param array $array
*
* @return string
*/
function GetScheme($array)
{
$array = array_change_key_case($array, CASE_UPPER);
if (array_key_exists('REQUEST_SCHEME', $array) && (strtolower($array['REQUEST_SCHEME']) == 'https')) {
return 'https://';
} elseif (array_key_exists('HTTPS', $array) && (strtolower($array['HTTPS']) == 'on')) {
return 'https://';
} elseif (array_key_exists('SERVER_PORT', $array) && ($array['SERVER_PORT'] == 443)) {
return 'https://';
} elseif (array_key_exists('HTTP_X_FORWARDED_PORT', $array) && ($array['HTTP_X_FORWARDED_PORT'] == 443)) {
return 'https://';
} elseif (array_key_exists('HTTP_X_FORWARDED_PROTO', $array) && (strtolower($array['HTTP_X_FORWARDED_PROTO']) == 'https')) {
return 'https://';
} elseif (array_key_exists('HTTP_X_FORWARDED_PROTOCOL', $array) && (strtolower($array['HTTP_X_FORWARDED_PROTOCOL']) == 'https')) {
return 'https://';
} elseif (array_key_exists('HTTP_X_FORWARDED_SSL', $array) && (strtolower($array['HTTP_X_FORWARDED_SSL']) == 'on')) {
return 'https://';
} elseif (array_key_exists('HTTP_X_URL_SCHEME', $array) && (strtolower($array['HTTP_X_URL_SCHEME']) == 'https')) {
return 'https://';
} elseif (array_key_exists('HTTP_CF_VISITOR', $array) && (stripos($array['HTTP_CF_VISITOR'], 'https') !== false)) {
return 'https://';
} elseif (array_key_exists('HTTP_FROM_HTTPS', $array) && (strtolower($array['HTTP_FROM_HTTPS']) == 'on')) {
return 'https://';
} elseif (array_key_exists('HTTP_FRONT_END_HTTPS', $array) && (strtolower($array['HTTP_FRONT_END_HTTPS']) == 'on')) {
return 'https://';
} elseif (array_key_exists('SERVER_PORT_SECURE', $array) && ($array['SERVER_PORT_SECURE'] == 1)) {
return 'https://';
}
return 'http://';
}
/**
* 获取服务器.
*
* @return int
*/
function GetWebServer()
{
if (!isset($_SERVER['SERVER_SOFTWARE'])) {
return SERVER_UNKNOWN;
}
$webServer = strtolower($_SERVER['SERVER_SOFTWARE']);
if (strpos($webServer, 'apache') !== false) {
return SERVER_APACHE;
} elseif (strpos($webServer, 'microsoft-iis') !== false) {
return SERVER_IIS;
} elseif (strpos($webServer, 'nginx') !== false) {
return SERVER_NGINX;
} elseif (strpos($webServer, 'lighttpd') !== false) {
return SERVER_LIGHTTPD;
} elseif (strpos($webServer, 'kangle') !== false) {
return SERVER_KANGLE;
} elseif (strpos($webServer, 'caddy') !== false) {
return SERVER_CADDY;
} elseif (strpos($webServer, 'development server') !== false) {
return SERVER_BUILTIN;
} else {
return SERVER_UNKNOWN;
}
}
/**
* 获取操作系统
*
* @return int
*/
function GetSystem()
{
if (in_array(strtoupper(PHP_OS), array('WINNT', 'WIN32', 'WINDOWS'))) {
return SYSTEM_WINDOWS;
} elseif ((strtoupper(PHP_OS) === 'UNIX')) {
return SYSTEM_UNIX;
} elseif (strtoupper(PHP_OS) === 'LINUX') {
return SYSTEM_LINUX;
} elseif (strtoupper(PHP_OS) === 'DARWIN') {
return SYSTEM_DARWIN;
} elseif (strtoupper(substr(PHP_OS, 0, 6)) === 'CYGWIN') {
return SYSTEM_CYGWIN;
} elseif (in_array(strtoupper(PHP_OS), array('NETBSD', 'OPENBSD', 'FREEBSD'))) {
return SYSTEM_BSD;
} else {
return SYSTEM_UNKNOWN;
}
}
/**
* 获取PHP解析引擎.
*
* @return int
*/
function GetPHPEngine()
{
return ENGINE_PHP;
}
/**
* 获取PHP Version.
*
* @return string
*/
function GetPHPVersion()
{
$p = phpversion();
if (strpos($p, '-') !== false) {
$p = substr($p, 0, strpos($p, '-'));
}
return $p;
}
/**
* 自动加载类文件.
*
* @param string $className 类名
*
* @api Filter_Plugin_Autoload
* *
* @return mixed
*/
function AutoloadClass($className)
{
global $autoload_class_dirs;
foreach ($GLOBALS['hooks']['Filter_Plugin_Autoload'] as $fpname => &$fpsignal) {
$fpreturn = $fpname($className);
if ($fpsignal == PLUGIN_EXITSIGNAL_RETURN) {
$fpsignal = PLUGIN_EXITSIGNAL_NONE;
return $fpreturn;
}
}
$className = str_replace('__', '/', $className);
//$fileName = ZBP_PATH . 'zb_system/function/lib/' . strtolower($className) . '.php';
foreach ($autoload_class_dirs as $dir) {
$fileName = $dir . strtolower($className) . '.php';
if (is_readable($fileName)) {
include $fileName;
return true;
}
}
return false;
}
/**
* 管理自动加载类文件的目录.
*/
function AddAutoloadClassDir($dir, $prepend = false)
{
global $autoload_class_dirs;
$dir = trim($dir);
if (empty($dir)) {
return false;
}
$dir = str_replace('\\', '/', $dir);
$dir = rtrim($dir, '/') . '/';
if ($prepend == false) {
$autoload_class_dirs[] = $dir;
} else {
array_unshift($autoload_class_dirs, $dir);
}
return true;
}
/**
* 记录日志.
*
* @param string $logString
* @param string $level INFO|ERROR|WARNING|FATAL|DEBUG|TRACE
* @param string $source system or plugin ID
*
* @return bool
*/
function Logs($logString, $level = 'INFO', $source = 'system')
{
global $zbp;
$time = date('Y-m-d') . ' ' . date('H:i:s') . ' ' . substr(microtime(), 1, 9) . ' ' . date('P');
$isError = false;
if ($level === true) {
$level = 'ERROR';
} elseif ($level === false) {
$level = 'INFO';
}
$level = strtoupper($level);
if ($level == 'WARNING' || $level == 'ERROR' || $level == 'FATAL') {
$isError = true;
}
$ip = GetGuestIP();
$ua = GetGuestAgent();
foreach ($GLOBALS['hooks']['Filter_Plugin_Logs'] as $fpname => &$fpsignal) {
$fpreturn = $fpname($logString, $level, $source, $time, $ip, $ua);
if ($fpsignal == PLUGIN_EXITSIGNAL_RETURN) {
$fpsignal = PLUGIN_EXITSIGNAL_NONE;
return $fpreturn;
}
}
if ($zbp->guid) {
if ($isError) {
$f = $zbp->logsdir . '' . $zbp->guid . '-error' . date("Ymd") . '.txt';
} else {
$f = $zbp->logsdir . '' . $zbp->guid . '-log' . date("Ymd") . '.txt';
}
} else {
if ($isError) {
$f = $zbp->logsdir . '' . md5($zbp->path) . '-error.txt';
} else {
$f = $zbp->logsdir . '' . md5($zbp->path) . '.txt';
}
}
ZBlogException::SuspendErrorHook();
$handle = @fopen($f, 'a+');
if ($handle) {
$t = $time;
@fwrite($handle, '[' . $t . ']' . " " . $level . " " . $source . " " . $ip . "\r\n" . $logString . "\r\n");
@fclose($handle);
}
ZBlogException::ResumeErrorHook();
return true;
}
/**
* Logs指定的变量的值
*/
function Logs_Dump()
{
$a = func_get_args();
foreach ($a as $key => $value) {
$s = call_user_func('print_r', $value, true);
Logs($s);
}
}
/*
* 初始化统计信息
*/
function RunTime_Begin()
{
$_SERVER['_start_time'] = microtime(true); //RunTime
$_SERVER['_query_count'] = 0;
$_SERVER['_memory_usage'] = 0;
$_SERVER['_error_count'] = 0;
if (function_exists('memory_get_usage')) {
$_SERVER['_memory_usage'] = memory_get_usage();
}
}
/**
* 输出页面运行时长
*
* @param bool $isOutput 是否输出(考虑历史原因,默认输出)
*
* @return array
*/
function RunTime($isOutput = true)
{
global $zbp;
$rt = array();
$_end_time = microtime(true);
$rt['time'] = number_format((1000 * ($_end_time - $_SERVER['_start_time'])), 2);
$rt['query'] = $_SERVER['_query_count'];
$rt['memory'] = $_SERVER['_memory_usage'];
$rt['debug'] = $zbp->isdebug ? 1 : 0;
$rt['loggedin'] = $zbp->islogin ? 1 : 0;
$rt['error'] = $_SERVER['_error_count'];
$rt['error_detail'] = ZBlogException:errors_msg;
if (function_exists('memory_get_peak_usage')) {
$rt['memory'] = (int) ((memory_get_peak_usage() - $_SERVER['_memory_usage']) / 1024);
}
$_SERVER['_runtime_result'] = $rt;
$_SERVER['_end_time'] = $_end_time;
if (isset($zbp->option['ZC_RUNINFO_DISPLAY']) && $zbp->option['ZC_RUNINFO_DISPLAY'] == false) {
return $rt;
}
if ($isOutput) {
echo '<!--' . $rt['time'] . ' ms , ';
echo $rt['query'] . ($rt['query'] > 1 ? ' queries' : ' query');
echo ' , ' . $rt['memory'] . 'kb memory';
echo ' , ' . $rt['error'] . ' error' . ($rt['error'] > 1 ? 's' : '');
//echo print_r($rt['error_detail'], true);
echo '-->';
}
return $rt;
}
/**
* 获得系统信息.
*
* @return string 系统信息
*
* @since 1.4
*/
function GetEnvironment($more = false)
{
global $zbp;
$ajax = Network::Create();
if ($ajax) {
$ajax = substr(get_class($ajax), 9);
}
if ($ajax == 'curl') {
if (ini_get("safe_mode")) {
$ajax .= '-s';
}
if (ini_get("open_basedir")) {
$ajax .= '-o';
}
$array = curl_version();
$ajax .= $array['version'];
}
if (function_exists('php_uname') == true) {
$uname = SplitAndGet(php_uname('r'), '-', 0);
} else {
$uname = '';
}
$system_environment = PHP_OS . $uname . '; ' .
GetValueInArray(
explode(
' ',
str_replace(array('Microsoft-', '/'), array('', ''), GetVars('SERVER_SOFTWARE', 'SERVER'))
),
0
) . '; PHP' . GetPHPVersion() . (IS_X64 ? 'x64' : '') . '; ';
if (isset($zbp->option) && isset($zbp->db)) {
$system_environment .= $zbp->option['ZC_DATABASE_TYPE'] . $zbp->db->version;
}
$system_environment .= '; ' . $ajax;
if (defined('OPENSSL_VERSION_TEXT')) {
$a = explode(' ', OPENSSL_VERSION_TEXT);
$system_environment .= '; ' . GetValueInArray($a, 0) . GetValueInArray($a, 1);
}
if ($more) {
if (method_exists($zbp, 'LoadApp')) {
$app = $zbp->LoadApp('plugin', 'AppCentre');
if (is_object($app) && $app->isloaded == true && $app->IsUsed()) {
$system_environment .= '; AppCentre' . $app->version;
}
}
$um = ini_get('upload_max_filesize');
$pm = ini_get('post_max_size');
$ml = ini_get('memory_limit');
$et = ini_get('max_execution_time');
$system_environment .= '; memory_limit:' . $ml . '; max_execution_time:' . $et;
$system_environment .= '; upload_max_filesize:' . $um . '; post_max_size:' . $pm;
}
return $system_environment;
}
/**
* 通过文件获取应用URL地址
*
* @param string $file 文件名
*
* @return string 返回URL地址
*/
function plugin_dir_url($file)
{
global $zbp;
$s1 = $zbp->path;
$s2 = str_replace('\\', '/', dirname($file) . '/');
$s = substr($s2, strspn($s1, $s2, 0));
if (strpos($s, 'zb_users/plugin/') !== false) {
$s = substr($s, strspn($s, $s3 = 'zb_users/plugin/', 0));
} else {
$s = substr($s, strspn($s, $s3 = 'zb_users/theme/', 0));
}
$a = explode('/', $s);
$s = $a[0];
$s = $zbp->host . $s3 . $s . '/';
return $s;
}
/**
* 通过文件获取应用目录路径.
*
* @param $file
*
* @return string
*/
function plugin_dir_path($file)
{
global $zbp;
$s1 = $zbp->path;
$s2 = str_replace('\\', '/', dirname($file) . '/');
$s = substr($s2, strspn($s1, $s2, 0));
if (strpos($s, 'zb_users/plugin/') !== false) {
$s = substr($s, strspn($s, $s3 = 'zb_users/plugin/', 0));
} else {
$s = substr($s, strspn($s, $s3 = 'zb_users/theme/', 0));
}
$a = explode('/', $s);
$s = $a[0];
$s = $zbp->path . $s3 . $s . '/';
return $s;
}
/**
* 通过Key从数组获取数据.
*
* @param array $array 数组名
* @param string $name 下标key
*
* @return mixed
*/
function GetValueInArray($array, $name, $default = null)
{
if (is_array($array)) {
if (array_key_exists($name, $array)) {
return $array[$name];
}
return $default;
}
return $default;
}
/**
* 获取数组中的当前元素(还是数组)的数据.
*
* @param string $array 数组名
* @param string $name 下标key
*
* @return mixed
*/
function GetValueInArrayByCurrent($array, $name, $default = null)
{
if (is_array($array)) {
$array = current($array);
return GetValueInArray($array, $name, $default);
}
}
/**
* 分割string并取某项数据.
*
* @param string $string
* @param string $delimiter
* @param int $n
*
* @return string
*/
function SplitAndGet($string, $delimiter = ';', $n = 0)
{
$a = explode($delimiter, $string);
if (!is_array($a)) {
$a = array();
}
if (isset($a[$n])) {
return (string) $a[$n];
}
return '';
}
/**
* 删除连续空格
*
* @param $s
*
* @return null|string|string[]
*/
function RemoveMoreSpaces($s)
{
return preg_replace("/\s(?=\s)/", "\\1", $s);
}
/**
* 获取Guid.
*
* @return string
*/
function GetGuid()
{
mt_srand();
$charid = strtolower(md5(uniqid(mt_rand(), true)));
return $charid;
}
/**
* 获取参数值
*
* @param string $name 数组key名
* @param string $type 默认为REQUEST
*
* @return mixed|null
*/
function GetVars($name, $type = 'REQUEST', $default = null)
{
if (empty($type)) {
$type = 'REQUEST';
}
$array = &$GLOBALS[strtoupper("_$type")];
if (array_key_exists($name, $array)) {
return $array[$name];
} else {
return $default;
}
}
/**
* 获取参数值(可设置默认返回值).本函数在1.7已经废弃了,改用GetVars!
*
* @param string $name 数组key名
* @param string $type 默认为REQUEST
* @param string $default 默认为null
*
* @return mixed|null
*
* @since 1.3.140614
*/
function GetVarsByDefault($name, $type = 'REQUEST', $default = null)
{
return GetVars($name, $type, $default);
}
|