| 设置SQL SERVER登录密码
rDatabase="sitelog" ''''设置SQL SERVER数据库名
set conn=Server.CreateObject("ADODB.Connection")
strconn="driver={sql server};server=" & rServer & ";uid=" & rUid & ";pwd=" & rPWD & ";database=" & rDatabase
conn.open strconn%>
SQL 注入的脆弱点发生在程序开发员构造一个WHERE 子句伴随着用户的输入的时候。比如,下面列出一个简单的ASP程序article_show.asp,它的功能是跟据GET获得的参数ID显示数据库info_article表中相应ID值的文章内容。
<%strID=Trim(Request.QueryString("ID"))
strSQL="select * from info_article where ID=" & strID
set rs=server.CreateObject("ADODB.Recordset")
rs.open strSQL,conn,1,3%>
<table width="100%" border="0" cellpadding="10" cellspacing="1" class="table1">
<tr class="trtitle">
<td><div align="center"><%=rs("title")%><br></div></td>
</tr>
<tr class="trcontent">
<td><%=rs("content")%></td>
</tr>
</table>
请注意strSQL="select * from info_article where ID=" & strID这一句。实际运行时,客户端应当使用类似http://www.abc.com/article_show.asp?ID=12这样的URL访问此ASP程序,当 上一页 [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] ... 下一页 >> |