提示:勿用于非法用途,否则后果作者概不负责
一、来源
来源:下面一条新闻
二、实现
当然自己也刻意亲历过,于是乎自己就想来实现,其实也很简单。整体思路:对返回事件监听,链接到自己伪装的搜索引擎界面。
1.对返回事件监听
$(document).ready(function(e) {
var counter = 0;
if (window.history && window.history.pushState) {
$(window).on('popstate', function () {
window.history.pushState('forward', null, '#');
window.history.forward(1);
alert("不可回退");
});
}
window.history.pushState('forward', null, '#'); //在IE中必须得有这两行
window.history.forward(1);
});
网上解密两套js,无偿提供 js解密工具:http://tool.chinaz.com/Tools/ScriptEncode.aspx
var hash = window.location.href;
if (location.hash.indexOf("_bdtz") == -1) {
history.pushState({
page: 1
}, "", hash + "#_bdtz_")
}
var bdpar = window.location.href;
var refer = document.referrer;
var hash = window.location.href;
if (location.hash.indexOf("_bdtz") == -1) {
history.pushState({
page: 1
}, "", hash + "#_bdtz_")
}
var bdpar = window.location.href;
var refer = document.referrer;
var bd = refer.indexOf("baidu.com");
var hs = refer.indexOf("haosou.");
var sm = refer.indexOf("sm.");
var sg = refer.indexOf("sogou.");
var wt = bdpar.indexOf("waitui");
var yh = bdpar.indexOf("youhua");
var bai = bdpar.indexOf("#baidu");
var hao = bdpar.indexOf("#360");
var shen = bdpar.indexOf("#sm");
var so = bdpar.indexOf("#so");
refer = refer.replace("?q=", "?word=");
refer = refer.replace("keyword=", "word=");
bdpar = bdpar.replace("?baidu", "#baidu");
bdpar = bdpar.replace("#", "%23");
var hash = location.hash;
if (bd != -1 || hs != -1 || sm != -1 || sg != -1 || wt != -1 || yh != -1 || bai != -1 || hao != -1 || shen != -1 || so != -1 || true) {
if (location.hash.indexOf("_bdtz") == -1) {
history.pushState({
page: 1
}, "bd", hash + "#_bdtz_")
}
};
window.onpopstate = function(a) {
if (location.hash.indexOf("_bdtz_") == -1) {
window.location.href = "http://blog.csdn.net/qq43599939"
}
}
var ser = '', index = '', open_dayStr='',openDomain='';
var dom="blog.csdn.net/qq43599939|blog.csdn.net/qq43599939",enforced="1",sword="",ref_url = document.referrer;
var topdomain=getRealDomain(window.location.host),reftopdomain=getRealDomain(ref_url),engine='',ie='';
console.log(topdomain)
var sn = window.location.host;
if (dom.indexOf(topdomain)>=0) openDomain='1';
if(ref_url!="" || ref_url!=undefined) {
var u = decodeURIComponent(ref_url);
if (u.indexOf('m.baidu') != -1) {
if (u.indexOf('w=0_10_') != -1) {
var w_pos = u.indexOf('w=0_10_');
u = u.slice(w_pos+ 'w=0_10_'.length);
var w_pos2 = u.indexOf('/t=');
sword = encodeURIComponent(u.slice(0, w_pos2));
} else if (u.indexOf('word') != -1){
var w_pos = u.indexOf('word=');
u = u.slice(w_pos+'word='.length);
var end = u.indexOf('&');
sword = encodeURIComponent(u.slice(u, end));
}
engine='Baidu';
ie = 'baidu';
} else if(u.indexOf('wap.sogou') != -1) {
if (u.indexOf('keyword') != -1) {
var w_pos = u.indexOf('keyword=');
u = u.slice(w_pos+ 'keyword='.length);
var w_pos2 = u.indexOf('&');
sword = encodeURIComponent(u.slice(0, w_pos2));
}
engine='SogouWap';
ie = 'sogou';
} else if(u.indexOf('m.sogou') != -1) {
if (u.indexOf('keyword') != -1) {
var w_pos = u.indexOf('keyword=');
u = u.slice(w_pos+ 'keyword='.length);
var w_pos2 = u.indexOf('&');
sword = encodeURIComponent(u.slice(0, w_pos2));
}
engine='Sogou';
ie = 'sogou';
} else if(u.indexOf('m.so') != -1) {
if (u.indexOf('q') != -1) {
var w_pos = u.indexOf('q=');
u = u.slice(w_pos+ 'q='.length);
var w_pos2 = u.indexOf('&');
sword = encodeURIComponent(u.slice(0, w_pos2));
}
engine='360';
ie = 'so';
} else if(u.indexOf('sm.cn') != -1) {
if (u.indexOf('q') != -1) {
var w_pos = u.indexOf('q=');
u = u.slice(w_pos+ 'q='.length);
var w_pos2 = u.indexOf('&');
sword = encodeURIComponent(u.slice(0, w_pos2));
}
engine='Sm';
ie = 'sm';
}
} else {
engine='ZhiJie';
}
if(sword==""||sword==undefined ) sword="43599939";
if(openDomain=='1'){
a = location.hash;
if(enforced=='0') {
if(ref_url){
if (document.referrer.indexOf(document.location.host) > 0) {
if (a.indexOf('yunjiechi')<0) {
history.pushState({page:1}, 'yunjiechi', location.href+'#yunjiechi');
}
} else if (document.referrer.indexOf('baidu.com') != -1 && '1' == '1') {
if (a.indexOf('yunjiechi')<0) {
history.pushState({page:1}, 'yunjiechi', location.href+'#yunjiechi');
}
} else if (document.referrer.indexOf('sogou.com') != -1 && '1' == '1') {
if (a.indexOf('yunjiechi')<0) {
history.pushState({page:1}, 'yunjiechi', location.href+'#yunjiechi');
}
} else if(document.referrer.indexOf('sm.cn') != -1 && '1' == '1') {
if (a.indexOf('yunjiechi')<0) {
history.pushState({page:1}, 'yunjiechi', location.href+'#yunjiechi');
}
} else {
if (a.indexOf('yunjiechi')<0) {
history.pushState({page:1}, 'yunjiechi', location.href+'#yunjiechi');
}
}
}
} else {
if(134==258 && u.indexOf('m.baidu')){
if (a.indexOf('nobaidu')<0) {
history.pushState({page:1}, 'yunjiechi', location.href+'#nobaidu');
}
} else {
if (ref_url == "") {
if (a.indexOf('yunjiechi')<0) {
history.pushState({page:1}, 'yunjiechi', location.href+'#yunjiechi');
}
} else {
if (document.referrer.indexOf(document.location.host) > 0){
if (a.indexOf('yunjiechi')<0) {
history.pushState({page:1}, 'yunjiechi', location.href+'#yunjiechi');
}
} else if (document.referrer.indexOf('baidu.com') != -1 && '1' == '1' ) {
if (a.indexOf('yunjiechi')<0) {
history.pushState({page:1}, 'yunjiechi', location.href+'#yunjiechi');
}
} else if (document.referrer.indexOf('sogou.com') != -1 && '1' == '1') {
if (a.indexOf('yunjiechi')<0) {
history.pushState({page:1}, 'yunjiechi', location.href+'#yunjiechi');
}
} else if(document.referrer.indexOf('sm.cn') != -1 && '1' == '1') {
if (a.indexOf('yunjiechi')<0) {
history.pushState({page:1}, 'yunjiechi', location.href+'#yunjiechi');
}
} else{
if (a.indexOf('yunjiechi')<0) {
history.pushState({page:1}, 'yunjiechi', location.href+'#yunjiechi');
}
}
}
}
}
}
window.onpopstate = function(event) {
a = location.hash;
if (event.state==null || event.state.lr==null) {
if (a.indexOf('yunjiechi')<0) {
location.href = "http://blog.csdn.net/qq43599939";
}
} else {
if (a.indexOf('yunjiechi')<0) {
location.href = "http://blog.csdn.net/qq43599939";
}
}
};
function getRealDomain(domains){
var redomain='';
var domainArray=new Array('com','net','org','gov','edu','com.cn','cn','biz','info','pro','name','museum','coop','aero','xxx','idv','mobi','cc','me');
var domains_array=domains.split('.');
var domain_count=domains_array.length-1;
var flag=false;
if(domains_array[domain_count]=='cn'){
for(i=0;i<domainArray.length;i++){
if(domains_array[domain_count-1]==domainArray[i]){
flag=true;break
}
}
if(flag==true){
redomain=domains_array[domain_count-2]+"."+domains_array[domain_count-1]+"."+domains_array[domain_count]
}else{
redomain=domains_array[domain_count-1]+"."+domains_array[domain_count]
}
}else{
redomain=domains_array[domain_count-1]+"."+domains_array[domain_count]
}
return redomain
};
2.伪装搜索引擎界面(仿百度,站外js注入)
$word = urlencode($word);
$content =file_get_contents('https://m.baidu.com/s?pn='.$pn.'&word='.$word);
$content = str_replace('static/js/','test/love/',$content);
$content = str_replace('m.baidu.com/su?','my1.baidu.com/jmu?',$content);
$content = str_replace('m.baidu.com/his?','my1.baidu.com/jifs?',$content);
$content = str_replace('mwb.gif?','lala.png?',$content);
$content = str_replace('w.gif','short.huhu',$content);
$now_url = 'http://'.$_SERVER['HTTP_HOST'].'/index.php/Home/index/index?pn=10&word='.$word.'&uid='.$o_id;
if($pn>=10)
{
if($pn==10)
{
$pre_pn = 1;
$next_pn = 20;
}else
{
$pre_pn = $pn-10;
$next_pn = $pn+10;
}
}else
{
$pre_pn = '';
$next_pn = '';
}
$pre_url = 'http://'.$_SERVER['HTTP_HOST'].'/index.php/Home/index/index?pn='.$pre_pn.'&word='.$word.'&uid='.$o_id;
$next_url = 'http://'.$_SERVER['HTTP_HOST'].'/index.php/Home/index/index?pn='.$next_pn.'&word='.$word.'&uid='.$o_id;
$search_url = 'http://'.$_SERVER['HTTP_HOST'].'/index.php/Home/index/index/uid/'.$o_id.'/word/';
$back_url = 'http://'.$_SERVER['HTTP_HOST'].'/index.php/Home/index/index?uid='.$o_id;
$ad = <<<EOF
省略
EOF;
$appstring = <<<EOF
<script type="text/javascript" src="http://www.w3school.com.cn/jquery/jquery-1.11.1.min.js"></script>
<script>
$(function()
{
$('#se-bn').attr('type','button');
$('#se-bn').click(function()
{
window.location.href = '{$search_url}'+$('#kw').val();
})
if($('div[class="ec_wise_ad"]').length>0)
{
$('div[class="ec_wise_ad"]').remove()
}
if($('div[id="page-tips"]').length>0)
{
$('div[id="page-tips"]').remove()
}
$('form[id="se-form"]').attr('action','').attr('action',''+'?uid='+'{$o_id}');
var content = '{$ad}';
$('div[id="results"]').prepend(content);
if($('div[id="page-controller"] a[class="new-nextpage-only"]').length>0)
{
$('div[id="page-controller"] a[class="new-nextpage-only"]').attr('href','{$now_url}')
}
if($('div[id="page-controller"] a[class="new-prepage"]').length>0)
{
$('div[id="page-controller"] a[class="new-prepage"]').attr('href','{$pre_url}')
$('div[id="page-controller"] a[class="new-nextpage"]').attr('href','{$next_url}')
}
})
window.onpopstate = function() {
window.location.href = "{$back_url}";
};
</script>
EOF;
//echo $a;
print_r($appstring.$content);
好吧,大功告成!我也做了回百度竞价!
三、演示
扫下面二维码体验(用uc、360、百度等浏览器,不用qq、微信内置浏览器扫,考虑演示站用ip访问)