主頁(yè) > 知識(shí)庫(kù) > ASP防止圖片木馬上傳的代碼

ASP防止圖片木馬上傳的代碼

熱門(mén)標(biāo)簽:Linux服務(wù)器 Mysql連接數(shù)設(shè)置 銀行業(yè)務(wù) 科大訊飛語(yǔ)音識(shí)別系統(tǒng) 團(tuán)購(gòu)網(wǎng)站 服務(wù)器配置 電子圍欄 阿里云
ASP木馬防御:
復(fù)制代碼 代碼如下:

const adTypeBinary=1

dim jpg(1):jpg(0)=CByte(HFF):jpg(1)=CByte(HD8)
dim bmp(1):bmp(0)=CByte(H42):bmp(1)=CByte(H4D)
dim png(3):png(0)=CByte(H89):png(1)=CByte(H50):png(2)=CByte(H4E):png(3)=CByte(H47)
dim gif(5):gif(0)=CByte(H47):gif(1)=CByte(H49):gif(2)=CByte(H46):gif(3)=CByte(H39):gif(4)=CByte(H38):gif(5)=CByte(H61)
Response.Write CheckFileType(Server.MapPath("2.gif"))

function CheckFileType(filename)
on error resume next
CheckFileType=false
dim fstream,fileExt,stamp,i
fileExt=mid(filename,InStrRev(filename,".")+1)
set fstream=Server.createobject("ADODB.Stream")
fstream.Open
fstream.Type=adTypeBinary
fstream.LoadFromFile filename
fstream.position=0
select case fileExt
case "jpg","jpeg"
stamp=fstream.read(2)
for i=0 to 1
if ascB(MidB(stamp,i+1,1))=jpg(i) then CheckFileType=true else CheckFileType=false
next
case "gif"
stamp=fstream.read(6)
for i=0 to 5
if ascB(MidB(stamp,i+1,1))=gif(i) then CheckFileType=true else CheckFileType=false
next
case "png"
stamp=fstream.read(4)
for i=0 to 3
if ascB(MidB(stamp,i+1,1))=png(i) then CheckFileType=true else CheckFileType=false
next
case "bmp"
stamp=fstream.read(2)
for i=0 to 1
if ascB(MidB(stamp,i+1,1))=bmp(i) then CheckFileType=true else CheckFileType=false
next
end select
fstream.Close
set fseteam=nothing
if err.number>0 then CheckFileType=false
end function
%>
您可能感興趣的文章:
  • ASP函數(shù)大全解析
  • 如何防范ASP木馬
  • asp防止上傳圖片木馬原理解析

標(biāo)簽:廣元 衢州 江蘇 蚌埠 大理 萍鄉(xiāng) 衡水 棗莊

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《ASP防止圖片木馬上傳的代碼》,本文關(guān)鍵詞  ;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問(wèn)題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無(wú)關(guān)。
  • 相關(guān)文章
  • 收縮
    • 微信客服
    • 微信二維碼
    • 電話(huà)咨詢(xún)

    • 400-1100-266