今天写一篇关于站点安全的文章。 ~S3eatM$9
很多人做网站,直接下源代码,比如动易,动网等等,除了论坛代码本身爆出的漏洞之外,站长本身不对论坛的一些敏感信息进行修改。别人只需要简单的分析一下整站系统的版本,就能知道整站源代码,然后就能知道默认管理员账号和登录连接,还有就是能知道数据库路径等等! ]lU
u%<-;
所以我们下好整站系统之后就要相应的修改数据库路径以及管理账号和密码,同时要打好补丁! {<kG{i/
关于自己亲手写的代码,要做好防注入,以下列出两个通用防注入代码: ZhsZywM
<% @m V C
'''''''''''''''''''''''''''''''''''''''''''''''' ju]]|
'ASP通用防注入代码 |'c4er/;#
'您可以把该代码COPY到头文件中.也可以单独作 5,
-pBep<
'为一个文件存在,每次调用使用 wI!
+L&Q
'''''''''''''''''''''''''''''''''''''''''''''''' L
iZdRr
Dim GetFlag Rem(提交方式) >AQ)x
Dim ErrorSql Rem(非法字符) [Iw>|q<e
Dim RequestKey Rem(提交数据) %e
Sm&`
Dim ForI Rem(循环标记) ^r>f2 x
ErrorSql = "'~;~and~(~)~exec~update~count~*~%~chr~mid~master~truncate~char~declare" Rem(每个敏感字符或者词语请使用半角 "~" 格开) kz0I2!bt
ErrorSql = split(ErrorSql,"~") &^&$!Xmu9
If Request.ServerVariables("REQUEST_METHOD")="GET" Then W ""*hJ
GetFlag=True 2"leUur~rO
Else =!(*5\IM
GetFlag=False A{z>D`d
End If N )zPxQ
If GetFlag Then v`S2M
For Each RequestKey In Request.QueryString r+{d!CHq}
For ForI=0 To Ubound(ErrorSql) xN`r4
If Instr(LCase(Request.QueryString(RequestKey)),ErrorSql(ForI))<>0 Then j?\$G.Y
response.write "<script>alert(""警告:\n请不要使用敏感字符"");location.href=""index.asp"";</script>" -".kH<SWv
Response.End m']9Q3-
End If Rk
pr8MS
Next mPs%ZC
Next dUoWo3r=
Else 5[,+\
For Each RequestKey In Request.Form 'u(=eJ@1
For ForI=0 To Ubound(ErrorSql) %'L].+$t
If Instr(LCase(Request.Form(RequestKey)),ErrorSql(ForI))<>0 Then Cs:+93w
response.write "<script>alert(""警告:\n请不要使用敏感字符"");location.href=""index.asp"";</script>" 5=Kq
@[(4
Response.End cgs3qI
End If Q`S iV
Next O`i)?BC
Next =6cyE
End If |5=~(-I>@
%> ZD5
I5
------------------------------------------------------------------------------------------------------------------- %/l-A
pu
[x!i*
rW3
第二个: #)^^_
5zNSEI"PY
<% #y=ZP:{:t
'防止注入 @s%X
dim qs,errc,iii |*^8~u3J"
qs=lcase(request.servervariables("query_string")) EkJVFHfh
'response.write(qs) y]}b?R~p=
dim deStr(18) EI1W
.V>@
deStr(0)="net user" =U4f}W;
deStr(1)="xp_cmdshell" ]}z'X!v_@
deStr(2)="/add" ;OOj[%.
deStr(3)="exec%20master.dbo.xp_cmdshell" {ExII<=6
deStr(4)="net localgroup administrators" \G$QNUU
deStr(5)="select" ,
Aq9fyC%
deStr(6)="count" >vWEUE[
deStr(7)="asc" :7p9t.R<$h
deStr(8)="char" +
a-wv
deStr(9)="mid" `d7gm;ykp
deStr(10)="'" 5vD3K!\u
deStr(11)=":" SU%mmwES3
deStr(12)="""" xw PI
deStr(13)="insert"
t=n+3`g
deStr(14)="delete" lSH ZV
Fd
deStr(15)="drop" k"">2#V
deStr(16)="truncate" q&zny2])
deStr(17)="from" (M ]XNn
deStr(18)="%" vv+TKO
errc=false MV:W@)rg
for iii= 0 to ubound(deStr) K;oV"KRK
if instr(qs,deStr(iii))<>0 then f).*NX
errc=true X=v~^8M7%
end if /8xH$n&xoC
next 4|[<e-W
if errc then TC qkm^xv
Response.Write("对不起,非法URL地址请求!") P+Wm9xR2d
response.end :KEq<fEI
end if C,o:
%> oW0gU?Rr)u
!|:RcH[
注入漏洞是最常见的漏洞,还有在线编辑漏洞,网上都有相关的防范方法。站点安全尤为重要,对站点的使用者有很大的影响,站点不安全,服务器就存在威胁!