April Fool なので Fool Proof な OS を作りました。

Proof of Concept ではありますが。

http://vps0.dan.co.jp/FoolBSD.tar.xz
size: 630,891,664 bytes
sha256sum: 893433cd6514f1466b57c48929a8130020265fbb915972b19c2b864da66cd73a

VMWare の仮想マシンです。 マシンのバージョンは 8。古めの Workstation や Fusion でも動くかと思います。

まずはログインしてみてましょう。ユーザー名:パスワードはfool:aprilです。コンソールじかでも SSH でもOKです。

FreeBSD/amd64 (foolbsd) (ttyv0)

login: fool
password: april

FreeBSD 10.0-RELEASE (GENERIC) #0 r260789: Thu Jan 16 22:34:59 UTC 2014

Welcome to FreeBSD!

Before seeking technical support, please use the following resources:

o  Security advisories and updated errata information for all releases are
   at http://www.FreeBSD.org/releases/ - always consult the ERRATA section
   for your release first as it's updated frequently.

o  The Handbook and FAQ documents are at http://www.FreeBSD.org/ and,
   along with the mailing lists, can be searched by going to
   http://www.FreeBSD.org/search/.  If the doc package has been installed
   (or fetched via pkg install lang-freebsd-doc, where lang is the
   2-letter language code, e.g. en), they are also available formatted
   in /usr/local/share/doc/freebsd.

If you still have a question or problem, please take the output of
`uname -a', along with any relevant error messages, and email it
as a question to the questions@FreeBSD.org mailing list.  If you are
unfamiliar with FreeBSD's directory layout, please refer to the hier(7)
manual page.  If you are not familiar with manual pages, type `man man'.

Edit /etc/motd to change this login announcement.

fool@fool:~ %

とりえあず、素性を確認してみましょう。ふつうの FreeBSD 10 に見えます。

fool@fool:~ % uname -a
FreeBSD fool 10.0-RELEASE FreeBSD 10.0-RELEASE #0 r260789: Thu Jan 16 22:34:59 UTC 2014     root@snap.freebsd.org:/usr/obj/usr/src/sys/GENERIC  amd64
fool@fool:~ % last
fool       pts/0                           Tue Apr  1 05:20   still logged in
boot time                                  Tue Apr  1 05:20

utx.log begins Tue Apr  1 05:20:57 JST 2014

ネットワークにもアクセスしてみましょう。

fool@fool:~ % fetch http://www.example.com/
fetch.out                                     100% of 1270  B 8336 kBps 00m00s
fool@fool:~ % less fetch.out 
<!doctype html>
<html>
<head>
    <title>Example Domain</title>
…

きちんとアクセスできているようです。

それではスーパユーザーになってみましょうか。suではなくsudoをお使いください。

fool@fool:~ % sudo -i
Password: april

sudo以外のpkgは事実上入っていないのですが、ふつうにpkgでいろいろインストールできます。

が、ここでは Fool Proof であることを確認しておきたいので、狼藉を働いてみます。

root@fool:~ # rm -rf /
rm: "/" may not be removed

おや、Linuxというかbinutilsなrmもそうですが最近のrmは素直でありませんねえ。

こうしてみましょう。

root@fool:~ # rm -rf /.??* /*
rm: /bin/rcp: Operation not permitted
rm: /bin: Directory not empty
rm: /dev/fd: Operation not supported
rm: /dev/led: Operation not supported
rm: /dev/usb: Operation not supported
rm: /dev/iso9660: Operation not supported
rm: /dev/gpt: Operation not supported
rm: /dev/gptid: Operation not supported
rm: /dev/pts: Operation not supported
rm: /dev: Device busy
rm: /lib/libc.so.7: Operation not permitted
rm: /lib/libcrypt.so.5: Operation not permitted
rm: /lib/libthr.so.3: Operation not permitted
rm: /lib: Directory not empty
rm: /libexec/ld-elf32.so.1: Operation not permitted
rm: /libexec/ld-elf.so.1: Operation not permitted
rm: /libexec: Directory not empty
rm: /sbin/init: Operation not permitted
rm: /sbin: Directory not empty
rm: /usr/lib32/libthr.so.3: Operation not permitted
rm: /usr/lib32/libcrypt.so.5: Operation not permitted
rm: /usr/lib32/librt.so.1: Operation not permitted
rm: /usr/lib32/libc.so.7: Operation not permitted
rm: /usr/lib32: Directory not empty
rm: /usr/lib/librt.so.1: Operation not permitted
rm: /usr/lib: Directory not empty
rm: /usr/bin/opiepasswd: Operation not permitted
rm: /usr/bin/passwd: Operation not permitted
rm: /usr/bin/login: Operation not permitted
rm: /usr/bin/ypchpass: Operation not permitted
rm: /usr/bin/rsh: Operation not permitted
rm: /usr/bin/ypchsh: Operation not permitted
rm: /usr/bin/su: Operation not permitted
rm: /usr/bin/ypchfn: Operation not permitted
rm: /usr/bin/chsh: Operation not permitted
rm: /usr/bin/rlogin: Operation not permitted
rm: /usr/bin/chfn: Operation not permitted
rm: /usr/bin/crontab: Operation not permitted
rm: /usr/bin/yppasswd: Operation not permitted
rm: /usr/bin/opieinfo: Operation not permitted
rm: /usr/bin/chpass: Operation not permitted
rm: /usr/bin: Directory not empty
rm: /usr: Directory not empty

schgフラグがかかっているのでしょうか。綺麗さっぱりというわけには行きませんでした。が、これで十二分に使い物にならなくなりました。

root@fool:~ # ls /
ls: Command not found.

最後のよりどころ、shellの内部コマンドechoで残骸を見てみましょう。

root@fool:~ # echo /*
/bin /dev /lib /libexec /sbin /usr
root@fool:~ # echo /*/*
/bin/rcp /dev/fd /dev/gpt /dev/gptid /dev/iso9660 /dev/led /dev/pts /dev/usb /lib/libc.so.7 /lib/libcrypt.so.5 /lib/libthr.so.3 /libexec/ld-elf.so.1 /libexec/ld-elf32.so.1 /sbin/init /usr/bin /usr/lib /usr/lib32

存分に破壊できているようです。もう復旧するには日本データテクノロジーに持っていくしかないのでしょうか?

ログアウトしちゃいましょうか。

root@fool:~ # exit
logout
fool@fool:~ % exit
logout

で、もう一度ログインしなおしてみてください。

FreeBSD/amd64 (foolbsd) (ttyv0)

login: fool
password:

なんということでしょう。先ほどの狼藉の後はどこにも見当たりません。それどころか先ほどのログインの形跡まで消えています。円環の理?

しかけ

コンソールからroot:evilでログインしてみてください。前述のとおりFoolBSDはSSHを有効にしていますが、rootログインはデフォルト通り切ってあるのでコンソール必須です。

あとは各自自習ということで。

jailZFSの組み合わせは最高ですね!

宿題

実はまだ多重ログインには未対応です。対応するにはどうしたらよいでしょう?

まとめ

即興ネタにしては、結構使いどころは案外多そうです。サーバー管理の演習、ハニーポットの実装、愚人節の余興…

Enjoy!

Dan the Fool for *BSD