SQL 注入 C# SQL 示例 [重复]
Posted
技术标签:
【中文标题】SQL 注入 C# SQL 示例 [重复]【英文标题】:Example of SQL-Injection C# SQL [duplicate] 【发布时间】:2014-04-12 12:59:15 【问题描述】:好的。我想了解一些关于 SQL 注入的知识。
我有一个包含两个表的数据库,一个是 Logins,另一个是 Orders。 我有一个非参数化的 SQL 查询,如下所示。
// Select_Button click event
//connection con
//command comm
comm.commandtext = "Select * from Logins where User_na='"+textBox1.text+" Pass_wrd='"+textBox2.text+"'";
//Execute reader
//Insrt_button Event
//connection ins_con
//command ins_comm
ins_comm.commandText = "Insert Into Logins(User_na, Pass_wrd) values ('"+textBox3.text+'", '"+textBox4.text+"'")";
//Execute non-query
现在我想知道如何对我的数据库进行 SQL 攻击。例如,我如何删除数据库中的其他数据表。有可能吗?
非常感谢任何和所有帮助。
【问题讨论】:
***.com/questions/332365/… @Steve。链接有帮助,但是您的答案比整篇文章要清楚得多。干得好,先生。 【参考方案1】:只是为了展示 Sql Injection 非常简单,并且除了破坏数据之外,还可能导致其他不良影响
textbox1.Text = "' OR User_na LIKE '%'; --";
生成的 comm.CommandText 是
comm.commandtext = @"Select * from Logins where User_na='' OR User_na LIKE '%'--pass_wrd= 'xxx'";
SqlDataReader r = cmd.ExecuteReader();
if(r.HasRows)
MessageBox.Show("The poor programmer was tricked by a smart hacker");
.....
然后根据您如何检查查询结果,未经身份验证的用户可以访问您的程序
【讨论】:
是的,完美的解决方案.. 就像一个魅力......感谢很多兄弟..以上是关于SQL 注入 C# SQL 示例 [重复]的主要内容,如果未能解决你的问题,请参考以下文章