会 员 登 录
热 门 文 章
相 关 文 章
- 没有文章
Tags(标签)
- 没有标签!
终极防范上传漏洞!
其实无论是组件还是非组件上传,都有这个漏洞,以下代码请需要得朋友仔细阅读,只要读懂代码就能融会贯通。
这里以ASPUPLOAD组件上传为例
以下3个关键函数:
function killext(byval s1) '干掉非法文件后缀
dim allowext
allowext=".JPG,.JPEG,.GIF,.BMP,.PNG,.SWF,.RM,.MP3,.WAV,.MID,.MIDI,.RA,.AVI,.MPG,.MPEG,.ASF,.ASX,.WMA,.MOV,.RAR,.ZIP,.EXE,.DOC,.XLS,.CHM,.HLP,.PDF"
s1=ucase(s1)
if len(s1)=0 then
killext=""
else
if not chk(allowext,s1,",") then
killext=".shit"
else
killext=s1
end if
end if
end function
function chk(byval s1,byval s2,byval fuhao) '检查字符串包含
dim i,a
chk=false
a=split(s1,fuhao)
for i = 0 to ubound(a)
if trim(a(i))=trim(s2) then
chk=true
exit for
end if
next
end function
function gname(byval n1) '以日期自动产生目录和文件名,参数1生成目录,参数2生成文件名(无后缀)
dim t,r
t=now()
randomize(timer)
r=int((rnd+1-1)*9999)
select case n1
case 1
gname=year(t)&right("00"&month(t),2)&right("00"&day(t),2)
case 2
gname=right("00"&hour(t),2)&right("00"&minute(t),2)&right("00"&second(t),2)&right("0000"&r,4)
end select
end function
调用方法:
dim oup,ofile,ext,myfile
这里以ASPUPLOAD组件上传为例
以下3个关键函数:
function killext(byval s1) '干掉非法文件后缀
dim allowext
allowext=".JPG,.JPEG,.GIF,.BMP,.PNG,.SWF,.RM,.MP3,.WAV,.MID,.MIDI,.RA,.AVI,.MPG,.MPEG,.ASF,.ASX,.WMA,.MOV,.RAR,.ZIP,.EXE,.DOC,.XLS,.CHM,.HLP,.PDF"
s1=ucase(s1)
if len(s1)=0 then
killext=""
else
if not chk(allowext,s1,",") then
killext=".shit"
else
killext=s1
end if
end if
end function
function chk(byval s1,byval s2,byval fuhao) '检查字符串包含
dim i,a
chk=false
a=split(s1,fuhao)
for i = 0 to ubound(a)
if trim(a(i))=trim(s2) then
chk=true
exit for
end if
next
end function
function gname(byval n1) '以日期自动产生目录和文件名,参数1生成目录,参数2生成文件名(无后缀)
dim t,r
t=now()
randomize(timer)
r=int((rnd+1-1)*9999)
select case n1
case 1
gname=year(t)&right("00"&month(t),2)&right("00"&day(t),2)
case 2
gname=right("00"&hour(t),2)&right("00"&minute(t),2)&right("00"&second(t),2)&right("0000"&r,4)
end select
end function
调用方法:
dim oup,ofile,ext,myfile
附件:
没有附件
0
票
顶一下
票
顶一下
0
票
踩一下
票
踩一下
| 文 章 评 论 | ||||||||
| ||||||||



您现在的位置: