博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
关于Mysql + asp.net注射能支持多语句的感慨
阅读量:2436 次
发布时间:2019-05-10

本文共 2158 字,大约阅读时间需要 7 分钟。

在一篇老外的文章里面看到一个图表,致使Mysql + Asp.Net 注入时支持多语句

真的?有点不信,测试了下:

    protected void Page_Load(object sender, EventArgs e)

    {
        try
        {
            Response.Write("使用Mysql.Data.MySqlClient<br /><br />");
            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 + "<br />");
            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驱动<br /><br />");
        //    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 + "<br />");
        //    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常用的两个方式,一个是用Mysql.Data.MySqlClient这个类。二个try是使用更加传统的odbc方式。

Step 1:注释第一个代码段,访问 table test(i int) 结果得到如下的错误信息:

“/MysqlInj_test”应用程序中的服务器错误。

--------------------------------------------------------------------------------

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库下面看,表test没有被创建

Step 2:注释第二个代码段,刷新页面。页面返回

使用Mysql.Data.MySqlClient

SQL:select * from admin where id=1;create table test(i int)

继续按F5刷新这个页面,得到如下消息

使用Mysql.Data.MySqlClient

SQL:select * from admin where id=1;create table test(i int)
Error:Table 'test' already exists

跑到test库看,果然有个叫test的表被创建了。乖乖,看来老外说的是真的,但是对了一半。

原来Mysql能不能多语句执行,这和处理它的数据库驱动有很大关系。不知道是不是绝对联系,但是至少是一个重要的因素。

推而广之呢?

转载地址:http://eqqmb.baihongyu.com/

你可能感兴趣的文章
Server has authorization schema version 3,but found a schema version 1 user
查看>>
WebSphere的池设置——线程池、连接池
查看>>
caffe-ssd调试问题总结
查看>>
用户态调测工具(一):strace和ltrace
查看>>
用户态调测工具(二):perror和man
查看>>
机器学习&深度学习入门历程
查看>>
LTP(Linux Test Project)学习(一)——LTP介绍
查看>>
LTP(Linux Test Project)学习(二)——LTP下载编译执行
查看>>
LTP(Linux Test Project)学习(三)——LTP目录介绍
查看>>
caffe(master分支)Makefile.config分析
查看>>
LTP(Linux Test Project)学习(四)——LTP邮件列表订阅
查看>>
LTP(Linux Test Project)学习(五)——LTP代码学习
查看>>
DirtyCow CVE-2016-5195分析
查看>>
caffe编译报错解决记录
查看>>
LTP(Linux Test Project)学习(七)——LTP提交补丁
查看>>
Linux 4.0亮点特性
查看>>
LTP(Linux Test Project)学习(六)—— 问题分析:chattr命令的限制
查看>>
Linux 4.1亮点特性
查看>>
Caffe学习(二) —— 下载、编译和安装Caffe(源码安装方式)
查看>>
Linux 4.3 亮点特性
查看>>