日韩久久久精品,亚洲精品久久久久久久久久久,亚洲欧美一区二区三区国产精品 ,一区二区福利

Linux Security Framework -- Apparmor機(jī)制介紹

系統(tǒng) 2506 0

AppArmor 是一個類似于selinux 的東東,主要的作用是設(shè)置某個可執(zhí)行程序的訪問控制權(quán)限,可以限制程序 讀/寫某個目錄/文件,打開/讀/寫網(wǎng)絡(luò)端口等等。

Novell給出的Apparmor的解釋:

?AppArmor is designed to provide easy-to-use application security for both servers and workstations. Novell AppArmor is an access control system that lets you specify per program which files the program may read, write, and execute. AppArmor secures applications by enforcing good application behavior without relying on attack signatures, so it can prevent attacks even if they are exploiting previously unknown vulnerabilities.

之所以選擇Apparmor而不是SELinux,主要基于以下兩點(diǎn)原因:

  • 對于初學(xué)者來說,Apparmor比SELinux更簡單
  • ubuntu的粉絲,ubuntu選擇了Apparmor,同理,如果你是fedora的粉絲,很明顯會選擇SELinux

實(shí)事求是的說,SELinux比Apparmor更安全,更靈活,同時配置起來也更復(fù)雜。SELinux與Apparmor最大的區(qū)別在于:Apparmor使用文件名(路徑名)最為安全標(biāo)簽,而SELinux使用文件的inode作為安全標(biāo)簽,這就意味著,Apparmor機(jī)制可以通過修改文件名而被繞過,另外,在文件系統(tǒng)中,只有inode才具有唯一性。

由于ubuntu發(fā)行版已經(jīng)自帶了Apparmor的package,所以只需要在命令行中輸入如下命令,就可以查詢當(dāng)前Apparmor的狀態(tài):

  1. sudo apparmor_status

Linux Security Framework -- Apparmor機(jī)制介紹
從上圖中可以看出,當(dāng)前Apparmor包含了20個profile文件,而且都處于enforce狀態(tài),沒有處于enforce狀態(tài)的文件。

Apparmor的profile文件分為兩類:enforce與complain mode,存在于/etc/apparmor.d/目錄下,下面來看下官方給出的兩種不同狀態(tài)的profile的解釋。

Enforcing: This means the profile is actively protecting the application. By default, Ubuntu already locks down the CUPS daemon for you, but you will see several other profiles listed that you can set to enforce mode at any time.
簡單理解就是:如果某個程序不符合其profile文件的限制,程序行為將會失敗。

Complain: This means a profile exists but is not yet actively protecting the application. Instead, it is sort of in "debug" mode and will put "complain" messages into /var/log/messages. What this means is that if the application wants to read, write, or execute something that isn't listed in the profile, it will complain. This is how you generally create a profile.

簡單理解就是:如果某個程序不符合其profile文件的限制,改程序就會被apparmor“打小報告”,即將該程序的行為記錄在系統(tǒng)日志中,但是程序訪問行為會成功,比如本來沒有讓某個程序訪問某個文件,但就是訪問,僅僅報告一下,文件訪問會成功,如果在enforce模式下,文件訪問就會失敗。

如果想把某個profile置為enforce狀態(tài),執(zhí)行如下命令:
  1. sudo enforce <application_name>
如果想把某個profile置為complain狀態(tài),執(zhí)行如下命令:
  1. sudo complain <application_name>
在修改了某個profile的狀態(tài)后,執(zhí)行如下命令使之生效:
  1. sudo /etc/init.d/apparmor restart
在了解了Apparmor的基礎(chǔ)知識后,估計(jì)你最想了解的就是如果構(gòu)建profile,概括起來主要有以下幾種方式可以得到profile。
(1)ubuntu發(fā)行版預(yù)定義了一些profile,可以通過如下命令安裝:

  1. sudo apt-get install apparmor-profiles
另外,也可以在該網(wǎng)站 http://bodhizazen.net /下載,然后,放在/etc/apparmor.d/目錄下即可,一旦程序啟動的時候,profile將會被自動激活。

(2)通過工具來管理profile,比較著名是:apparmor-utils,通過如下命令進(jìn)行安裝:

  1. sudo apt-get install apparmor-utils
此工具最常用的兩個命令為:aa-genprof和aa-logprof,前者用來生成profile文件,后者用來查詢處于apparmor的日志記錄。

再看一個手工編寫的profile,熟悉下其語法格式,如果想更詳細(xì)的學(xué)習(xí),參見具體的講解profile語法格式的文檔,如: http://ubuntuforums.org/showthread.php?t=1008906

  1. #include <tunables/global>
  2. /usr/bin/kopete { //需要限制的應(yīng)用程序的名稱
  3. #include <abstractions/X>
  4. #include <abstractions/audio>
  5. #include <abstractions/base>
  6. #include <abstractions/kde>
  7. #include <abstractions/nameservice>
  8. #include <abstractions/user-tmp>
  9. //限制其在對家目錄下幾個文件的讀寫權(quán)限
  10. deny @{HOME}/.bash* rw,
  11. deny @{HOME}/.cshrc rw,
  12. deny @{HOME}/.profile rw,
  13. deny @{HOME}/.ssh/* rw,
  14. deny @{HOME}/.zshrc rw,
//對以下文件具有讀、寫、或可執(zhí)行的權(quán)限
  1. /etc/X11/cursors/oxy-white.theme r,
  2. /etc/default/apport r,
  3. /etc/kde4/* r,
  4. /etc/kde4rc r,
  5. /etc/kderc r,
  6. /etc/security/* r,
  7. /etc/ssl/certs/* r,
  8. owner /home/*/ r,
  9. /opt/firefox/firefox.sh Px,
  10. /usr/bin/convert rix,
  11. /usr/bin/kde4 rix,
  12. /usr/bin/kopete r,
  13. /usr/bin/kopete_latexconvert.sh rix,
  14. /usr/bin/launchpad-integration ix,
  15. /usr/bin/xdg-open mrix,
  16. /usr/lib/firefox*/firefox.sh Px,
  17. /usr/lib/kde4/**.so mr,
  18. /usr/lib/kde4/libexec/drkonqi ix,
  19. /usr/share/emoticons/ r,
  20. /usr/share/emoticons/** r,
  21. /usr/share/enchant/** r,
  22. /usr/share/kde4/** r,
  23. /usr/share/kubuntu-default-settings/** r,
  24. /usr/share/locale-langpack/** r,
  25. /usr/share/myspell/** r,
  26. owner @{HOME}/.config/** rwk,
  27. owner @{HOME}/.kde/** rwlk,
  28. owner @{HOME}/.local/share/mime/** r,
  29. owner @{HOME}/.thumbnails/** rw,
  30. owner @{HOME}/Downloads/ rw,
  31. owner @{HOME}/Downloads/** rw,
  32. }
語法介紹:

  1. r = read
  2. w = write
  3. l = link
  4. k = lock
  5. a = append

  1. ix = inherit = Inherit the parent's profile.
  2. px = requires a separate profile exists for the application, with environment scrubbing.
  3. Px = requires a separate profile exists for the application, without environment scrubbing.
  4. ux and Ux = Allow execution of an application unconfined, with and without environmental scrubbing. (use with caution if at all).
  5. m = allow executable mapping.

Linux Security Framework -- Apparmor機(jī)制介紹


更多文章、技術(shù)交流、商務(wù)合作、聯(lián)系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯(lián)系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點(diǎn)擊下面給點(diǎn)支持吧,站長非常感激您!手機(jī)微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點(diǎn)擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發(fā)表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 额敏县| 朝阳区| 元谋县| 酒泉市| 吴堡县| 嘉祥县| 石城县| 大理市| 六安市| 高唐县| 山西省| 保德县| 临沧市| 彭泽县| 哈尔滨市| 镇宁| 横山县| 乳山市| 张家口市| 潮州市| 清苑县| 德州市| 江西省| 扬中市| 成武县| 孟州市| 桑植县| 宕昌县| 大化| 靖宇县| 太和县| 齐河县| 清苑县| 宾川县| 昭觉县| 平利县| 汝州市| 林口县| 汾西县| 鄂州市| 呼图壁县|