今天写一篇关于站点安全的文章。 CQ{p
v3)
很多人做网站,直接下源代码,比如动易,动网等等,除了论坛代码本身爆出的漏洞之外,站长本身不对论坛的一些敏感信息进行修改。别人只需要简单的分析一下整站系统的版本,就能知道整站源代码,然后就能知道默认管理员账号和登录连接,还有就是能知道数据库路径等等! n&Q0V.
所以我们下好整站系统之后就要相应的修改数据库路径以及管理账号和密码,同时要打好补丁! a0k/R<4
关于自己亲手写的代码,要做好防注入,以下列出两个通用防注入代码: s?9`dv}P
<% +}g6X6m
'''''''''''''''''''''''''''''''''''''''''''''''' =+VDb5= TV
'ASP通用防注入代码 &jrc]
'您可以把该代码COPY到头文件中.也可以单独作 (V}?y:)
'为一个文件存在,每次调用使用 Lu71Qdu09
'''''''''''''''''''''''''''''''''''''''''''''''' Wq25, M'
Dim GetFlag Rem(提交方式) t#!AfTY$w
Dim ErrorSql Rem(非法字符) 7<*g'6JG[
Dim RequestKey Rem(提交数据)
(2
P&@!|
Dim ForI Rem(循环标记) Vc8w[oS
ErrorSql = "'~;~and~(~)~exec~update~count~*~%~chr~mid~master~truncate~char~declare" Rem(每个敏感字符或者词语请使用半角 "~" 格开) Kciz^)
'Z
ErrorSql = split(ErrorSql,"~") U]M
5&R=?
If Request.ServerVariables("REQUEST_METHOD")="GET" Then
(
s51GRC
GetFlag=True KO))2GET
Else u`*1OqU
GetFlag=False \h}sA
End If #=ko4?Wr(
If GetFlag Then bhKe"#m|S
For Each RequestKey In Request.QueryString 94lz?-j
For ForI=0 To Ubound(ErrorSql) R$2\Xl@qQF
If Instr(LCase(Request.QueryString(RequestKey)),ErrorSql(ForI))<>0 Then I#(?xHx
response.write "<script>alert(""警告:\n请不要使用敏感字符"");location.href=""index.asp"";</script>" 1_mqPMm
Response.End _Q*,~ z~
End If GCrsf
Next 0.~s>xXp
Next h.xtkD)Y~
Else +~xzgaL
For Each RequestKey In Request.Form N.V
5>2
For ForI=0 To Ubound(ErrorSql) 2\"T&
If Instr(LCase(Request.Form(RequestKey)),ErrorSql(ForI))<>0 Then <.
V*]g/;
response.write "<script>alert(""警告:\n请不要使用敏感字符"");location.href=""index.asp"";</script>" i@=(Y~tD`
Response.End
+^$E)Ol
End If S;u2B_/
Next :?gp}.
Next h\6 t\_^\
End If b:x~Jz#%2
%> 8wCB}q C
------------------------------------------------------------------------------------------------------------------- #,SPV&
+[V.yY/t|>
第二个: -c[fg+L9
\mFgjPz
<% 1/=6s5vS}
'防止注入 \5#
eBJ
dim qs,errc,iii Vzh\1cF
qs=lcase(request.servervariables("query_string")) Q*9Y.W. 8
'response.write(qs) @f#6Nu
dim deStr(18) /vLW{ %
deStr(0)="net user" EiPOY'
deStr(1)="xp_cmdshell" F>k/;@d
deStr(2)="/add" .p78
\T
deStr(3)="exec%20master.dbo.xp_cmdshell" 2t3)$\ylQp
deStr(4)="net localgroup administrators" 6"2IV
deStr(5)="select" Upc_"mkI.
deStr(6)="count" ;(Z9.
deStr(7)="asc" /9ZU_y4&3f
deStr(8)="char" rL/H{.@$`
deStr(9)="mid" i&L!?6 5-f
deStr(10)="'" 6^ ,;^
deStr(11)=":" K{iC'^wP
deStr(12)="""" (I#3![q
deStr(13)="insert" SM.KM_%K
deStr(14)="delete" >B$B|g~
deStr(15)="drop" !!)NER-dv
deStr(16)="truncate" }n k[WW
deStr(17)="from" ?V =#x.9
deStr(18)="%" _"#n%@
errc=false C:vVFU|4
for iii= 0 to ubound(deStr) >%c>R'~h
if instr(qs,deStr(iii))<>0 then wd2z=^S~
errc=true mfk^t`w_
end if 3oPyh $*
next pvdCiYo1r
if errc then 'On%p|s)H
Response.Write("对不起,非法URL地址请求!") nCLEAe$W\=
response.end N LSJ
D
end if CH0Nkf
%> 4@9xq<<5
H6MG5f_
注入漏洞是最常见的漏洞,还有在线编辑漏洞,网上都有相关的防范方法。站点安全尤为重要,对站点的使用者有很大的影响,站点不安全,服务器就存在威胁!