• <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>
  • 提高Linux安全等級

    發表于:2007-07-02來源:作者:點擊數: 標簽:
    Linux 缺省的 安全 等級是0,如果將其升到1,就可以一定程度上提高系統的安全性.安全等級為1的時候,它會禁止修改ex2fs系統中文件的immutable和append-only位,同時禁止裝入/移除module.所以我們可以先用chattr +i 將大部分的可執行文件,動態連接庫,一些重要的系

        Linux缺省的安全等級是0,如果將其升到1,就可以一定程度上提高系統的安全性.安全等級為1的時候,它會禁止修改ex2fs系統中文件的immutable和append-only位,同時禁止裝入/移除module.所以我們可以先用chattr +i 將大部分的可執行文件,動態連接庫,一些重要的系統文件(inetd.conf,securetty,hosts.allow,hosts.deny,rc.d下的啟動script...)加上immutable位,這樣"黑客"就很難在你的機器上放置木馬和留后門了. (即便他已經得到了root權限,當然通過直接硬盤讀寫仍然可以修改,但比較麻煩而且危險).

        "黑客"們一旦進入系統獲得root,首先會清除系統的記錄文件.你可以給一些系統記錄文件(wtmp,messages,syslog...)增加append-only位,使"黑客"不能輕易的修改它們.要抓他們就容易多了.:-)

        修改安全等級比較直接的辦法是直接修改內核源碼.將linux/kernel/sched.c中的securelevel設成1即可.不過如果要改變安全等級的話需要重新編譯內核,我太懶,不想那么麻煩.:-)

        為什么不用module呢?我寫了個很簡單的lkm和一個client程序來完成安全等級的切換.
    方法: insmod lkm; clt -h;
        注意:普通用戶也可以執行clt來切換安全等級,所以最好是在clt和lkm中加段密碼檢查,如果密碼不對就不允許執行.:-)這兩個程序在Redhat 5.2(2.0.36)下編譯運行通過.對于2.2.x的內核,securelevel變成了securebits,簡單的將它改到1,會連setuid()都被禁止了,這樣普通用戶就不能登陸了.如果誰對2.2.x比較熟悉,請不吝賜教,共同提高嘛.:)
        <在測試這些程序以前,請備份重要數據.本人不為運行此程序帶來的任何損失負責.>
        (一旦securelevel=1,kernel將不允許裝入modlue,所以你的kerneld可能不能正常工作,而且禁止你訪問/dev/kmem,所以有些用到svgalib的程序也不能正常工作,象zgv什么的。不過這本來就是安全隱患,所以不工作就不工作好了,呵呵)(關于chattr,lsaddr請man chattr和man lsattr)


    /**************************** lkm.c ********************************/

    /* Simple lkm to secure Linux.

    * This module can be used to change the securelevel of Linux.

    * Running the client will switch the securelevel.

    *

    * gcc -O3 -Wall -c lkm.c

    * insmod lkm

    *

    * It is tested in Redhat 5.2 (2.0.36).

    * (It should be modified if you want to run it in 2.2.x kernel).

    * It is really very simple,but we just for educational purposes.:-)

    *

    *

    */

    #define MODULE
    #define __KERNEL__
    #include
    #include
    #include
    #include
    #include
    #include
    #include
    #include
    #include
    #include
    #include
    #include
    #include
    #include
    #include
    #define __NR_secureswitch 250

    extern void *sys_call_table[];

    int sys_secureswitch(int secure)
    {
    if(secure==0) securelevel=0;
    if(secure==1) securelevel=1;
    return securelevel;
    }

    int init_module(void)
    {
    sys_call_table[__NR_secureswitch] = (void *)sys_secureswitch;
    return 0;
    }

    void cleanup_module(void)
    {
    sys_call_table[__NR_secureswitch] = NULL;
    return;
    }

    /************************ clt.c **************************/

    /*
    * This client can switch the secure level of Linux.
    *
    * gcc -O3 -Wall -o clt clt.c
    * Usage: clt -h/-l
    * -h switch to the high secure level.
    * -l switch to the low secure level.
    *
    * Most of codes are ripped from smiler.:)
    *
    */

    #include
    #include
    #include
    #define __NR_secureswitch 250

    static inline _syscall1(int, secureswitch, int, command);

    int main(int argc,char **argv)
    {
    int ret,level = 0;
    if (argc < 2)
    {
    fprintf(stderr,"Usage: %s [-h/-l]n",argv[0]);
    exit(-1);
    }

    if (argv[1][1] == @#h@#) level++;
    else if (argv[1][1] != @#l@#)
    {
    fprintf(stderr,"Usage: %s [-h/-l]n",argv[0]);
    exit(-1);
    }
    ret = secureswitch(level);

    if (ret < 0)
    printf("Hmmm...It seemed that our lkm hasn@#t been loaded.;-)n");
    else {
    if (ret == 0) {
    puts("Now the secure level is changed to 0!n");
    } else {
    puts("Now the secure level is chagned to 1!n");
    }
    }
    return(1);
    }
    摘自:http://linux.wuxi.net.cn/docs/safety/safelevel.html

    原文轉自:http://www.kjueaiud.com

    老湿亚洲永久精品ww47香蕉图片_日韩欧美中文字幕北美法律_国产AV永久无码天堂影院_久久婷婷综合色丁香五月

  • <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>