# Php安全新闻早8点（2011-11-20 星期日）

**URL:** <https://forum.90sec.com/t/topic/2933>\
**Category:** 技术文章\
**Created:** [2011 年11 月 19 日 14:32 UTC](https://forum.90sec.com/t/topic/2933 "2011-11-19T14:32:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

作者： ![Micropoor1](https://forum.90sec.com/user_avatar/forum.90sec.com/micropoor1/32/11345_2.png) [@Micropoor1](https://forum.90sec.com/u/Micropoor1)\
发布日期： [2011 年11 月 19 日 14:32 UTC](https://forum.90sec.com/t/topic/2933/1 "2011-11-19T14:32:03Z")

</div>

**[http://hi.baidu.com/micropoor](http://hi.baidu.com/micropoor)**

'2011-11-20 星期日  
'插入篇---asp篇  
'程序员的思维  
'Micropoor.asp代码片段  
\<%  
dim upload,file,formName,formPath,iCount,fileformat  
//......略  
end function  
formPath="2010/"  
//......略  
set file=upload.file(formName) ''生成一个文件对象  
//......略  
if fileformat=".asp" or fileformat=".exe" or fileformat=".txt" or fileformat=".htm" then  
response.write"\<script\>alert('文件格式不对，请重新上传！');location='"&request.ServerVariables("HTTP\_REFERER")&"'\</script\>"  
response.end  
end if  
if file.FileSize\>0 then ''如果 FileSize \> 0 说明有文件数据  
newname=MakedownName()&"."&mid(file.FileName,InStrRev(file.FileName, ".")+1)  
file.SaveAs Server.mappath(formPath&newname) ''保存文件  
// ...... 略  
next  
%\>

'我们的思维  
仅仅是过滤了asp,exe,txt,htm并没有过滤cer,asa,php,aspx等

**结论：上传文件的安全决定了生死存亡.**

---

<div class="post-metadata">

作者： ![user22](https://forum.90sec.com/user_avatar/forum.90sec.com/user22/32/11361_2.png) [@user22](https://forum.90sec.com/u/user22)\
发布日期： [2011 年11 月 19 日 14:44 UTC](https://forum.90sec.com/t/topic/2933/2 "2011-11-19T14:44:03Z")

</div>

白名单。更安全。{:4\_100:}
