sql注入
2016-02-21 21:27
232 查看
六.暴力破解密码
目前的登陆和修改密码,没有错误次数的限制。
Solution: 是否可以加入新的逻辑:单位时间内输入错误次数大于一个数值时,改账号会被冻结。可以由改company的admin 解冻 或者发送申请到 sunnet后由sunnet公司解冻。
1.web.config里加链接字段:
[html] viewplain copy
<configuration>
<connectionStrings >
<add name="myConnectionString"
connectionString="Server=10.231.248.177;Database=testdb;User ID=sa;Password=pa$$word;Trusted_Connection=False;"
providerName="System.Data.SqlClient"/>
</connectionStrings>
2.拖几个控件在form里:
[html] viewplain copy
<form id="form1" runat="server">
<asp:Label ID="LU" runat="server" Text="User Name:"></asp:Label>
<asp:TextBox ID="TBU" runat="server"></asp:TextBox>
<br/>
<asp:Label ID="LP" runat="server" Text="Password:"></asp:Label>
<asp:TextBox ID="TBP" runat="server"></asp:TextBox>
<br/>
<asp:Button ID="Login" runat="server" Text="Login" OnClick="Login_Click" />
<div>
3.写登录事件:
[csharp] viewplain copy
protected void Login_Click(object sender, EventArgs e)
{
using(SqlConnection con = new SqlConnection(WebConfigurationManager.ConnectionStrings["myConnectionString"].ConnectionString))
{
con.Open();
SqlCommand cmd = new SqlCommand();
cmd.CommandText = "SELECT Count(1) FROM [User] where UserName='" + TBU.Text.Trim() + "' and Password='" + TBP.Text.Trim() + "'";
cmd.CommandType = CommandType.Text;
cmd.Connection = con;
int count =(int) cmd.ExecuteScalar();
Response.Write(cmd.CommandText);
if (count > 0)
{
Response.Write("<script>alert('Login pass!');</script>");
}
else
{
Response.Write("<script>alert('Login fail!');</script>");
}
}
}
4.构造SQL注入登录:
用户名输入:test' or ''='密码输入:' or ''='
或者
用户名输入:test
密码输入:' or ''='
如图:
其他ASP.net SQL注入的例子,如果有兴趣可以参考下:
http://www.aspsnippets.com/Articles/SQL-Injection-Attack-its-examples-and-Prevention-mechanisms-and-Techniques-in-ASPNet.aspx
http://www.codeproject.com/Articles/459324/Understading-SQL-Injection-and-Creating-SQL-Inject
http://blogs.iis.net/nazim/sql-injection-demo
其他的SQL注入:http://www.unixwiz.net/techtips/sql-injection.html
相关文章推荐
- oracle之事务控制
- 【SQL】θ联接(Theta Join)和交叉联接(Cross Join)
- UDL ODBC 获取数据库连接字符串
- mysql学习笔记(1)
- Oracle 经常使用命令小结
- PHP_Memcache函数详解
- Redis替代文件存储session
- PHP 使用memcached
- win7下安装mysql
- oracle11g在没DNS情况下failover的配置方法
- SQL Server ->> 深入探讨SQL Server 2016新特性之 --- Temporal Table(历史表)
- C++自制Redis 数据库(十二) 初级存储引擎已经测试完毕
- 统计Oracle数据库文件的大小
- JUnit应用实例:数据库程序单元测试
- 简单几步快速预判oracle 数据库运行状态
- 使用sqlldr导入GPS数据含有clob字段和双引号
- oracle表空间使用率查询
- C#读取本地磁盘下指定路径下的所有图片,并以二进制存入数据库
- mysql 服务启动error:1067错误
- 学习mysql比较好一些书籍