File: hppfs.html

package info (click to toggle)
user-mode-linux-doc 20060501-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k, jessie, jessie-kfreebsd, lenny, squeeze, wheezy
  • size: 2,360 kB
  • ctags: 517
  • sloc: makefile: 36; sh: 7
file content (487 lines) | stat: -rw-r--r-- 20,764 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
    "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
   <meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type">
<title>The Honeypot procfs</title>
</head>
<body alink="#FF0000" vlink="#55188A" link="#0000EF" bgcolor="#FFFFFF" text="#000099">
<table border="0">
<tr align="left">
<td valign="top">
<table border="0">

<tr align="left"><td valign="top" >
<img src="http://user-mode-linux.sourceforge.net/uml-small.png" height="171" width="120"/> 
</td></tr>

<tr align="left"><td valign="top" bgcolor="#e0e0e0">
<font size="-1"><a href="http://user-mode-linux.sourceforge.net/index.html">Site Home Page</a></font>
<br>
              <font size="-1"><a href="http://uml.harlowhill.com">The UML Wiki</a></font>
<br>
              <font size="-1"><a href="http://usermodelinux.org">UML Community Site</a></font>
<br>
              <font size="-1"><a href="http://user-mode-linux.sourceforge.net/roadmap.html">The UML roadmap</a></font>
<br>
              <font size="-1"><a href="http://user-mode-linux.sourceforge.net/uses.html">What it's good for</a></font>
<br>
              <font size="-1"><a href="http://user-mode-linux.sourceforge.net/case-studies.html">Case Studies</a></font>
<br>
              <font size="-1"><a href="http://user-mode-linux.sourceforge.net/kernel.html">Kernel Capabilities</a></font>
<br>
              <font size="-1"><a href="http://user-mode-linux.sourceforge.net/dl-sf.html">Downloading it</a></font>
<br>
              <font size="-1"><a href="http://user-mode-linux.sourceforge.net/run.html">Running it</a></font>
<br>
              <font size="-1"><a href="http://user-mode-linux.sourceforge.net/compile.html">Compiling</a></font>
<br>
              <font size="-1"><a href="http://user-mode-linux.sourceforge.net/install.html">Installation</a></font>
<br>
              <font size="-1"><a href="http://user-mode-linux.sourceforge.net/skas.html">Skas Mode</a></font>
<br>
              <font size="-1"><a href="http://user-mode-linux.sourceforge.net/patches.html">Incremental Patches</a></font>
<br>
              <font size="-1"><a href="http://user-mode-linux.sourceforge.net/tests.html">Test Suite</a></font>
<br>
              <font size="-1"><a href="http://user-mode-linux.sourceforge.net/devanon.html">Host memory use</a></font>
<br>
              <font size="-1"><a href="http://user-mode-linux.sourceforge.net/fs_making.html">Building filesystems</a></font>
<br>
              <font size="-1"><a href="http://user-mode-linux.sourceforge.net/faq.html">Troubles</a></font>
<br>
              <font size="-1"><a href="http://user-mode-linux.sourceforge.net/contrib.html">User Contributions</a></font>
<br>
              <font size="-1"><a href="http://user-mode-linux.sourceforge.net/links.html">Related Links</a></font>
<br>
              <font size="-1"><a href="http://user-mode-linux.sourceforge.net/todo.html">The ToDo list</a></font>
<br>
              <font size="-1"><a href="http://user-mode-linux.sourceforge.net/projects.html">Projects</a></font>
<br>
              <font size="-1"><a href="http://user-mode-linux.sourceforge.net/diary.html">Diary</a></font>
<br>
              <font size="-1"><a href="http://user-mode-linux.sourceforge.net/thanks.html">Thanks</a></font>
<br>
              <font size="-1"><a href="http://user-mode-linux.sourceforge.net/contacts.html">Contacts</a></font>
</td></tr>

<tr align="left"><td valign="top" bgcolor="#e0e0e0">Tutorials<br>
<font size="-1"><a href="http://user-mode-linux.sourceforge.net/UserModeLinux-HOWTO.html">The HOWTO (html)</a></font>
<br>
              <font size="-1"><a href="http://user-mode-linux.sourceforge.net/UserModeLinux-HOWTO.txt">The HOWTO (text)</a></font>
<br>
              <font size="-1"><a href="http://user-mode-linux.sourceforge.net/hostfs.html">Host file access</a></font>
<br>
              <font size="-1"><a href="http://user-mode-linux.sourceforge.net/input.html">Device inputs</a></font>
<br>
              <font size="-1"><a href="http://user-mode-linux.sourceforge.net/shared_fs.html">Sharing filesystems</a></font>
<br>
              <font size="-1"><a href="http://user-mode-linux.sourceforge.net/fs.html">Creating filesystems</a></font>
<br>
              <font size="-1"><a href="http://user-mode-linux.sourceforge.net/resize.html">Resizing filesystems</a></font>
<br>
              <font size="-1"><a href="http://user-mode-linux.sourceforge.net/networking.html">Virtual Networking</a></font>
<br>
              <font size="-1"><a href="http://user-mode-linux.sourceforge.net/mconsole.html">Management Console</a></font>
<br>
              <font size="-1"><a href="http://user-mode-linux.sourceforge.net/debugging.html">Kernel Debugging</a></font>
<br>
              <font size="-1"><a href="http://user-mode-linux.sourceforge.net/honeypots.html">UML Honeypots</a></font>
<br>
              <font size="-1"><a href="http://user-mode-linux.sourceforge.net/gprof.html">gprof and gcov</a></font>
<br>
              <font size="-1"><a href="http://user-mode-linux.sourceforge.net/xtut.html">Running X</a></font>
<br>
              <font size="-1"><a href="http://user-mode-linux.sourceforge.net/trouble.html">Diagnosing problems</a></font>
<br>
              <font size="-1"><a href="http://user-mode-linux.sourceforge.net/config.html">Configuration</a></font>
<br>
              <font size="-1"><a href="http://user-mode-linux.sourceforge.net/slack_readme.html">Installing Slackware</a></font>
<br>
              <font size="-1"><a href="http://user-mode-linux.sourceforge.net/arch-port.html">Porting UML</a></font>
<br>
              <font size="-1"><a href="http://user-mode-linux.sourceforge.net/iomem.html">IO memory emulation</a></font>
<br>
              <font size="-1"><a href="http://user-mode-linux.sourceforge.net/2G-2G.html">UML on 2G/2G hosts</a></font>
<br>
              <font size="-1"><a href="http://user-mode-linux.sourceforge.net/lksct/index.html">Adding a UML system call</a></font>
<br>
              <font size="-1"><a href="http://user-mode-linux.sourceforge.net/nesting.html">Running nested UMLs</a></font>
</td></tr>

<tr align="left"><td valign="top" bgcolor="#e0e0e0">How you can help<br>
<font size="-1"><a href="http://user-mode-linux.sourceforge.net/help-gen.html">Overview</a></font>
<br>
              <font size="-1"><a href="http://user-mode-linux.sourceforge.net/help-doc.html">Documentation</a></font>
<br>
              <font size="-1"><a href="http://user-mode-linux.sourceforge.net/help-userspace.html">Utilities</a></font>
<br>
              <font size="-1"><a href="http://user-mode-linux.sourceforge.net/help-kernel-v1.html">Kernel bugs</a></font>
<br>
              <font size="-1"><a href="http://user-mode-linux.sourceforge.net/projects.html">Kernel projects</a></font>
</td></tr>

<tr align="left"><td valign="top" bgcolor="#e0e0e0">Screenshots<br>
<font size="-1"><a href="http://user-mode-linux.sourceforge.net/net.html">A virtual network</a></font>
<br>
              <font size="-1"><a href="http://user-mode-linux.sourceforge.net/x.html">An X session</a></font>
</td></tr>

<tr align="left"><td valign="top" bgcolor="#e0e0e0">Transcripts<br>
<font size="-1"><a href="http://user-mode-linux.sourceforge.net/login.html">A login session</a></font>
<br>
              <font size="-1"><a href="http://user-mode-linux.sourceforge.net/debug-session.html">A debugging session</a></font>
<br>
              <font size="-1"><a href="http://user-mode-linux.sourceforge.net/slackinst.html">Slackware installation</a></font>
</td></tr>

<tr align="left"><td valign="top" bgcolor="#e0e0e0">Reference<br>
<font size="-1"><a href="http://user-mode-linux.sourceforge.net/switches.html">Kernel switches</a></font>
<br>
              <font size="-1"><a href="http://user-mode-linux.sourceforge.net/slack_readme.html">Slackware README</a></font>
</td></tr>

<tr align="left"><td valign="top" bgcolor="#e0e0e0">Papers<br>
<font size="-1"><a href="http://user-mode-linux.sourceforge.net/als2000/index.html">ALS 2000 paper (html)</a></font>
<br>
              <font size="-1"><a href="http://user-mode-linux.sourceforge.net/als2000.tex">ALS 2000 paper (TeX)</a></font>
<br>
              <font size="-1"><a href="http://user-mode-linux.sourceforge.net/slides/als2000/slides.html">ALS 2000 slides</a></font>
<br>
              <font size="-1"><a href="http://user-mode-linux.sourceforge.net/slides/lca2001/lca.html">LCA 2001 slides</a></font>
<br>
              <font size="-1"><a href="http://user-mode-linux.sourceforge.net/slides/ols2001/index.html">OLS 2001 paper (html)</a></font>
<br>
              <font size="-1"><a href="http://user-mode-linux.sourceforge.net/ols2001.tex">OLS 2001 paper (TeX)</a></font>
<br>
              <font size="-1"><a href="http://user-mode-linux.sourceforge.net/als2001/index.html">ALS 2001 paper (html)</a></font>
<br>
              <font size="-1"><a href="http://user-mode-linux.sourceforge.net/als2001.tex">ALS 2001 paper (TeX)</a></font>
<br>
              <font size="-1"><a href="http://user-mode-linux.sourceforge.net/slides/ists2002/umlsec.htm">UML security (html)</a></font>
<br>
              <font size="-1"><a href="http://user-mode-linux.sourceforge.net/slides/lca2002/lca2002.htm">LCA 2002 (html)</a></font>
<br>
              <font size="-1"><a href="http://user-mode-linux.sourceforge.net/slides/wvu2002/wvu2002.htm">WVU 2002 (html)</a></font>
<br>
              <font size="-1"><a href="http://user-mode-linux.sourceforge.net/slides/ists_rt/ists_rt.htm">Security Roundtable (html)</a></font>
<br>
              <font size="-1"><a href="http://user-mode-linux.sourceforge.net/slides/ols2002/ols2002.html">OLS 2002 slides</a></font>
<br>
              <font size="-1"><a href="http://user-mode-linux.sourceforge.net/slides/lwe2005/LWE2005.html">LWE 2005 slides</a></font>
</td></tr>

<tr align="left"><td valign="top" bgcolor="#e0e0e0">Fun and Games<br>
<font size="-1"><a href="http://user-mode-linux.sourceforge.net/cgi-bin/hangman">Kernel Hangman</a></font>
<br>
              <font size="-1"><a href="http://user-mode-linux.sourceforge.net/sdotm.html">Disaster of the Month</a></font>
</td></tr>

</table>
</td>
<td valign="top" align="left">

<center>
            <h3>The Honeypot procfs</h3>
          </center>

hppfs reads a proc hierarchy in the current working directory
on the host of the UML.  When a UML process accesses a /proc entry,
hppfs consults the corresponding entry in this hierarchy to decide what
to do.  This entry is a directory which contains a file which
describes what to do with that entry.  The possibilities are as
follows:
<ul>
<li>
No entry on the host - hppfs passes the operation on to the UML /proc
- effectively this means that entry is unmodified.  Most /proc entries
contain no information about whether the machine is a UML, so these
can be left alone.
</li>
<li>
The host entry is a normal file or symlink - the contents of this file
(or target of the link) will replace the UML /proc entry.  This is
appropriate for /proc entries, such as /proc/cmdline, which can be
replaced by the corresponding /proc entry on the host.  It is also
appropriate for entries which must be changed, but which are static.
In this case, you'd drop the static file into the host proc hierarchy
for that UML.
</li>
<li>
The host entry is a directory and contains
<ul>
<li>
&quot;remove&quot; (a normal file) - this causes the entry to disappear from the
UML /proc.  This can be used to remove things which don't exist on
physical machines, such as /proc/exitcode and /proc/mconsole.
</li>
<li>
&quot;r&quot; (a unix socket) - this causes the entry to be generated on
demand by the process attached to the socket.  This is useful for
entries which must be dynamically generated, but can be generated from
scratch on the host.  
</li>
<li>
&quot;rw&quot; (a unix socket) - this is similar to &quot;r&quot;, except that the current
UML /proc contents of that entry are written to the socket before the
new contents are read.  This allows the host process to filter the UML
/proc data.  This is useful when data must be removed from a UML /proc
entry.
</li>
</ul>
</li>
</ul>
The files inside /proc/<i>pid</i> need slightly special handling
because you can't know on the host what pids are going to be present
inside UML.  UML looks in the pid subdirectory of the host's shadow
proc for all modifications of UML /proc/<i>pid</i> entries.
<p>
The uml_utilities tarball (under honeypot/) contains a few things to
simplify the disguising of a UML's /proc:
<ul>
<li>
hppfs.pm - A perl module which acts as a server for any dynamic proc
entries that need to be generated.
</li>
<li>
hppfslib.pm - A library which contains a set of utilities for
constructing a fake proc environment.
</li>
<li>
honeypot.pl - A sample driver for hppfs.pm and hppfslib.pm which
overrides a number of UML /proc entries in various ways.
</li>
</ul>

<a name="Example"/><table width="100%" bgcolor="#e0e0e0">
            <tr>
              <td>
                <b>
                  <font color="black">Example</font>
                </b>
              </td>
            </tr>
          </table>
          <blockquote head="Example">

Here is an example of setting up a customized UML /proc using hppfs.
<p>
First, boot a UML with hppfs enabled ('grep hppfs /proc/filesystems'
to check).  Login in and mount hppfs over /proc:
<blockquote>
              <tt>
                <font color="#000000" where="UML">UML# mount none /proc -t hppfs</font>
              </tt>
            </blockquote>
ls /proc and notice that it doesn't seem any different than before:
<tt>
              <pre>
                <font size="-1">
usermode:~# ls /proc
1    130  137  7        devices      interrupts  loadavg  mtd         swaps
100  131  140  8        dma          iomem       locks    net         sys
104  132  2    93       driver       ioports     meminfo  partitions  sysvipc
109  133  3    95       execdomains  irq         misc     scsi        tty
121  134  4    bus      exitcode     kcore       mm       self        uptime
126  135  5    cmdline  filesystems  kmsg        modules  slabinfo    version
129  136  6    cpuinfo  fs           ksyms       mounts   stat
</font>
              </pre>
            </tt>
Create a proc directory in the current working directory of the UML
<blockquote>
              <tt>
                <font color="#000000" where="host">host% mkdir proc</font>
              </tt>
            </blockquote>
Now, put something into proc/cmdline
<blockquote>
              <tt>
                <font color="#000000" where="host">host% echo 'hi there' &gt; proc/cmdline</font>
              </tt>
            </blockquote>
and look at the UML's /proc/cmdline
<tt>
              <pre>
                <font size="-1">
usermode#~: cat /proc/cmdline 
hi there
</font>
              </pre>
            </tt>
This should give you a good idea of how to make simple modifications
to the UML's /proc.  A more realistic example would be to make
/proc/cmdline the same as on the host.  You can do this by copying the
host's /proc/cmdline into proc, but a symbolic link will work, too:
<blockquote>
              <tt>
                <font color="#000000" where="host">host% ln -s /proc/cmdline proc/cmdline</font>
              </tt>
            </blockquote>

<tt>
              <pre>
                <font size="-1">
usermode:~# cat /proc/cmdline 
auto BOOT_IMAGE=2.4.19 ro root=306 BOOT_FILE=/boot/vmlinuz
</font>
              </pre>
            </tt>

With that step, you removed one way for an intruder to fingerprint the
machine as a UML.  There are a bunch of others, and it would be nice
to automate the creation of realistic, fake data for them as well.

<p>
Grab the uml_utilities tarball, unpack it, and cd into honeypot/.  Run
honeypot.pl with the current directory of UML as an argument:
<blockquote>
              <tt>
                <font color="#000000" where="host">host% perl ./honeypot.pl ~/linux/2.4/um/</font>
              </tt>
            </blockquote>
honeypot.pl asks the hppfs module to 
<ul>
<li>
create the directory:
<tt>
                  <pre>
                    <font size="-1">
my $hppfs = hppfs-&gt;new($dir);
</font>
                  </pre>
                </tt>
</li>
<li>
initialize its contents:
<tt>
                  <pre>
                    <font size="-1">
$hppfs-&gt;add(&quot;devices&quot; =&gt; remove_line(&quot;ubd&quot;),
	    &quot;uptime&quot; =&gt; proc(&quot;uptime&quot;),
	    &quot;exitcode&quot; =&gt; &quot;remove&quot;,
	    &quot;filesystems&quot; =&gt; remove_line(&quot;hppfs&quot;),
	    &quot;interrupts&quot; =&gt; proc(&quot;interrupts&quot;),
	    &quot;iomem&quot; =&gt; proc(&quot;iomem&quot;),
	    &quot;ioports&quot; =&gt; proc(&quot;ioports&quot;),
	    &quot;mounts&quot; =&gt; remove_line(&quot;hppfs&quot;),
	    &quot;pid/mounts&quot; =&gt; remove_line(&quot;hppfs&quot;),
	    &quot;version&quot; =&gt; proc(&quot;version&quot;) );
</font>
                  </pre>
                </tt>
</li>

<li>
call the hppfs server main loop, which will service requests from the
hppfs client inside UML for dynamic proc entries:
<tt>
                  <pre>
                    <font size="-1">
$hppfs-&gt;handler();
</font>
                  </pre>
                </tt>
</li>
</ul>
If you look at the proc directory now, you will see a bunch of new
entries:
<tt>
              <pre>
                <font size="-1">
host% ls ~/linux/2.4/um/proc/
devices   filesystems  iomem    mounts  uptime
exitcode  interrupts   ioports  pid     version
</font>
              </pre>
            </tt>
These all need some sort of manipulation.
<ul>
<li>
Removal - /proc/exitcode is specific to UML; writing to it allows the
exit code of UML on the host to be changed.  This obviously can't be
present in a honeypot, so the argument
<blockquote>
                  <tt>
                    <font color="#000000"> &quot;exitcode&quot; =&gt; &quot;remove&quot;,</font>
                  </tt>
                </blockquote>
to hppfs::add causes it to create an exitcode directory in proc on the
host:
<tt>
                  <pre>
                    <font size="-1">
host% ls -al ~/linux/2.4/um/proc/exitcode
total 8
drwxrw-rw-    2 jdike    jdike        4096 Dec 18 14:43 .
drwxrw-rw-   11 jdike    jdike        4096 Dec 18 14:43 ..
-rw-rw-rw-    1 jdike    jdike           0 Dec 18 14:43 remove
</font>
                  </pre>
                </tt>
The 'remove' entry tells hppfs to hide the UML /proc 'exitcode' file,
and 'ls /proc' inside the UML shows that it is indeed gone.
</li>

<li>
Fabrication - we've already seen an example of fabricating a proc
entry from scratch.  Dropping a static file into proc will cause it to
replace the corresponding UML /proc entry.  However, lots of /proc
files are dynamic, so looking at it twice and seeing exactly the same
data would be a tip-off that something's wrong.  If the host's /proc
entry is usable, then a symbolic link from the shadow proc to /proc
will be fine.  This is what these arguments to hppfs::add do:
<tt>
                  <pre>
                    <font size="-1">
&quot;uptime&quot; =&gt; proc(&quot;uptime&quot;),
&quot;interrupts&quot; =&gt; proc(&quot;interrupts&quot;),
&quot;iomem&quot; =&gt; proc(&quot;iomem&quot;),
&quot;ioports&quot; =&gt; proc(&quot;ioports&quot;),
&quot;mounts&quot; =&gt; remove_line(&quot;hppfs&quot;),
&quot;pid/mounts&quot; =&gt; remove_line(&quot;hppfs&quot;),
&quot;version&quot; =&gt; proc(&quot;version&quot;) );
</font>
                  </pre>
                </tt>
</li>
(although the actual hppfslib implementation of proc() currently has
the hppfs server execute 'cat /proc/&lt;file&gt;')
<li>
Filtering - sometimes the host's /proc or anything else we can
generate on the host won't be right.  Instead, we might want to take
the UML /proc file contents and manipulate them somehow.  An example
is /proc/filesystems.  In this honeypot, it contains an entry for
hppfs, which can't be allowed to remain.  So, this argument to
hppfs::add causes that one line to be removed, leaving everything else
the same:
<tt>
                  <pre>
                    <font size="-1">
&quot;filesystems&quot; =&gt; remove_line(&quot;hppfs&quot;),
</font>
                  </pre>
                </tt>
</li>
<li>
Note the &quot;pid/mounts&quot; entry.  That covers all references to any
/proc/<i>pid</i>/mounts file inside UML.
</li>

</ul>

</blockquote>


</td>
</tr>
</table>

<center>
<font size="-1">Hosted at </font>
    <a href="http://sourceforge.net">
    <img src="http://sourceforge.net/sflogo.php?group_id=429" width="88" height="31" border="0" alt="SourceForge Logo">
    </a>
</center>
</body>
</html>