bash是linux默认命令行管理程序shell。汉澳 sinox也安装有,尽管sinox并没有默认使用bash。可是用户一旦使用就会可能被通过漏洞入侵,所以必须高速修复。尽管sinox使用freebsd 的ports,可是freebsd已经升级到最新的软件管理pkg,ports正在被淘汰,要通过portsnap直接更新到最新的ports然后用pkg安装。只是最新的ports仅仅是在freebsd10以上使用。对于低版本号pkg可能不支持。无论怎么说,假设你要用pkg,仅仅能用freebsd10,否则问题会非常多,pkg会直接升级到软件的最新版本号。pkg产生是为了实现类似yum直接更新二进制程序。

要想编译最新的ports,先编译安装最新的pkg。

最新的ports在sinox执行有的程序会有问题的。

既然如此。我们仅仅能改动 sinox当前版本号bash,把漏洞堵上去。先看bash漏洞。

执行env x='() { :;}; echo vulnerable’ bash -c “echo this is a test”

产生结果

vulnerable

echo this is a test

问题是,环境变量x通过() { :;}; echo vulnerable获得,但当中echo是系统命令。会运行。

假设把 echo vulnerable改成ls,pwd会怎么样,假设是sudo就会获得超级管理员的权限。

网页用户能够通过cgi程序等方式使用bash执行指令控制系统。

我查阅了网上资料,堵漏洞原理就是修改程序中对引入函数的处理,并參考了最新bash ports修改方式,制定了当前版本号bash堵漏洞办法。

先用make extract,make patch把代码解压出来,然后备份shell.c和variables.c为后面加.orig,然后改动shell.c和variables.c,改好后进入源代码文件夹生成补丁。

diff -uN shell.c.orig shell.c > shell.c.patch

diff -uN variables.c.orig variables.c >variables.c.patch

把生成的patch文件放到ports源代码files文件夹.然后在 Makefile添加这两行

EXTRA_PATCHES+= ${PATCHDIR}/shell.c.patch

EXTRA_PATCHES+= ${PATCHDIR}/variables.c.patch

如今进入文件夹,make clean;make。检查一下代码是否已经改正好。

假设好了就make install.

为了强制安装,我在/etc/make.conf添加

FORCE_PKG_REGISTER=yes

安装好了以后。执行bash。输入上面命令行,不再出现vulnerable,修复成功。

为了用gcc4.6编译,我在make.conf设置

DISABLE_VULNERABILITIES=YES

.if !empty(.CURDIR:M/usr/ports/*) && exists(/usr/local/bin/gcc46)

CC=gcc46

CXX=g++46

CPP=cpp46

.endif

以下粘贴patch文件

shell.c.patch

— shell.c.orig 2011-01-03 05:04:51.000000000 +0800

+++ shell.c 2014-10-11 17:37:30.000000000 +0800

@@ -225,7 +225,7 @@

#else

int posixly_correct = 0; /* Non-zero means posix.2 superset. */

#endif



+int import_functions = 0;//IMPORT_FUNCTIONS_DEF; //patch

/* Some long-winded argument names. These are obviously new. */

#define Int 1

#define Charp 2

@@ -244,6 +244,7 @@

{ “help”, Int, &want_initial_help, (char **)0x0 },

{ “init-file”, Charp, (int *)0x0, &bashrc_file },

{ “login”, Int, &make_login_shell, (char **)0x0 },

+ { “import-functions”, Int, &import_functions, (char **)0x0 }, //patch

{ “noediting”, Int, &no_line_editing, (char **)0x0 },

{ “noprofile”, Int, &no_profile, (char **)0x0 },

{ “norc”, Int, &no_rc, (char **)0x0 },

variables.c.patch

— variables.c.orig 2014-10-11 19:22:10.000000000 +0800

+++ variables.c 2014-10-11 19:21:34.000000000 +0800

@@ -100,6 +100,7 @@

extern int assigning_in_environment;

extern int executing_builtin;

extern int funcnest_max;

+extern int import_functions;//patch

#if defined (READLINE)

extern int no_line_editing;

@@ -312,7 +313,8 @@

char *name, *string, *temp_string;

int c, char_index, string_index, string_length;

SHELL_VAR *temp_var;



+ int skipped_import;//patch

+

create_variable_tables ();

for (string_index = 0; string = env[string_index++]; )

@@ -335,11 +337,18 @@

char_index == strlen (name) */

temp_var = (SHELL_VAR *)NULL;



+ skipped_import = 0;//patch

+reval: //patch

/* If exported function, define it now. Don’t import functions from

the environment in privileged mode. */

– if (privmode == 0 && read_but_dont_execute == 0 && STREQN (“() {“, string, 4))

+ if (skipped_import == 0 && privmode == 0 && read_but_dont_execute == 0 && STREQN (“() {“, string, 4)) //patch

{

+ if (!import_functions && !interactive_shell) { //patch————

+ skipped_import = 1;

+ //report_error (_(“Skipping importing function definition for `%s': –import-functions required.”), tname);

+ goto reval;

+ } //———–patch

+

string_length = strlen (string);

temp_string = (char *)xmalloc (3 + string_length + char_index);

我为sinox2014就是64位制作了bash修复安装包。安装命令例如以下|

pkg_add -f ftp://sinox.3322.org/bash-4.2.20.tbz

sinox2013没有制作修复安装包。大家能够自己按上面说明自己编译修复。

高速修复汉澳sinox命令解释程序bash shell漏洞的更多相关文章

  1. 汉澳sinox不受openssl心血漏洞影响并分析修复其漏洞代码

    OpenSSL 心血(HeartBleed)漏洞 是openssl 在 2014-04-07 发布的重大安全漏洞(CVE-2014-0160)这个漏洞使攻击者可以从server内存中读取64 KB的数 ...

  2. 非常多人不愿意承认汉澳sinox已经超过windows

    汉澳sinox採用的zfs和jail打造高可靠性存储server和矩阵计算机,这不是windows和linux能相提并论的. 只是非常多人立即出来出来反驳说,windows驱动程序多(就是支持硬件多) ...

  3. 汉澳sinox通过ndis执行windows驱动程序

    汉澳sinox不仅能通过wine执行windows应用程序.还能通过ndis执行windows驱动程序 汉澳sinox使用 Windows NDIS 驱动程序 详细实现方法是用ndisgen把wind ...

  4. bash shell漏洞及测试

    1.bash shell是大多数linux发行版本的默认shell命令解释器,但是最近爆出bash shell存在漏洞. 2.如果Bash是默认的系统shell,网络攻击者可以通过发送Web请求.se ...

  5. 汉澳Sinox2014X64server高级桌面服务器版操作系统公布

    汉澳Sinox2014X64server高级桌面服务器版操作系统公布   当你在现代城市夜空中看到一道闪电.屏幕中央闪过几个图形,转眼间变成美轮美奂的紫色空中天国,说明你来到了汉澳sinox2014世 ...

  6. 开发汉澳即时通信网,2006年上线,QQ死期到了

    为汉澳sinox用户打造即时通信网让大家用上即时通信软件 近期腾讯关闭了linuxQQ登录,汉澳 sinox也登陆不上.非windows用户再也不能用上即时通信软件了! 这是多么可悲的事,可是我们必须 ...

  7. 汉澳sinox2014没有黑屏,一个能够依靠的安全避风港

    首先汉澳sinox2014没有验证server,根本就没办法区分正版和盗版 其次汉澳sinox2014安装也没有系列号cdkey等东西,直接安装无干扰 最后汉澳sinox2014不会有黑屏这样的东西. ...

  8. 《Linux命令行与shell脚本编程大全》 第三章 学习笔记

    第三章:基本的bash shell命令 bash程序使用命令行参数来修改所启动shell的类型 参数 描述 -c string 从string中读取命令并处理他们 -r 启动限制性shell,限制用户 ...

  9. Linux Shell——bash shell 脚本简介

    bash shell 脚本简介 shell 运行环境 如果你运行的是 Unix 或 Linux 系统,例如 Ubuntu,Red Hat,SUSE Linux,还有macOS,都是内置了 bash s ...

随机推荐

  1. JS中 this 的四种用法

    1.在一般函数中使用 this 指全局对象 window function fn(){ this.x = 1 } fn(); //相当于window.fn() 2.作为对象方法使用 this 指该对象 ...

  2. Codeforces Round #315 (Div. 2)【贪心/重排去掉大于n的元素和替换重复的元素】

    B. Inventory time limit per test 1 second memory limit per test 256 megabytes input standard input o ...

  3. 伪全栈工程师做的有点简陋的ui设计

    站酷:http://www.zcool.com.cn/work/ZMjEwMDIxMDA=.html 这个app 叫自我时间管理  是一个 工具  管理自己开会 购物 健身 记账等 的提醒与管理,还可 ...

  4. Java获取路径的方法分析详解(Application/Web)

    1.利用System.getProperty()函数获取当前路径: System.getProperty("user.dir");//user.dir用户当前的工作目录,输出:D: ...

  5. 深入浅出 Cocoa 之 Core Data(2)- 手动编写代码

    深入浅出 Cocoa 之 Core Data(2)- 代码示例 罗朝辉(http://blog.csdn.net/kesalin) CC 许可,转载请注明出处 前面详细讲解了 Core Data 的框 ...

  6. mac 安装 office

    1.下载word2016,可以网上搜一下,很多资源 当然这里将我用的版本提供给你: 链接: https://pan.baidu.com/s/1mix07lY 密码: asgc   一直默认下一步进行安 ...

  7. SSD配置

    SSD: Single Shot MultiBox Detector - 运行“ make -j32”时出错: nvcc warning : The 'compute_20', 'sm_20', an ...

  8. DesignSurface简介

    The Perfect Host: Create And Host Custom Designers With The .NET Framework 2.0 Dinesh Chandnani - 三月 ...

  9. C#自定义MessageBox 按钮的Text

    运行效果: 代码: using System; using System.Drawing; using System.Runtime.InteropServices; using System.Tex ...

  10. 解决Linux下AES解密失败

    前段时间,用了个AES加密解密的方法,详见上篇博客AES加密解密. 加解密方法在window上測试的时候没有出现不论什么问题.将加密过程放在安卓上.解密公布到Linuxserver的时候,安卓将加密的 ...