预防PHPDDOS的发包攻击别人的方法(iis+linux)
时间:2023-10-14 04:09:34
说下防止PHPDDOS发包的方法
if (eregi("ddos-udp",$read)) {
fputs($verbinden,"privmsg $Channel :ddos-udp – started udp flood – $read2[4]\n\n");
$fp = fsockopen("udp://$read2[4]", 500, $errno, $errstr, 30);
if (!$fp)
{
$fp = fsockopen("udp://$read2[4]", 500, $errno, $errstr, 30);
既然是用fsockopen()函数请求外部,那就不让他请求
php.ini里设置
allow_url_fopen = Off
如果这样他还是能发包
extension=php_sockets.dll
改成
;extension=php_sockets.dll
重启APACHE、IIS、NGINX
这样就可以防止PHP DDOS发包了
对这种攻击的处罚政策是,
Further violations will proceed with these following actions:
1st violation - Warning and shutdown of server. We will allow 24 hours for you to rectify the problem. 第一次是警告+关机,给24小时的时间来解决问题
2nd violation - Immediate reformat of server. 第二次是立即格式化服务器
3rd violation - Cancellation with no refund. 第三次是取消服务并不给退款
针对这个问题,给一个简单的描述,
表现特征:一打开IIS,服务器的流出带宽就用光-----就是说服务器不断向别人发包,这个情况和受到ddos攻击是不同的,Ddos是不断收到大量数据包.
解决办法:
先停止IIS,这样就暂时没法对外攻击了,然后
禁止上述的代码:
在c:\windows\php.ini里设置:
disable_functions =gzinflate,passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_alter,ini_restore,dl,pfsockopen,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,fsocket,fsockopen
在c:\windows\php.ini里设其值为Off
allow_url_fopen = Off
并且:
;extension=php_sockets.dll
前面的;号一定要有,意思就是限制用sockets.dll
前面的;号要保留
然后启动IIS
在IP策略,或防火墙中,禁止所有udp向外发送
linux下解决办法
一、禁止本机对外发送UDP包
iptables -A OUTPUT -p udp -j DROP
二、允许需要UDP服务的端口(如DNS)
iptables -I OUTPUT -p udp --dport 53 -d 8.8.8.8 -j ACCEPT
绿色“53”,为DNS所需要的UDP端口,黄色“8.8.8.8”部分为DNS IP,根据您服务器的设定来定,若您不知您当前服务器使用的DNS IP,可在SSH中执行以下命令获取:
cat /etc/resolv.conf |grep nameserver |awk 'NR==1{print $2 }'
附完整iptables规则
#iptables -A INPUT -p tcp -m tcp --sport 53 --dport 1024:65535 -m state --state ESTABLISHED -j ACCEPT
#iptables -A INPUT -p udp -m udp --sport 53 --dport 1024:65535 -m state --state ESTABLISHED -j ACCEPT
#iptables -A OUTPUT -p tcp -m tcp --sport 1024:65535 -d 8.8.4.4 --dport 53 -m state --state NEW,ESTABLISHED -j ACCEPT
#iptables -A OUTPUT -p udp -m udp --sport 1024:65535 -d 8.8.8.8 --dport 53 -m state --state NEW,ESTABLISHED -j ACCEPT
#iptables -A OUTPUT -p udp -j REJECT
#/etc/rc.d/init.d/iptables save
# service iptables restart
#chkconfig iptables on
开放 对外 以及对内的 DNS端口 53
禁止其他全部出站的UDP 协议
开机启动iptables
另外要说明的是,上面的代码是因为我服务器使用的是谷歌的DNS来解析,我服务器端对外的访问(在服务器端上网,就需要,如果只是单纯的服务器,不进行 yum安装也可以不用),因此我开放对8.8.4.4和8.8.8.8的访问,如果你不是设置为谷歌的DNS,那么这里要自行修改成你的DNS。使用的 DNS是什么可以用下面方法查询
利用IP安全策略 下载 phpddos_jb51.rar
使用方法:
首先 开始 - 运行 - gpedit.msc 找到IP安全策略
鼠标右键 - 所有任务 - 选择导入策略
最后指派策略即可
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Python Django 封装分页成通用的模块详解
![](https://img.aspxhome.com/file/2023/3/103523_0s.png)
SQL Server中多行多列连接成为单行单列
MySQL事务(transaction)看这篇就足够了
![](https://img.aspxhome.com/file/2023/2/119722_0s.png)
tensorflow识别自己手写数字
![](https://img.aspxhome.com/file/2023/1/99431_0s.jpg)
mysql中合并两个字段的方法分享
python制作填词游戏步骤详解
![](https://img.aspxhome.com/file/2023/5/89365_0s.png)
MYSQL 表的全面总结
![](https://img.aspxhome.com/file/2023/2/70392_0s.png)
SQL语句 一个简单的字符串分割函数
AJAX请求类下载
利用Python程序读取Excel创建折线图
![](https://img.aspxhome.com/file/2023/9/85219_0s.png)
Python制作一个随机抽奖小工具的实现
![](https://img.aspxhome.com/file/2023/3/104973_0s.png)
pyqt5 QListWidget的用法解析
![](https://img.aspxhome.com/file/2023/9/70749_0s.gif)
Python变量和数据类型详解
让所有IE支持HTML5的解决方案
实例详解mysql子查询
浅谈MySQL安装starting the server失败的解决办法
![](https://img.aspxhome.com/file/2023/7/79137_0s.jpg)
用Python编写个解释器实现方法接受
![](https://img.aspxhome.com/file/2023/5/65505_0s.png)
PHP实现的随机IP函数【国内IP段】
vue中el-table两个表尾合计行联动同步滚动条实例代码
![](https://img.aspxhome.com/file/2023/0/139950_0s.gif)