The example in this article describes the solution to Ddos attack in PHP. Share it with everyone for your reference. The specific analysis is as follows:
Today, one of my machines suddenly sent a large number of data packets to the outside world, which could reach more than 1G per second. Although I used a policy to prohibit UDP packets, they could not be sent out, but it took up a lot of cup, so I finally found a way to solve it. .
Look at the source code first, the code is as follows:
This pressure is on the server that executes this script, because it first consumes a lot of its own network bandwidth, CPU and other resources. If you want to use this script to put pressure on the target site, you need to execute it on multiple servers. This script, DDOS, since it uses fsockopen to request external requests, then it is not allowed to request.
Set in php.ini, the code is as follows:
If he can still send the package in this way, the code is as follows:
extension=php_sockets.dll
changed to
;extension=php_sockets.dll
Restart APACHE, IIS, and NGINX to prevent PHP DDOS from sending packages.
In addition, some netizens said that it is very simple to disable the setting of scripts to no timeout:
1. Disable the set_time_limit function
2. Enable PHP’s safe mode (safe_mode=on).
To disable the socket function, you can directly disable all socket modules or disable the fsockopen function. It is recommended that since socket is often used to send emails to retrieve passwords, it is recommended to directly enable the safe mode. However, in this case, the script will time out every 30 seconds. , I guess no "hacker" is lonely enough to click to start DDOS every 30 seconds.
Experience:This kind of problem is usually caused by website security. We should pay attention to the security of the website and the security of the server, so that it is not easy to be invaded. If you know how to use macofee friends, you can check the website. It would be better to limit it.
I hope this article will be helpful to everyone’s PHP programming design.