如何修补或修复.asp中的sql注入 [英] how to patch or fix sql inject in .asp

查看:76
本文介绍了如何修补或修复.asp中的sql注入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<!--#include file=../db.asp-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<link href="styles.css" rel="stylesheet" type="text/css">
<title>Validate Login </title>
</head>
<body>

<p>&nbsp;</p>
<p>&nbsp;</p>
<table border="0" align="center">
  <tr>
    <td align="center" valign="top"><%
dim rs
if Request.Form("LoginID")<>"" and Request.Form("Password")<>"" then
	Set rs=Server.CreateObject("ADODB.RecordSet")
	rs.open "Select role from users where [UserID]='" & Request.form("LoginID") & "' and [Password]='" & Request.Form("Password") & "'",con,1,3
	if not rs.eof  then 
		Session("LoginID")= Request.form("LoginID")
		response.redirect("Managenews.asp")
	else
		response.write ("<h1 class=articleheader> Invalid login or password...</h1>")
		response.write ("<h3> <a href=index.htm class=txtlinks> Please Try Again...</a></h3>")
	end if
End if	
%></td>
  </tr>
</table>

</body>
</html>

推荐答案

Google用于VBScript参数化sql查询。



另外,你在数据库中以明文形式存储密码是一个很大的错误。
Google for "VBScript parameterized sql queries".

Also, you're making the MASSIVE mistake of storing password in clear text in your database.


修复SQL注入的路径听起来很荒谬。 SQL注入是一种恶意技术;它不应该被修补或修复。



你的方法从一开始就是错误的。通过串联从UI获取的字符串组成的查询。不仅重复的字符串连接是低效的(因为字符串是不可变的;我是否必须解释为什么它会使重复连接变坏?),但是,当然,更重要的一个问题是 SQL注入。



这是它的工作原理: http:// xkcd.com/327



你明白了吗?从控件中获取的字符串可以是任何东西,包括......一段SQL代码。



怎么办?只需阅读有关此问题和主要补救措施:参数化语句 http://en.wikipedia.org/ wiki / SQL_injection



使用ADO.NET,使用:http://msdn.microsoft.com/en-us/library/ff648339.aspx



请参阅我过去的答案有更多细节:

在com.ExecuteNonQuery中更新EROR( );

嗨名字没有显示在名称中?



-SA
"Path of fix SQL inject" sounds absurd. "SQL injection" is a malicious technique; it should not be "patched or fixed".

Your approach is wrong from the very beginning. The query composed by concatenation with strings taken from UI. Not only repeated string concatenation is inefficient (because strings are immutable; do I have to explain why it makes repeated concatenation bad?), but, of course, a way more important issue is the vulnerability to SQL injection.

This is how it works: http://xkcd.com/327.

Are you getting the idea? The string taken from a control can be anything, including… a fragment of SQL code.

What to do? Just read about this problem and the main remedy: parametrized statements: http://en.wikipedia.org/wiki/SQL_injection.

With ADO.NET, use this: http://msdn.microsoft.com/en-us/library/ff648339.aspx.

Please see my past answers for some more detail:
EROR IN UPATE in com.ExecuteNonQuery();,
hi name is not displaying in name?.

—SA


这篇关于如何修补或修复.asp中的sql注入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆