教程集 www.jiaochengji.com
教程集 >  脚本编程  >  php  >  正文 IIS环境中防止本地用户用fsockopen进行DDOS攻击的方法

IIS环境中防止本地用户用fsockopen进行DDOS攻击的方法

发布时间:2015-06-08   编辑:jiaochengji.com
使用php中的fsockopen函数,可以对外部地址,发送大量的UDP数据包,造成小规模的ddos攻击。

先来看代码:
 

复制代码 代码如下:
<?php
/*
 from: http://www.jiaochengji.com
 date: 2013/2/17
*/
$fp = fsockopen("udp://$ip", $rand, $errno, $errstr, 5);
if($fp){
fwrite($fp, $out);
fclose($fp);
?>

针对这种情况,可以修改 php.ini ,禁用 fsockopen 函数,及使用Windows 2003的 安全策略 屏蔽本机的UDP端口。

1)、禁用函数
查找到 disable_functions ,添加需禁用的函数名,如下例:
 

复制代码 代码如下:
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

重启IIS后生效。

2)、屏蔽UDP端口
复制到记事本,另存为任意名称的bat文件,双击运行即可。
 

复制代码 代码如下:

REM 添加安全策略,名称
netsh ipsec static add policy name=我的安全策略

REM 添加 IP筛选器列表
netsh ipsec static add filterlist name=允许列表
netsh ipsec static add filterlist name=拒绝列表

REM 添加筛选器到IP筛选器列表(允许上网)
netsh ipsec static add filter filterlist=允许列表 srcaddr=me dstaddr=any description=dns访问 protocol=udp mirrored=yes dstport=53

REM 添加筛选器到IP筛选器列表(不让别人访问)
netsh ipsec static add filter filterlist=拒绝列表 srcaddr=any dstaddr=me description=别人到我任何访问 protocol=udp mirrored=yes

REM 添加筛选器操作
netsh ipsec static add filteraction name=可以 action=permit
netsh ipsec static add filteraction name=不可以 action=block

@REM http://www.jiaochengji.com
REM 创建一个链接指定 IPSec 策略、筛选器列表和筛选器操作的规则(加入规则到我的安全策略)
netsh ipsec static add rule name=允许规则 policy=我的安全策略 filterlist=允许列表 filteraction=可以
netsh ipsec static add rule name=拒绝规则 policy=我的安全策略 filterlist=拒绝列表 filteraction=不可以

REM 激活我的安全策略
netsh ipsec static set policy name=我的安全策略 assign=y

您可能感兴趣的文章:
php中防止ddos恶意攻击的方法参考
IIS环境中防止本地用户用fsockopen进行DDOS攻击的方法
一个防DDOS攻击的SHELL脚本
asp.net如何防范SQL注入式攻击
php防止SQL注入攻击与XSS攻击的方法
asp.net 如何防止SQL注入
web安全之文件上传漏洞攻击与防范方法
巧妙在IIS中配置PHP调试环境(一)
php防范SQL注入攻击与XSS攻击的方法详解
php安全问题思考

[关闭]
~ ~