SQLi-labs环境搭建及学习

环境搭建

SQL相关知识

SQL注释符

SQL注释符      URL编码
#               %23
--空格            --%20 --+
/*...*/

SQL 查询信息

version()       数据库版本信息
database()      数据库名称
user()          用户名

盲注(在不知道数据库返回值的情况下 对数据中的内容进行猜测)

盲注
布尔盲注:页面只返回TrueFalse两种类型页面。利用页面返回不同,逐个猜解数据

基于时间的盲注:通过页面沉睡时间判断

报错的盲注:构造payload让信息通过错误提示回显出来,一种类型(其它的暂时不怎么了解)是先报字段数,再利用后台数据库报错机制回显(跟一般的报错区别是,一般的报错注入是爆出字段数后,在此基础通过正确的查询语句,使结果回显到页面;后者是在爆出字段数的基础上使用能触发SQL报错机制的注入语句)

Lesson 1 GET-Error based-Single quotes-String

基于错误-单引号-字符注入

Lesson 2 GET-Error based-Intiger based

基于错误的数值注入
- 判断是否为数值注入
id=1 成功回显数据
id=1 and 1=1 成功回显数据
id=1 and 1=2 成功执行没有回显数据

Lesson 3 GET-Error based-Single quotes with twist-string

基于GET错误-单引号变形-字符
- 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
- 猜测id除了有单引号'' 还有()
select * from tablename where id=(' ')
- id=1') and 1=1--+ 成功回显

Lesson 4 GET-Error based-Double Quotes-String

基于错误-双引号-字符
- id=1' 一个单引号竟然成功回显了
id=1'' 两个单引号竟然成功回显了 好吧1'''被当作1执行了
- id=1" 报错for the right syntax to use near ' "3"") LIMIT 0,1' at line 1
- 猜测select * from tablename where id=(" ")
- id=1") and 1=1--+ 成功回显

Lesson 5 GET-Double Injection-Single Quotes-String

GET-双注入-单引号-字符
双注入用到的函数/语句

Rand()          随机函数
Floor()         取整函数
Count()         汇总函数
Group by clause 分组语句

Lesson 6 GET-Double Injection-Double Quotes-String

GET-双注入-双引号-字符串
- 同lesson5 单引号变双引号

Lesson 7 GET-Dump into outfile-String

GET-导出文件-字符型
- id=1 回显You are in.... Use outfile......
- 判断数值注入 id=1 and 1=2 还是回显You are in.... Use outfile......不是数值注入
- 判断字符注入 id=1' 回显You have an error in your SQL syntax有戏
id=1'--+ 回显You have an error in your SQL syntax
id=1')--+ 回显You have an error in your SQL syntax
id=1'))--+ 回显You are in.... Use outfile......

Lesson 8 GET-Blind-Boolian Based-Single Quotes

GET-盲注-基于布尔-单引号
- ?id=1 回显You are in...........
id=0 成功执行无回显

布尔盲注 成功查询到数据返回true 错误及无数据返回false