首页 安全基础 网络安全 安全协议 病毒分析 防火墙 OS安全 无线安全 Web安全 PKI与PMI 入侵检测 经典案例
安全审计 设备安全 安全管理 安全标准 法律法规 隔离网闸 DB安全 XML安全 开源项目 资源下载 安全论坛 备份恢复
 当前位置:首页>>WEB安全>>asp安全>>正文
asp中对ip进行过滤限制函数
文章出处:www.100down.com   发布时间:2004-12-02   点击:0
 

看了一些IP限制的函数,觉得太复杂。所以,试着写了一个,比较简单。请网友参考指教。谢谢!~

================================

<%
'获取访问者的地址
ip=Request.ServerVariables("REMOTE_ADDR")

'允许的IP地址段为10.0.0.0~10.68.63.255
allowip1="10.0.0.0"
allowip2="10.68.10.71"

response.write checkip(ip,allowip1,allowip2)


function checkip(ip,allowip1,allowip2)
dim check(4)
checkip=false
ipstr=split(ip,".")
allow1=split(allowip1,".")
allow2=split(allowip2,".")
if cint(allow1(0))>cint(allow2(0)) then '判断IP地址段是否合法
response.write "IP地址段出错!"
exit function
end if
for i=0 to ubound(ipstr)
if cint(allow1(i))<cint(allow2(i)) then
if cint(allow1(i))=cint(ipstr(i)) then
check(i)=true
checkip=true
exit for
else
if cint(ipstr(i))<cint(allow2(i)) then
check(i)=true
checkip=true
exit for
else
if cint(ipstr(i))>cint(allow2(i)) then
check(i)=false
checkip=false
exit for
else
check(i)=true
checkip=true
end if
end if
end if
else
if cint(allow1(i))>cint(ipstr(i)) or cint(allow1(i))<cint(ipstr(i)) then
check(i)=false
checkip=false
if i<>ubound(ipstr) then
exit for
end if
else
check(i)=true
end if
end if
next

if (check(0)=true and check(1)=true and check(2)=true and check(3)=false) and (cint(allow2(2))>cint(ipstr(2))) then
checkip=true
end if

end function
%>

=====================

作者:
[返回顶部↑]  [推荐好友] [查看评论]  
用户名: 新注册) 密码: 匿名评论 [查看评论]  发表评论
评论内容:(不能超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规。
 
↑文章搜索
  关键字:  
  范  围:  
  开始搜索  
※相关文章※
 

◎ 用通ASP直接获取
◎ 用IIS+ASP建网站
◎IIS5 UNICODE 编
◎IIS安全机制
◎ 如何把ASP编写成
◎ 巧用ASP技术保护
◎ 维护 ASP 应用程

 
※热点文章※
  ·使用组件来保护你的ASP代码
·偷看ASP原码的6种方法
·ASP、IIS的安全漏洞
· 堵住ASP漏洞
· 维护 ASP 应用程
· 巧用ASP技术保护
· 如何把ASP编写成
 

关于我们 | 征搞启示 | 版权信息 | 联系我们 | 友情链接

版权所有:中国信息安全组织 © 2003-2005 Power by DedeCms