In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-11 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "how to use PHP to prevent CC attacks". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "how to use PHP to prevent CC attacks".
The implementation code for PHP against CC attacks is "if (session_is_registered ('ll_lasttime')) {$ll_lasttime = $_ SESSION [' ll_lasttime']; $ll_times =.}".
This article operating environment: Windows7 system, PHP7.1 version, DELL G3 computer
What is the implementation code of PHP against CC attacks?
PHP Anti-CC attack implementation Code
The so-called CC attack is that the other party uses a program or some agents to access your website continuously, causing your website to crash because it cannot be handled.
At this time, your statistical system (may be Quantum, Baidu, etc.) is certainly not available. However, we can use some anti-attack software to achieve, but the effect is sometimes not obvious.
Below I provide a piece of PHP code, can play a certain anti-CC effect.
Main function: refresh the page more than 5 times in 3 seconds will point to the native http://127.0.0.1
The code is as follows:
$P_S_T = $t_array [0] + $t_array [1]; $timestamp = time (); session_start (); $ll_nowtime = $timest if (session_is_registered ('ll_lasttime')) {$ll_lasttime = $_ SESSION [' ll_lasttime']; $ll_times = $_ SESSION ['ll_times'] + 1 [' ll_times'] = $ll_times;} else {$ll_lasttime = $ll_nowtime;$ll_times = 1 $_ SESSION ['ll_times'] = $ll_times;$_SESSION [' ll_lasttime'] = $ll_lasttime;} if (($ll_nowtime-$ll_lasttime) = 5) {header (sprintf ("Location:% s", 'http://127.0.0.1'));exit;}}else{$ll_times = 0 potential session [' ll_lasttime'] = $ll_nowtime;$_SESSION ['ll_times'] = $ll_times;})
The following are the responses from netizens:
SESSION depends on COOKIE. What if COOKIE is blocked?
The process of TCP/IP-> apache-> php has consumed a lot of things, but there are no more computing operations and MYSQL connections at this point.
These lines of code alone won't solve the problem. At best, it is useful for those who press F5 to browse the page in the browser.
Therefore, it is recommended that you install a firewall against cc attacks on your server.
At this point, I believe you have a deeper understanding of "how to use PHP to prevent CC attacks". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.