查看文章
 
入侵时.bash_history的隐患
2010-06-22 3:22

,这个蛋疼的问题,估计很多xx客都忽略了,在你蹂躏一台linux主机的时候,当你千方百计的通过溢出,通过XXX和xx手段获得了root权限,可能你没有忘记修改文件时间,可能你没有忘记删除http访问日志,可能你千方百计的去删除ssh日志和wtmp记录,可是,你有想起来root下的.bash_history也会记录你的日志么,随便找个机器演示一下,反弹shell,执行

python -c 'import pty;pty.spawn("/bin/sh")';

然后很弱智的做一些机械运动,去milw0rm找exp溢出等等等,bingo,root了


sh-3.2# id
id
uid=0(root) gid=0(root) groups=501(www) context=system_u:system_r:initrc_t
好啊,我们清楚日志,我们擦脚印,我们谨慎的进行着每一步操作

unset HISTORY HISTFILE HISTSAVE HISTZONE HISTORY HISTLOG; export HISTFILE=/dev/null; export HISTSIZE=0; export HISTFILESIZE=0 我们不记录日志

history -c 我们清除日志,我们替换http访问记录,我们替换ssh访问记录,当你完成这一切的时候,你觉得你做的天衣无缝了,可以高枕无忧了,你从管理员的鼻子底下蒸发了…………

扯淡!root下的.bash_history会出卖你,他会告诉管理员你root之后的每一步操作,你的一举一动。看下我做测试的机器root之后我的一些操作

sh-3.2#cat /root/.bash_history

/usr/local/httpcws/httpcws -d -p 19807 -x /usr/local/httpcws/dict
hitory
history
kill -HUP `cat /opt/www/nginx/nginx.pid`
kill -HUP `cat /opt/www/nginx/nginx.pid`
kill -HUP `cat /opt/www/nginx/nginx.pid`
kill -HUP `cat /opt/www/nginx/nginx.pid`
kill -HUP `cat /opt/nginx/nginx.pid`
ls
cd
cd usr
cd usr
cd /usr
cd local
ll
cd webserver/
ll
cd my
cd mysql/
lls
cd d
ll
cd data/
ll
chmod -r 777 phpcms
chmod -r phpcms phpcms
cd /usr/local/webserver/
ll
cd mysql
ll
cd data
ll
cd phpcms
chmod -R phpcms 777
chmod -R phpcms 777
chmod --help
chmod -R phpcms 777
chmod -R 777 phpcms
chmod -R 777 *
cd ..
chmod -R 777 phpcms
ls
wget http://www.tcpdump.org/release/libpcap-1.0.0.tar.gz
cat /etc/shadow
\uname -a
ifconfig
/sbin/ifconfig -a
ps -aux
last
last
last -n 20
ls
netstat -an | grep :22
ps -aux | grep ssh
cat /etc/ssh/sshd_config
ls
ls
cd ..
ls
tar zxvf libpcap-1.1.1.tar.gz
cd libpcap-1.1.1
ls
./confihure
./configure
cd ..
ls
tar zxvf flex-2.5.35.tar.gz
cd flex-2.5.35
ls
./configure
make
make install
cd ..
ls
rm -rf flex*
ls
cd libpcap-1.1.1
ls
./configure
啊,我都干了什么了,啊,我下载了ettercap,我下载了libpcap,啊,我当管理员不存在……

所以各位xx客和xx客,做事要谨慎,这个地方的日志,一定要记得清除,当然,你可以手工删除,你可以用sed替换,你可以伪造,但是你不可以清空,这里将会暴露你的一举一动。

细节决定成败,假如,你什么都做了,只差这一步,假如,你遇到了一个非人类的管理员,那么,你的悲剧就来了……


类别:Security||添加到搜藏 |分享到i贴吧|浏览(1653)|评论 (0)
 
 
最近读者:
 
网友评论:
发表评论:
姓 名:
网址或邮箱: (选填)
内 容:
     

   
帮助中心 | 空间客服 | 投诉中心 | 空间协议
©2012 Baidu