自製wordpress防簡易CC攻擊刷新跳轉
自製簡易防CC攻擊刷新跳轉代碼,每秒刷新過多後跳轉防cc頁,5秒後反回博客首頁,感覺只能防一下亂刷新的人,就是打開博客一通亂點的人。
使用:以WordPress為例,在WordPress根目錄創建cc.php文件,把php代碼添加到裡面保存,再創建cc.html文件把html代碼放入保存,在到根目錄的index.php文件最前面加上調用代碼,調用cc.php文件即可,可把cc.php里的時間修改周期改長點。
調用cc.php代碼:
1 |
require 'cc.php'; |
cc.php代碼(自行創建在WordPress根目錄):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
<?php //代理IP直接退出 emptyempty($_SERVER['HTTP_VIA']) or exit('Access Denied'); //防止快速刷新 session_start(); $seconds = '3'; //時間段[秒] $refresh = '8'; //刷新次數 //設置監控變數 $cur_time = time(); if(isset($_SESSION['last_time'])){ $_SESSION['refresh_times'] += 1; }else{ $_SESSION['refresh_times'] = 1; $_SESSION['last_time'] = $cur_time; } //處理監控結果 if($cur_time - $_SESSION['last_time'] < $seconds){ if($_SESSION['refresh_times'] >= $refresh){ //跳轉防cc頁 header(sprintf('Location:%s', 'http://www.ggplus.cn/cc.html')); exit('Access Denied'); } }else{ $_SESSION['refresh_times'] = 0; $_SESSION['last_time'] = $cur_time; } ?> |
cc.html代碼(自行創建在WordPress根目錄):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>防CC刷新攻擊中,5秒後跳轉首頁</title> <meta http-equiv="refresh" content="5;url=/" /> <style>*{box-sizing:inherit;}body{min-height:100vh;display:flex;justify-content:center;align-items:center;background:#151924;padding:0;margin:0;}.loading{--color:#F5F9FF;--duration:2000ms;font-family:Roboto,Arial;font-size:24px;position:relative;white-space:nowrap;user-select:none;color:var(--color);}.loading span{--x:0;--y:0;--move-y:0;--move-y-s:0;--delay:0ms;display:block;position:absolute;top:0;left:0;width:1px;text-indent:calc(var(--x) * -1);overflow:hidden;transform:translate(var(--x),var(--y));}.loading.start div{opacity:0;}.loading.start span{animation:move var(--duration) ease-in-out var(--delay);}@keyframes move{30%{transform:translate(var(--x),var(--move-y));}82%{transform:translate(var(--x),var(--move-y-s));}</style> </head> <body> <div class="loading">防CC刷新攻擊中,5秒後跳轉首頁</div><br> <script src="https://cdn.bootcss.com/jquery/3.3.0/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function(){let loading=$('.loading').wrapInner('<div></div>'),min=20,max=70,minMove=10,maxMove=20;startAnimation(loading);loading.on('animationend webkitAnimationEnd oAnimationEnd','span:last-child',e=>{startAnimation(loading)});function setCSSVars(elem,min,max,minMove,maxMove){let width=Math.ceil(elem.width()),text=elem.text();for(let i=1;i<width;i++){let num=Math.floor(Math.random()*(max-min+1))+min,numMove=Math.floor(Math.random()*(maxMove-minMove+1))+minMove,dir=(i%2==0)?1:-1,spanCurrent=elem.find('span:eq('+i+')'),span=spanCurrent.length?spanCurrent:$('<span />');span.css({'--x':i-1+'px','--move-y':num*dir+'px','--move-y-s':((i%2==0)?num*dir-numMove:num*dir+numMove)+'px','--delay':i*10+'ms'});if(!spanCurrent.length){elem.append(span.text(text))}}}function startAnimation(elem){elem.removeClass('start');setCSSVars(elem,min,max,minMove,maxMove);void elem[0].offsetWidth;elem.addClass('start')}}); </script> </body> </html> |
由於網站搬家,部分鏈接失效,如無法下載,請聯繫站長!謝謝支持!
1. 帶 [親測] 說明源碼已經被站長親測過!
2. 下載後的源碼請在24小時內刪除,僅供學慣用途!
3. 分享目的僅供大家學習和交流,請不要用於商業用途!
4. 本站資源售價只是贊助,收取費用僅維持本站的日常運營所需!
5. 本站所有資源來源於站長上傳和網路,如有侵權請郵件聯繫站長!
6. 沒帶 [親測] 代表站長時間緊促,站長會保持每天更新 [親測] 源碼 !
7. 盜版ripro用戶購買ripro美化無擔保,若設置不成功/不生效我們不支持退款!
8. 本站提供的源碼、模板、插件等等其他資源,都不包含技術服務請大家諒解!
9. 如果你也有好源碼或者教程,可以到審核區發布,分享有金幣獎勵和額外收入!
10.如果您購買了某個產品,而我們還沒來得及更新,請聯繫站長或留言催更,謝謝理解 !
GG資源網 » 自製wordpress防簡易CC攻擊刷新跳轉
1. 帶 [親測] 說明源碼已經被站長親測過!
2. 下載後的源碼請在24小時內刪除,僅供學慣用途!
3. 分享目的僅供大家學習和交流,請不要用於商業用途!
4. 本站資源售價只是贊助,收取費用僅維持本站的日常運營所需!
5. 本站所有資源來源於站長上傳和網路,如有侵權請郵件聯繫站長!
6. 沒帶 [親測] 代表站長時間緊促,站長會保持每天更新 [親測] 源碼 !
7. 盜版ripro用戶購買ripro美化無擔保,若設置不成功/不生效我們不支持退款!
8. 本站提供的源碼、模板、插件等等其他資源,都不包含技術服務請大家諒解!
9. 如果你也有好源碼或者教程,可以到審核區發布,分享有金幣獎勵和額外收入!
10.如果您購買了某個產品,而我們還沒來得及更新,請聯繫站長或留言催更,謝謝理解 !
GG資源網 » 自製wordpress防簡易CC攻擊刷新跳轉