mysql支持asp.net_关于Mysql + asp.net注射能支持多语句的感慨(2月)
關(guān)于Mysql + asp.net注射能支持多語(yǔ)句的感慨
2010-09-07 03:32
在一篇老外的文章里面看到一個(gè)圖表,致使Mysql + Asp.Net 注入時(shí)支持多語(yǔ)句
真的?有點(diǎn)不信,測(cè)試了下:
protected void Page_Load(object sender, EventArgs e)
{
try
{
Response.Write(“使用Mysql.Data.MySqlClient
“);
string myConnectionString = “server=localhost;user id=root;password=123456;database=test”;
MySqlConnection myConnection = new MySqlConnection(myConnectionString);
string myQuery = “select * from admin where id=” + Request.QueryString["id"];
Response.Write(“SQL:” + myQuery + “
“);
MySqlCommand myCommand = new MySqlCommand(myQuery, myConnection);
myConnection.Open();
myCommand.ExecuteReader();
myCommand.Connection.Close();
}
catch (MySqlException err)
{
Response.Write(“Error:” + err.Message);
}
//try
//{
// Response.Write(“使用Mysql ODBC驅(qū)動(dòng)
“);
// string myConnectionString = “DRIVER={MySQL ODBC 3.51 Driver};SERVER=localhost;DATABASE=test;UID=root;PASSWORD=123456;OPTION=3″;
// string myQuery = “select * from admin where id=” + Request.QueryString["id"];
// Response.Write(“SQL:” + myQuery + “
“);
// OdbcConnection myConnection = new OdbcConnection(myConnectionString);
// OdbcCommand myCommand = new OdbcCommand(myQuery, myConnection);
// myConnection.Open();
// myCommand.ExecuteReader();
// myCommand.Connection.Close();
//}
//catch(OleDbException err)
//{
// Response.Write(“Error:” + err.Message);
//}
}
這里面是連接mysql常用的兩個(gè)方式,一個(gè)是用Mysql.Data.MySqlClient這個(gè)類。二個(gè)try是使用更加傳統(tǒng)的odbc方式。
Step 1:注釋第一個(gè)代碼段,訪問(wèn)http://localhost:2928/MysqlInj_test/MysqlInj_test.aspx?id=1;create table test(i int) 結(jié)果得到如下的錯(cuò)誤信息:
“/MysqlInj_test”應(yīng)用程序中的服務(wù)器錯(cuò)誤。
——————————————————————————–
ERROR [42000] [MySQL][ODBC 3.51 Driver][mysqld-5.0.45-community-nt]You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘;create table test(i int)’ at line 1
到test庫(kù)下面看,表test沒(méi)有被創(chuàng)建
Step 2:注釋第二個(gè)代碼段,刷新頁(yè)面。頁(yè)面返回
使用Mysql.Data.MySqlClient
SQL:select * from admin where id=1;create table test(i int)
繼續(xù)按F5刷新這個(gè)頁(yè)面,得到如下消息
使用Mysql.Data.MySqlClient
SQL:select * from admin where id=1;create table test(i int)
Error:Table ‘test’ already exists
跑到test庫(kù)看,果然有個(gè)叫test的表被創(chuàng)建了。乖乖,看來(lái)老外說(shuō)的是真的,但是對(duì)了一半。
原來(lái)Mysql能不能多語(yǔ)句執(zhí)行,這和處理它的數(shù)據(jù)庫(kù)驅(qū)動(dòng)有很大關(guān)系。不知道是不是絕對(duì)聯(lián)系,但是至少是一個(gè)重要的因素。
推而廣之呢?
總結(jié)
以上是生活随笔為你收集整理的mysql支持asp.net_关于Mysql + asp.net注射能支持多语句的感慨(2月)的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: mysql 录入窗体设计_在Access
- 下一篇: python十进制转二进制循环_pyth