今天写一篇关于站点安全的文章。 eq" ]%s
很多人做网站,直接下源代码,比如动易,动网等等,除了论坛代码本身爆出的漏洞之外,站长本身不对论坛的一些敏感信息进行修改。别人只需要简单的分析一下整站系统的版本,就能知道整站源代码,然后就能知道默认管理员账号和登录连接,还有就是能知道数据库路径等等! jtc~DL
所以我们下好整站系统之后就要相应的修改数据库路径以及管理账号和密码,同时要打好补丁! ]d`VT)~vje
关于自己亲手写的代码,要做好防注入,以下列出两个通用防注入代码: I|J/F}@p
<% bfO=;S]b!
'''''''''''''''''''''''''''''''''''''''''''''''' >MK98(F
'ASP通用防注入代码 |' .
'您可以把该代码COPY到头文件中.也可以单独作 a>)f=uS
'为一个文件存在,每次调用使用 BD-AI
'''''''''''''''''''''''''''''''''''''''''''''''' H1T.(M/"
Dim GetFlag Rem(提交方式) s7EinI{
^
Dim ErrorSql Rem(非法字符) W l16`9
Dim RequestKey Rem(提交数据) ,PZ ge
Dim ForI Rem(循环标记) ~4"dweu?
ErrorSql = "'~;~and~(~)~exec~update~count~*~%~chr~mid~master~truncate~char~declare" Rem(每个敏感字符或者词语请使用半角 "~" 格开) V,9cl,z+
ErrorSql = split(ErrorSql,"~") m3ff;,
If Request.ServerVariables("REQUEST_METHOD")="GET" Then {|\.i
GetFlag=True <1pEwI~
Else h1
{3njdr
GetFlag=False J=L5=G7(
End If fQ98(+6
If GetFlag Then 5?L<N:;J_
For Each RequestKey In Request.QueryString qa6,z.mQ
For ForI=0 To Ubound(ErrorSql) ;wVwX6:ZKr
If Instr(LCase(Request.QueryString(RequestKey)),ErrorSql(ForI))<>0 Then {x7,
response.write "<script>alert(""警告:\n请不要使用敏感字符"");location.href=""index.asp"";</script>" X(C$@N
Response.End >Se,;cB'/]
End If -![|}pX
Next Ve=b16H
Next tjnIN?YT
Else };g"GNy
For Each RequestKey In Request.Form Wl Sm
For ForI=0 To Ubound(ErrorSql) - YV>j
If Instr(LCase(Request.Form(RequestKey)),ErrorSql(ForI))<>0 Then T)})
pt!V
response.write "<script>alert(""警告:\n请不要使用敏感字符"");location.href=""index.asp"";</script>" Z6pUZ[j,
Response.End Ev P{p
End If {iLT/
i%
Next s{" 2L{,$
Next y?:.;%!E
End If D-4f.Tq4#
%> 2"5v[,$1H
------------------------------------------------------------------------------------------------------------------- W%)Y#C
2
FFD%O05
第二个: ;6wA"
;$tSb ~K+
<%
;>YzEo
'防止注入 g ci
dim qs,errc,iii %IRi1EmN8
qs=lcase(request.servervariables("query_string")) ASfaX:ke
'response.write(qs) +MLVbK
dim deStr(18) 6R5Qy]]E
deStr(0)="net user" 0RK!/:'
deStr(1)="xp_cmdshell" :yjFQ9^?&
deStr(2)="/add" LDD|(KLR*.
deStr(3)="exec%20master.dbo.xp_cmdshell" 4aY|TN/|
deStr(4)="net localgroup administrators" R$Q.sE
deStr(5)="select" f9;(C4+
deStr(6)="count" -(#iIgmP
deStr(7)="asc" ERt{H3eCcJ
deStr(8)="char" r9lR|\Ax2U
deStr(9)="mid" Q
IgNs
z
deStr(10)="'" -gWZwW/lD
deStr(11)=":" }T$p)"
deStr(12)="""" :lzrgsW
deStr(13)="insert" _y3Xb`0a
deStr(14)="delete" rbCAnwA2
deStr(15)="drop" {GO#.P"
deStr(16)="truncate" .6V}3q$-@
deStr(17)="from" qv"$Bd:]r
deStr(18)="%" "Pf~iwfw
errc=false 63A.@mL
for iii= 0 to ubound(deStr) hzRYec(
if instr(qs,deStr(iii))<>0 then <|\Lm20G]
errc=true N !|wo:
end if {V-v-f
next W];dD$Oqg
if errc then )/EO&F
Response.Write("对不起,非法URL地址请求!") `KQvJjA6
response.end ][]
end if |W\(kb+
%> ""D 4s
^KELKv,_
注入漏洞是最常见的漏洞,还有在线编辑漏洞,网上都有相关的防范方法。站点安全尤为重要,对站点的使用者有很大的影响,站点不安全,服务器就存在威胁!