AppArmor是一个类似于selinux 的东东,主要的作用是设置某个可执行程序的访问控制权限,可以限制程序
读/写某个目录/文件,打开/读/写网络端口等等。
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,主要基于以下两点原因:
-
对于初学者来说,Apparmor比SELinux更简单
-
ubuntu的粉丝,ubuntu选择了Apparmor,同理,如果你是fedora的粉丝,很明显会选择SELinux
实事求是的说,SELinux比Apparmor更安全,更灵活,同时配置起来也更复杂。SELinux与Apparmor最大的区别在于:Apparmor使用文件名(路径名)最为安全标签,而SELinux使用文件的inode作为安全标签,这就意味着,Apparmor机制可以通过修改文件名而被绕过,另外,在文件系统中,只有inode才具有唯一性。
由于ubuntu发行版已经自带了Apparmor的package,所以只需要在命令行中输入如下命令,就可以查询当前Apparmor的状态:
从上图中可以看出,当前Apparmor包含了20个profile文件,而且都处于enforce状态,没有处于enforce状态的文件。
Apparmor的profile文件分为两类:enforce与complain mode,存在于/etc/apparmor.d/目录下,下面来看下官方给出的两种不同状态的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“打小报告”,即将该程序的行为记录在系统日志中,但是程序访问行为会成功,比如本来没有让某个程序访问某个文件,但就是访问,仅仅报告一下,文件访问会成功,如果在enforce模式下,文件访问就会失败。
如果想把某个profile置为enforce状态,执行如下命令:
-
sudo enforce <application_name>
如果想把某个profile置为complain状态,执行如下命令:
-
sudo complain <application_name>
在修改了某个profile的状态后,执行如下命令使之生效:
-
sudo /etc/init.d/apparmor restart
在了解了Apparmor的基础知识后,估计你最想了解的就是如果构建profile,概括起来主要有以下几种方式可以得到profile。
(1)ubuntu发行版预定义了一些profile,可以通过如下命令安装:
-
sudo apt-get install apparmor-profiles
另外,也可以在该网站
http://bodhizazen.net/下载,然后,放在/etc/apparmor.d/目录下即可,一旦程序启动的时候,profile将会被自动激活。
(2)通过工具来管理profile,比较著名是:apparmor-utils,通过如下命令进行安装:
-
sudo apt-get install apparmor-utils
此工具最常用的两个命令为:aa-genprof和aa-logprof,前者用来生成profile文件,后者用来查询处于apparmor的日志记录。
再看一个手工编写的profile,熟悉下其语法格式,如果想更详细的学习,参见具体的讲解profile语法格式的文档,如:http://ubuntuforums.org/showthread.php?t=1008906。
-
#include <tunables/global>
-
-
/usr/bin/kopete { //需要限制的应用程序的名称
-
#include <abstractions/X>
-
#include <abstractions/audio>
-
#include <abstractions/base>
-
#include <abstractions/kde>
-
#include <abstractions/nameservice>
-
#include <abstractions/user-tmp>
-
-
//限制其在对家目录下几个文件的读写权限
-
deny @{HOME}/.bash* rw,
-
deny @{HOME}/.cshrc rw,
-
deny @{HOME}/.profile rw,
-
deny @{HOME}/.ssh/* rw,
-
deny @{HOME}/.zshrc rw,
//对以下文件具有读、写、或可执行的权限
-
/etc/X11/cursors/oxy-white.theme r,
-
/etc/default/apport r,
-
/etc/kde4/* r,
-
/etc/kde4rc r,
-
/etc/kderc r,
-
/etc/security/* r,
-
/etc/ssl/certs/* r,
-
owner /home/*/ r,
-
/opt/firefox/firefox.sh Px,
-
/usr/bin/convert rix,
-
/usr/bin/kde4 rix,
-
/usr/bin/kopete r,
-
/usr/bin/kopete_latexconvert.sh rix,
-
/usr/bin/launchpad-integration ix,
-
/usr/bin/xdg-open mrix,
-
/usr/lib/firefox*/firefox.sh Px,
-
/usr/lib/kde4/**.so mr,
-
/usr/lib/kde4/libexec/drkonqi ix,
-
/usr/share/emoticons/ r,
-
/usr/share/emoticons/** r,
-
/usr/share/enchant/** r,
-
/usr/share/kde4/** r,
-
/usr/share/kubuntu-default-settings/** r,
-
/usr/share/locale-langpack/** r,
-
/usr/share/myspell/** r,
-
owner @{HOME}/.config/** rwk,
-
owner @{HOME}/.kde/** rwlk,
-
owner @{HOME}/.local/share/mime/** r,
-
owner @{HOME}/.thumbnails/** rw,
-
owner @{HOME}/Downloads/ rw,
-
owner @{HOME}/Downloads/** rw,
-
-
}
语法介绍:
-
r = read
-
w = write
-
l = link
-
k = lock
-
a = append
-
ix = inherit = Inherit the parent's profile.
-
px = requires a separate profile exists for the application, with environment scrubbing.
-
Px = requires a separate profile exists for the application, without environment scrubbing.
-
-
ux and Ux = Allow execution of an application unconfined, with and without environmental scrubbing. (use with caution if at all).
-
-
m = allow executable mapping.
-
分享到:
相关推荐
Linux-bench是一个Go应用程序,可通过运行CIS Distribution Independent Linux Benchmark中记录的检查来检查Linux操作系统是否已安全配置。 测试是使用YAML文件配置的,因此随着测试规范的发展,该工具易于更新。 ...
Spotify-apparmor Linux Spotify客户端的AppArmor配置文件。 已在Ubuntu GNOME 14.04.3 LTS,15.04和15.10上使用Spotify 0.9.17.1测试。 在Ubuntu 14.04及更早版本上,请注释掉配置文件的最后一行。
docker run -v /sys/kernel/security:/sys/kernel/security --privileged --rm -t ewindisch/apparmor 内核配置 机器必须具有可用并已配置的AppArmor模块。 主机上不需要AppArmor用户空间。 对于某些发行版,可能...
祸根 用于Docker容器的AppArmor配置文件生成器。 基本上,比手动创建一个更好的AppArmor配置文件,因为谁会这样做。 “审查AppArmor配置文件请求请求是我生存的祸根” 杰西·弗雷泽(Jess Frazelle) 目录安装二进制...
CAVEAT :该原型用于评估项目高效运行、与 AppArmor 配合良好以及在动态分析阶段有效生成不变量的能力。 因此,它不是一个健壮的代码库,也不适合生产使用。 某些安全参数(例如用于 MAC 安全令牌的密钥)是硬编码...
华科2022信息系统安全实验任务一AppArmor
AppArmor 因为近在研究OJ(oline judge)后台的安全模块的实现,所以一直在研究Linux下沙箱的东西,同时发现...作为对传统Unix的自主访问控制模块的补充,AppArmor提供了强制访问控制机制,它已经被整合到2.6版本的
Firejail是一个SUID沙箱程序,它使用Linux名称空间,seccomp-bpf和Linux功能来限制不受信任的应用程序的运行环境,从而降低了违反...Firejail可以在SELinux或AppArmor环境中工作,并且与Linux控制组集成在一起。 写在
Docker容器的自动AppArmor管理 用法 要使用docker-sec,只需通过添加后缀-sec即可使用docker命令。 例如,要启动新容器,请运行以下命令: docker-sec run --name safe-nginx -p 80:80 nginx 要使用docker-sec用户...
该项目是Security Profiles Operator的起点,这是树外的Kubernetes增强功能,旨在使在Kubernetes中更轻松,更直接地管理和应用seccomp和AppArmor配置文件。 关于 该项目的动机可以在相应的找到。 对本项目有直接...
HiGlass服务器 HiGlass服务器通过提供用于访问和上载生成的图块的API来支持和 。 ... 安装 先决条件: ...docker run -d --cap-add SYS_ADMIN --device /dev/fuse --security-opt apparmor:unconfined --name hi
政策如何运作该策略通过定义允许的AppArmor配置文件的白名单来起作用。 然后在创建和更新时检查Pod,以确保仅使用批准的Profile。 如果未定义AppArmor配置文件,Kubernetes将把最终选择权留给基础容器运行时。 这将...
沙盒在 Linux 上使用 cgroups 和 Apparmor 对 ruby 内容进行沙箱处理的原型。盒子所有库都捆绑在一起Apparmor 禁止网络,删除功能磁盘几乎是隐藏的,只有 ruby 工具和代码可以读取。 UNIX 套接字是唯一可写...
AppArmor配置文件 这是我创建的AppArmor配置文件的集合。 我的概要文件都没有使用基本系统抽象。 “抽象”用于我的自定义抽象。 可能很少,但是我主要是使它们具有强化的权限,而无需在每个配置文件中复制粘贴相同...
Apparmor食谱 默认配方将安装和管理AppArmor服务,或者根据default['apparmor']['disable']属性禁用和删除AppArmor。 还包括用于管理AppArmor策略的自定义资源(LWRP)。要求平台类的Ubuntu 德比安厨师厨师12.7+食谱...
AppArmor security module for linux network.
apparmor配置文件:某些应用程序的AppArmor安全配置文件
介绍apparmor的幻灯片。apparmor也是一个基于LSM的安全操作系统实现,与SELINUX的主要区别在于其本身是基于文件路径名来实现访问控制的。而SELINUX是基于标记的
tomcat7 Tomcat 7 带有用于...#提示 docker run -itd --cap-add=SYS_PTRACE --security-opt=apparmor:unconfined -e TOMCAT7PASS=VerySecretPass -v /data/supersite:/data/supersite --hostname docker.supersite....
Certified-Kubernetes-Security-Specialist:精选的资源可帮助您准备CNCFLinux Foundation CKS 2021“ Kubernetes认证的安全专家”认证考试。 请提出问题或提出要求,以提供反馈或要求。 欢迎提供改进的所有反馈。 ...