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

Subversion リポジトリの参照

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2898 - (show annotations) (download)
Wed Aug 12 06:31:05 2009 UTC (14 years, 9 months ago) by kumaneko
Original Path: tags/htdocs/1.6/learning.html.en
File size: 9147 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 'q' key to quit the policy editor. Then, run "ccs-ccstree" and verify that /usr/sbin/httpd processes are assigned profile number 1.</p>
52
53 <p><img src="ccstree-httpd1.png" width="1108" height="722"></p>
54
55 <hr>
56
57 <h2>Step 2: Gathering necessary permissions</h2>
58
59 <p>Restart the Apache in order to learn necessary permissions for starting/finishing the Apache.</p>
60
61 <table border="1">
62 <tr><td>
63 [root@tomoyo ~]# service httpd restart
64 </td></tr>
65 </table>
66
67 <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>
68
69 <p>Press 'Enter' key to browse the permissions gathered by now.</p>
70
71 <p><img src="editpolicy-httpd-acl1.png" width="720" height="400"></p>
72
73 <p>Press 'q' key to quit the policy editor. Do whatever you want to allow Apache.</p>
74
75 <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>
76
77 <p>To save the policy currently in the kernel onto the disk, use "ccs-savepolicy" command.</p>
78
79 <table border="1">
80 <tr><td>
81 [root@tomoyo ~]# /usr/sbin/ccs-savepolicy
82 </td></tr>
83 </table>
84
85 <p>By executing "ccs-savepolicy", three files ("system_policy.conf", "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>
86
87 <p>To load the policy currently on the disk into the kernel, use "ccs-loadpolicy" command.</p>
88
89 <table border="1">
90 <tr><td>
91 [root@tomoyo ~]# /usr/sbin/ccs-loadpolicy af
92 </td></tr>
93 </table>
94
95 <p>The "a" option means load three files ("system_policy.conf", "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>
96
97 <hr>
98
99 <h2>Step 3: Reviewing gathered permissions</h2>
100
101 <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>
102
103 <p>Choose target domains and press 's' key and enter '2' and press 'Enter' key.</p>
104
105 <p><img src="editpolicy-httpd-set-profile2.png" width="720" height="400"></p>
106
107 <p>Now the profile number of the /usr/sbin/httpd and descendant has changed to 2.</p>
108
109 <p><img src="editpolicy-httpd-profile2.png" width="720" height="400"></p>
110
111 <p>Press 'q' key to quit the policy editor. Redo whatever you want to allow Apache to do.</p>
112
113 <p>If the profile is configured as "TOMOYO-VERBOSE=enabled" (this is default), the "TOMOYO-WARNING:" messages will be printed to the console when policy violation occurs.</p>
114
115 <p><img src="permissive-warning.png" width="720" height="400"></p>
116
117 <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>
118
119 <table border="1">
120 <tr><td>
121 [root@tomoyo ~]# grep -A 3 -F 'profile=2 mode=permissive' /var/log/tomoyo/reject_log.conf<br>
122 #2009-07-13 16:40:22# profile=2 mode=permissive pid=7131 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<br>
123 &lt;kernel&gt; /usr/sbin/httpd<br>
124 allow_read /usr/share/horde/admin/sqlshell.php<br>
125 <br>
126 #2009-07-13 16:40:22# profile=2 mode=permissive pid=7131 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<br>
127 &lt;kernel&gt; /usr/sbin/httpd<br>
128 allow_read /usr/share/pear/DB.php<br>
129 <br>
130 #2009-07-13 16:40:22# profile=2 mode=permissive pid=7131 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<br>
131 &lt;kernel&gt; /usr/sbin/httpd<br>
132 allow_read /usr/lib/gconv/EUC-JP.so<br>
133 <br>
134 #2009-07-13 16:40:22# profile=2 mode=permissive pid=7131 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<br>
135 &lt;kernel&gt; /usr/sbin/httpd<br>
136 allow_read /usr/lib/gconv/libJIS.so<br>
137 <br>
138 #2009-07-13 16:40:22# profile=2 mode=permissive pid=7131 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<br>
139 &lt;kernel&gt; /usr/sbin/httpd<br>
140 allow_read /usr/share/horde/lib/Horde/CLI.php<br>
141 <br>
142 #2009-07-13 16:40:22# profile=2 mode=permissive pid=7132 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<br>
143 &lt;kernel&gt; /usr/sbin/httpd<br>
144 allow_read /usr/share/horde/js/stripe.js
145 </td></tr>
146 </table>
147
148 <p>You can compress these logs using "ccs-sortpolicy" command.</p>
149
150 <table border="1">
151 <tr><td>
152 [root@tomoyo ~]# grep -A 3 -F 'profile=2 mode=permissive' /var/log/tomoyo/reject_log.conf | /usr/sbin/ccs-sortpolicy<br>
153 &lt;kernel&gt; /usr/sbin/httpd<br>
154 <br>
155 #2009-07-13 16:40:22# profile=2 mode=permissive pid=7131 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<br>
156 #2009-07-13 16:40:22# profile=2 mode=permissive pid=7132 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<br>
157 allow_read /usr/lib/gconv/EUC-JP.so<br>
158 allow_read /usr/lib/gconv/libJIS.so<br>
159 allow_read /usr/share/horde/admin/sqlshell.php<br>
160 allow_read /usr/share/horde/js/stripe.js<br>
161 allow_read /usr/share/horde/lib/Horde/CLI.php<br>
162 allow_read /usr/share/pear/DB.php
163 </td></tr>
164 </table>
165
166 <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-editpolicy's "-" option means read from stdin, "d" option means domain_policy.conf .</p>
167
168 <table border="1">
169 <tr><td>
170 [root@tomoyo ~]# grep -A 3 -F 'profile=2 mode=permissive' /var/log/tomoyo/reject_log.conf | /usr/sbin/ccs-sortpolicy &gt; ~/rejected.log<br>
171 [root@tomoyo ~]# emacs ~/rejected.log<br>
172 [root@tomoyo ~]# /usr/sbin/ccs-loadpolicy -d &lt; ~/rejected.log
173 </td></tr>
174 </table>
175
176 <p>If the "TOMOYO-WARNING:" messages are no longer printed after you have likely done everything you want Apache to allow, proceed to the next step.</p>
177
178 <p>If your purpose of using TOMOYO Linux is for just analysis, this point is the goal of this procedure.</p>
179
180 <p>If your purpose of using TOMOYO Linux is for protection, proceed to next phase.</p>
181
182 <hr>
183
184 <p><a href="index.html.en">Return to index page.</a></p>
185 <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>
186 </body>
187 </html>

Properties

Name Value
svn:keywords Date

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