オープンソース・ソフトウェアの開発とダウンロード

Subversion リポジトリの参照

Contents of /tags/htdocs/1.8/learning.html.en

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3021 - (show annotations) (download)
Sat Sep 12 07:12:53 2009 UTC (14 years, 8 months ago) by kumaneko
Original Path: tags/htdocs/1.7/learning.html.en
File size: 16810 byte(s)


1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2 <html lang="en-US">
3 <head>
4 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
5 <meta http-equiv="Content-Style-Type" content="text/css">
6 <title>TOMOYO Linux Install manual</title>
7 <link rel="stylesheet" href="tomoyo.css" media="all" type="text/css">
8 </head>
9 <body>
10 <p style="text-align:right;"><a href="learning.html.ja">Japanese Page</a></p>
11 <p style="text-align:right;">Last modified: $Date$</p>
12 <h1>Phase 3: Learning your system's behavior.</h1>
13
14 <p>This page describes how to use TOMOYO's learning mode.</p>
15
16 <hr>
17
18 <h2>Step 1: Creating domains</h2>
19
20 <p>After you rebooted the system with TOMOYO Linux kernels, login as root.</p>
21
22 <p>Decide what application to analyze/protect.</p>
23
24 <p>Below procedure is a case of Apache in CentOS 5.3 environment.</p>
25
26 <p>Start the target application.</p>
27
28 <table border="1">
29 <tr><td>
30 [root@tomoyo ~]# service httpd start
31 </td></tr>
32 </table>
33
34 <p>Let's start TOMOYO's policy editor. Please note that this time, you don't need to pass /etc/ccs/ to the command line, for we directly edits TOMOYO's policy currently used by the kernel.</p>
35
36 <p>In the CentOS 5.3 , Apache's program's location is /usr/sbin/httpd .<br>
37 Scroll the cursor using arrow-keys and/or Home/End/PageUp/PageDown keys to find the line /usr/sbin/httpd . In this picture, it is line 416.</p>
38
39 <p><img src="editpolicy-httpd-profile0.png" width="720" height="400"></p>
40
41 <p>If /usr/sbin/httpd is registered with "initialize_domain", a domain named "&lt;kernel&gt; /usr/sbin/httpd" is created by invoking /usr/sbin/httpd . If not registered, a child domain of invoker domain (for example, if you invoked from "&lt;kernel&gt; /usr/sbin/mingetty /bin/login /bin/bash", it is "&lt;kernel&gt; /usr/sbin/mingetty /bin/login /bin/bash /usr/sbin/httpd") is created. This manual assumes that /usr/sbin/httpd is registered with "initialize_domain".</p>
42
43 <p>Press 's' key and enter '1' and press 'Enter' key.</p>
44
45 <p><img src="editpolicy-httpd-set-profile1.png" width="720" height="400"></p>
46
47 <p>Now the profile number of the /usr/sbin/httpd has changed to 1.</p>
48
49 <p><img src="editpolicy-httpd-profile1.png" width="720" height="400"></p>
50
51 <p>Press '@' key to switch to process list. Verify that /usr/sbin/httpd processes are assigned profile number 1.</p>
52
53 <p><img src="editpolicy-httpd-process1.png" width="720" height="400"></p>
54
55 <p>Press 'q' key to quit the policy editor.</p>
56
57 <hr>
58
59 <h2>Step 2: Gathering necessary permissions</h2>
60
61 <p>Restart the Apache in order to learn necessary permissions for starting/finishing the Apache.</p>
62
63 <table border="1">
64 <tr><td>
65 [root@tomoyo ~]# service httpd restart
66 </td></tr>
67 </table>
68
69 <p>Run TOMOYO's policy editor again and go to the /usr/sbin/httpd line. (Line number may be changed because new domains are added by programs executed by you and the system.)</p>
70
71 <p>Press 'Enter' key to browse the permissions gathered by now.</p>
72
73 <p><img src="editpolicy-httpd-acl1.png" width="720" height="400"></p>
74
75 <p>Press 'q' key to quit the policy editor. Do whatever you want to allow Apache.</p>
76
77 <p><img src="operation-learning.png" width="688" height="933"></p>
78
79 <p>Be sure to sometimes save policy, for necessary permissions are accumulated on only kernel memory. If you reboot the system, all gathered permissions will be lost.</p>
80
81 <p>To save the policy currently in the kernel onto the disk, use "ccs-savepolicy" command.</p>
82
83 <table border="1">
84 <tr><td>
85 [root@tomoyo ~]# /usr/sbin/ccs-savepolicy
86 </td></tr>
87 </table>
88
89 <p>By executing "ccs-savepolicy", two files ("exception_policy.conf", "domain_policy.conf") are created in the /etc/ccs/ directory. To be accurate, they are symbolic links to text files whose filenames contain the creation time.</p>
90
91 <p>To load the policy currently on the disk into the kernel, use "ccs-loadpolicy" command.</p>
92
93 <table border="1">
94 <tr><td>
95 [root@tomoyo ~]# /usr/sbin/ccs-loadpolicy af
96 </td></tr>
97 </table>
98
99 <p>The "a" option means load two files ("exception_policy.conf", "domain_policy.conf"). The "f" option means erase the policy currently in the kernel before loading the policy currently on the disk. If "f" is not given, the policy currently on the disk will be added to the policy currently in the kernel.</p>
100
101 <hr>
102
103 <h2>Step 3: Reviewing gathered permissions</h2>
104
105 <p>After you came to think you have done roughly everything you want to allow Apache to do, run the policy editor and change the profile number to 2. Note that Apache may have executed some external programs (e.g. /bin/sh , /usr/bin/perl , /usr/lib/sendmail) and thus has descendant domains. Be sure to change the profile number for descendant domains if any as well as the /usr/sbin/httpd domain.</p>
106
107 <p>Choose target domains and press 's' key and enter '2' and press 'Enter' key.</p>
108
109 <p><img src="editpolicy-httpd-set-profile2.png" width="720" height="400"></p>
110
111 <p>Now the profile number of the /usr/sbin/httpd and descendant has changed to 2.</p>
112
113 <p><img src="editpolicy-httpd-profile2.png" width="720" height="400"></p>
114
115 <p>Press 'q' key to quit the policy editor. Redo whatever you want to allow Apache to do.</p>
116
117 <p>If the profile is configured as "PREFERENCE::permissive={ verbose=yes }" (this is default), the "WARNING:" messages will be printed to the console when policy violation occurs.</p>
118
119 <p><img src="operation-permissive.png" width="688" height="622"></p>
120
121 <p><img src="permissive-warning.png" width="720" height="400"></p>
122
123 <p>If you have configured audit logs at <a href="initialize.html.en#configure_audit_daemon">Phase 2: Initializing TOMOYO Linux.</a>, you can pick up necessary permissions from audit logs using "grep".</p>
124
125 <table border="1">
126 <tr><td>
127 [root@tomoyo ~]# grep -A 3 -F 'profile=2 mode=permissive' /var/log/tomoyo/reject_log.conf<br>
128 #2009-09-04 16:31:37# profile=2 mode=permissive pid=4025 uid=48 gid=48 euid=48 egid=48 suid=48 sgid=48 fsuid=48 fsgid=48 state[0]=0 state[1]=0 state[2]=0 (global-pid=4025)<br>
129 &lt;kernel&gt; /usr/sbin/httpd<br>
130 allow_network TCP accept 0:0:0:0:0:ffff:c0a8:801 3810<br>
131 <br>
132 #2009-09-04 16:32:08# profile=2 mode=permissive pid=4027 uid=48 gid=48 euid=48 egid=48 suid=48 sgid=48 fsuid=48 fsgid=48 state[0]=0 state[1]=0 state[2]=0 (global-pid=4027)<br>
133 &lt;kernel&gt; /usr/sbin/httpd<br>
134 allow_network TCP accept 0:0:0:0:0:ffff:c0a8:801 3829<br>
135 <br>
136 #2009-09-04 16:32:09# profile=2 mode=permissive pid=4609 uid=48 gid=48 euid=48 egid=48 suid=48 sgid=48 fsuid=48 fsgid=48 state[0]=0 state[1]=0 state[2]=0 realpath="/usr/bin/id" argc=1 envc=7 argv[]={ "id" } envp[]={ "TERM=linux" "PATH=/sbin:/usr/sbin:/bin:/usr/bin" "PWD=/usr/share/horde/admin" "LANG=en_US.UTF-8" "SHLVL=3" "LANGUAGE=en_US.UTF-8" "_=/usr/bin/id" } (global-pid=4609)<br>
137 &lt;kernel&gt; /usr/sbin/httpd /bin/sh<br>
138 allow_execute /usr/bin/id<br>
139 <br>
140 #2009-09-04 16:32:09# profile=2 mode=permissive pid=4609 uid=48 gid=48 euid=48 egid=48 suid=48 sgid=48 fsuid=48 fsgid=48 state[0]=0 state[1]=0 state[2]=0 (global-pid=4609)<br>
141 &lt;kernel&gt; /usr/sbin/httpd /bin/sh<br>
142 use_profile 2<br>
143 <br>
144 #2009-09-04 16:32:09# profile=2 mode=permissive pid=4609 uid=48 gid=48 euid=48 egid=48 suid=48 sgid=48 fsuid=48 fsgid=48 state[0]=0 state[1]=0 state[2]=0 realpath="/usr/bin/id" argc=1 envc=7 argv[]={ "id" } envp[]={ "TERM=linux" "PATH=/sbin:/usr/sbin:/bin:/usr/bin" "PWD=/usr/share/horde/admin" "LANG=en_US.UTF-8" "SHLVL=3" "LANGUAGE=en_US.UTF-8" "_=/usr/bin/id" } (global-pid=4609)<br>
145 &lt;kernel&gt; /usr/sbin/httpd /bin/sh /usr/bin/id<br>
146 allow_env TERM<br>
147 <br>
148 #2009-09-04 16:32:09# profile=2 mode=permissive pid=4609 uid=48 gid=48 euid=48 egid=48 suid=48 sgid=48 fsuid=48 fsgid=48 state[0]=0 state[1]=0 state[2]=0 realpath="/usr/bin/id" argc=1 envc=7 argv[]={ "id" } envp[]={ "TERM=linux" "PATH=/sbin:/usr/sbin:/bin:/usr/bin" "PWD=/usr/share/horde/admin" "LANG=en_US.UTF-8" "SHLVL=3" "LANGUAGE=en_US.UTF-8" "_=/usr/bin/id" } (global-pid=4609)<br>
149 &lt;kernel&gt; /usr/sbin/httpd /bin/sh /usr/bin/id<br>
150 allow_env PATH<br>
151 <br>
152 #2009-09-04 16:32:09# profile=2 mode=permissive pid=4609 uid=48 gid=48 euid=48 egid=48 suid=48 sgid=48 fsuid=48 fsgid=48 state[0]=0 state[1]=0 state[2]=0 realpath="/usr/bin/id" argc=1 envc=7 argv[]={ "id" } envp[]={ "TERM=linux" "PATH=/sbin:/usr/sbin:/bin:/usr/bin" "PWD=/usr/share/horde/admin" "LANG=en_US.UTF-8" "SHLVL=3" "LANGUAGE=en_US.UTF-8" "_=/usr/bin/id" } (global-pid=4609)<br>
153 &lt;kernel&gt; /usr/sbin/httpd /bin/sh /usr/bin/id<br>
154 allow_env PWD<br>
155 <br>
156 #2009-09-04 16:32:09# profile=2 mode=permissive pid=4609 uid=48 gid=48 euid=48 egid=48 suid=48 sgid=48 fsuid=48 fsgid=48 state[0]=0 state[1]=0 state[2]=0 realpath="/usr/bin/id" argc=1 envc=7 argv[]={ "id" } envp[]={ "TERM=linux" "PATH=/sbin:/usr/sbin:/bin:/usr/bin" "PWD=/usr/share/horde/admin" "LANG=en_US.UTF-8" "SHLVL=3" "LANGUAGE=en_US.UTF-8" "_=/usr/bin/id" } (global-pid=4609)<br>
157 &lt;kernel&gt; /usr/sbin/httpd /bin/sh /usr/bin/id<br>
158 allow_env LANG<br>
159 <br>
160 #2009-09-04 16:32:09# profile=2 mode=permissive pid=4609 uid=48 gid=48 euid=48 egid=48 suid=48 sgid=48 fsuid=48 fsgid=48 state[0]=0 state[1]=0 state[2]=0 realpath="/usr/bin/id" argc=1 envc=7 argv[]={ "id" } envp[]={ "TERM=linux" "PATH=/sbin:/usr/sbin:/bin:/usr/bin" "PWD=/usr/share/horde/admin" "LANG=en_US.UTF-8" "SHLVL=3" "LANGUAGE=en_US.UTF-8" "_=/usr/bin/id" } (global-pid=4609)<br>
161 &lt;kernel&gt; /usr/sbin/httpd /bin/sh /usr/bin/id<br>
162 allow_env SHLVL<br>
163 <br>
164 #2009-09-04 16:32:09# profile=2 mode=permissive pid=4609 uid=48 gid=48 euid=48 egid=48 suid=48 sgid=48 fsuid=48 fsgid=48 state[0]=0 state[1]=0 state[2]=0 realpath="/usr/bin/id" argc=1 envc=7 argv[]={ "id" } envp[]={ "TERM=linux" "PATH=/sbin:/usr/sbin:/bin:/usr/bin" "PWD=/usr/share/horde/admin" "LANG=en_US.UTF-8" "SHLVL=3" "LANGUAGE=en_US.UTF-8" "_=/usr/bin/id" } (global-pid=4609)<br>
165 &lt;kernel&gt; /usr/sbin/httpd /bin/sh /usr/bin/id<br>
166 allow_env LANGUAGE<br>
167 <br>
168 #2009-09-04 16:32:09# profile=2 mode=permissive pid=4609 uid=48 gid=48 euid=48 egid=48 suid=48 sgid=48 fsuid=48 fsgid=48 state[0]=0 state[1]=0 state[2]=0 realpath="/usr/bin/id" argc=1 envc=7 argv[]={ "id" } envp[]={ "TERM=linux" "PATH=/sbin:/usr/sbin:/bin:/usr/bin" "PWD=/usr/share/horde/admin" "LANG=en_US.UTF-8" "SHLVL=3" "LANGUAGE=en_US.UTF-8" "_=/usr/bin/id" } (global-pid=4609)<br>
169 &lt;kernel&gt; /usr/sbin/httpd /bin/sh /usr/bin/id<br>
170 allow_env _<br>
171 <br>
172 #2009-09-04 16:32:09# profile=2 mode=permissive pid=4609 uid=48 gid=48 euid=48 egid=48 suid=48 sgid=48 fsuid=48 fsgid=48 state[0]=0 state[1]=0 state[2]=0 (global-pid=4609)<br>
173 &lt;kernel&gt; /usr/sbin/httpd /bin/sh /usr/bin/id<br>
174 allow_read /etc/selinux/config<br>
175 <br>
176 #2009-09-04 16:32:09# profile=2 mode=permissive pid=4609 uid=48 gid=48 euid=48 egid=48 suid=48 sgid=48 fsuid=48 fsgid=48 state[0]=0 state[1]=0 state[2]=0 (global-pid=4609)<br>
177 &lt;kernel&gt; /usr/sbin/httpd /bin/sh /usr/bin/id<br>
178 allow_read /proc/filesystems<br>
179 <br>
180 #2009-09-04 16:32:09# profile=2 mode=permissive pid=4609 uid=48 gid=48 euid=48 egid=48 suid=48 sgid=48 fsuid=48 fsgid=48 state[0]=0 state[1]=0 state[2]=0 (global-pid=4609)<br>
181 &lt;kernel&gt; /usr/sbin/httpd /bin/sh /usr/bin/id<br>
182 allow_read /usr/lib/locale/locale-archive<br>
183 <br>
184 #2009-09-04 16:32:09# profile=2 mode=permissive pid=4609 uid=48 gid=48 euid=48 egid=48 suid=48 sgid=48 fsuid=48 fsgid=48 state[0]=0 state[1]=0 state[2]=0 (global-pid=4609)<br>
185 &lt;kernel&gt; /usr/sbin/httpd /bin/sh /usr/bin/id<br>
186 allow_read /etc/nsswitch.conf<br>
187 <br>
188 #2009-09-04 16:32:09# profile=2 mode=permissive pid=4609 uid=48 gid=48 euid=48 egid=48 suid=48 sgid=48 fsuid=48 fsgid=48 state[0]=0 state[1]=0 state[2]=0 (global-pid=4609)<br>
189 &lt;kernel&gt; /usr/sbin/httpd /bin/sh /usr/bin/id<br>
190 allow_read /etc/passwd<br>
191 <br>
192 #2009-09-04 16:32:09# profile=2 mode=permissive pid=4609 uid=48 gid=48 euid=48 egid=48 suid=48 sgid=48 fsuid=48 fsgid=48 state[0]=0 state[1]=0 state[2]=0 (global-pid=4609)<br>
193 &lt;kernel&gt; /usr/sbin/httpd /bin/sh /usr/bin/id<br>
194 allow_read /etc/group<br>
195 <br>
196 #2009-09-04 16:32:09# profile=2 mode=permissive pid=4609 uid=48 gid=48 euid=48 egid=48 suid=48 sgid=48 fsuid=48 fsgid=48 state[0]=0 state[1]=0 state[2]=0 (global-pid=4609)<br>
197 &lt;kernel&gt; /usr/sbin/httpd /bin/sh /usr/bin/id<br>
198 allow_read /etc/group<br>
199 <br>
200 #2009-09-04 16:33:19# profile=2 mode=permissive pid=4024 uid=48 gid=48 euid=48 egid=48 suid=48 sgid=48 fsuid=48 fsgid=48 state[0]=0 state[1]=0 state[2]=0 (global-pid=4024)<br>
201 &lt;kernel&gt; /usr/sbin/httpd<br>
202 allow_network TCP accept 0:0:0:0:0:ffff:c0a8:801 3854
203 </td></tr>
204 </table>
205
206 <p>You can compress these logs using "ccs-sortpolicy" command.</p>
207
208 <table border="1">
209 <tr><td>
210 [root@tomoyo ~]# grep -A 3 -F 'profile=2 mode=permissive' /var/log/tomoyo/reject_log.conf | /usr/sbin/ccs-sortpolicy<br>
211 &lt;kernel&gt; /usr/sbin/httpd<br>
212 <br>
213 #2009-09-04 16:32:08# profile=2 mode=permissive pid=4027 uid=48 gid=48 euid=48 egid=48 suid=48 sgid=48 fsuid=48 fsgid=48 state[0]=0 state[1]=0 state[2]=0 (global-pid=4027)<br>
214 #2009-09-04 16:32:09# profile=2 mode=permissive pid=4609 uid=48 gid=48 euid=48 egid=48 suid=48 sgid=48 fsuid=48 fsgid=48 state[0]=0 state[1]=0 state[2]=0 realpath="/usr/bin/id" argc=1 envc=7 argv[]={ "id" } envp[]={ "TERM=linux" "PATH=/sbin:/usr/sbin:/bin:/usr/bin" "PWD=/usr/share/horde/admin" "LANG=en_US.UTF-8" "SHLVL=3" "LANGUAGE=en_US.UTF-8" "_=/usr/bin/id" } (global-pid=4609)<br>
215 #2009-09-04 16:38:19# profile=2 mode=permissive pid=4029 uid=48 gid=48 euid=48 egid=48 suid=48 sgid=48 fsuid=48 fsgid=48 state[0]=0 state[1]=0 state[2]=0 (global-pid=4029)<br>
216 --<br>
217 allow_network TCP accept 0:0:0:0:0:ffff:c0a8:801 3810<br>
218 allow_network TCP accept 0:0:0:0:0:ffff:c0a8:801 3829<br>
219 allow_network TCP accept 0:0:0:0:0:ffff:c0a8:801 3854<br>
220 allow_network TCP accept 0:0:0:0:0:ffff:c0a8:801 3892<br>
221 <br>
222 &lt;kernel&gt; /usr/sbin/httpd /bin/sh<br>
223 <br>
224 #2009-09-04 16:32:09# profile=2 mode=permissive pid=4609 uid=48 gid=48 euid=48 egid=48 suid=48 sgid=48 fsuid=48 fsgid=48 state[0]=0 state[1]=0 state[2]=0 (global-pid=4609)<br>
225 #2009-09-04 16:32:09# profile=2 mode=permissive pid=4609 uid=48 gid=48 euid=48 egid=48 suid=48 sgid=48 fsuid=48 fsgid=48 state[0]=0 state[1]=0 state[2]=0 realpath="/usr/bin/id" argc=1 envc=7 argv[]={ "id" } envp[]={ "TERM=linux" "PATH=/sbin:/usr/sbin:/bin:/usr/bin" "PWD=/usr/share/horde/admin" "LANG=en_US.UTF-8" "SHLVL=3" "LANGUAGE=en_US.UTF-8" "_=/usr/bin/id" } (global-pid=4609)<br>
226 allow_execute /usr/bin/id<br>
227 <br>
228 &lt;kernel&gt; /usr/sbin/httpd /bin/sh /usr/bin/id<br>
229 <br>
230 #2009-09-04 16:32:09# profile=2 mode=permissive pid=4609 uid=48 gid=48 euid=48 egid=48 suid=48 sgid=48 fsuid=48 fsgid=48 state[0]=0 state[1]=0 state[2]=0 (global-pid=4609)<br>
231 #2009-09-04 16:32:09# profile=2 mode=permissive pid=4609 uid=48 gid=48 euid=48 egid=48 suid=48 sgid=48 fsuid=48 fsgid=48 state[0]=0 state[1]=0 state[2]=0 realpath="/usr/bin/id" argc=1 envc=7 argv[]={ "id" } envp[]={ "TERM=linux" "PATH=/sbin:/usr/sbin:/bin:/usr/bin" "PWD=/usr/share/horde/admin" "LANG=en_US.UTF-8" "SHLVL=3" "LANGUAGE=en_US.UTF-8" "_=/usr/bin/id" } (global-pid=4609)
232 #2009-09-04 16:33:19# profile=2 mode=permissive pid=4024 uid=48 gid=48 euid=48 egid=48 suid=48 sgid=48 fsuid=48 fsgid=48 state[0]=0 state[1]=0 state[2]=0 (global-pid=4024)<br>
233 allow_env LANG<br>
234 allow_env LANGUAGE<br>
235 allow_env PATH<br>
236 allow_env PWD<br>
237 allow_env SHLVL<br>
238 allow_env TERM<br>
239 allow_env _<br>
240 allow_read /etc/group<br>
241 allow_read /etc/nsswitch.conf<br>
242 allow_read /etc/passwd<br>
243 allow_read /etc/selinux/config<br>
244 allow_read /proc/filesystems<br>
245 allow_read /usr/lib/locale/locale-archive
246 </td></tr>
247 </table>
248
249 <p>You can save the compressed logs into a temporary file. Then, you can edit as you need and append to currently used policy in the kernel using "ccs-loadpolicy". ccs-loadpolicy's "-" option means read from stdin, "d" option means domain_policy.conf .</p>
250
251 <table border="1">
252 <tr><td>
253 [root@tomoyo ~]# grep -A 3 -F 'profile=2 mode=permissive' /var/log/tomoyo/reject_log.conf | /usr/sbin/ccs-sortpolicy &gt; ~/rejected.log<br>
254 [root@tomoyo ~]# emacs ~/rejected.log<br>
255 [root@tomoyo ~]# /usr/sbin/ccs-loadpolicy -d &lt; ~/rejected.log
256 </td></tr>
257 </table>
258
259 <p>If the "WARNING:" messages are no longer printed after you have likely done everything you want Apache to allow, proceed to the next step. (You can ignore "Access TCP accept" warnings against /usr/sbin/httpd , for you will make the address and port number patterns at next phase.)</p>
260
261 <p>If your purpose of using TOMOYO Linux is for just analysis, this point is the goal of this procedure.</p>
262
263 <p>If your purpose of using TOMOYO Linux is for protection, proceed to next phase.</p>
264
265 <hr>
266
267 <p><a href="index.html.en">Return to index page.</a></p>
268 <p><a href="http://sourceforge.jp/"><img src="http://sourceforge.jp/sflogo.php?group_id=1973" width="96" height="31" alt="SourceForge.jp"></a></p>
269 </body>
270 </html>

Properties

Name Value
svn:keywords Date

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26