linux下rm命令屏蔽脚本
时间:2016-06-05 00:06 来源:linux.it.net.cn 作者:IT
今天发现了个不错的东西,Linux之劫持rm命令实现安全删除和屏蔽删除/、/*,发给群里居然还有人因为不会用而说不好,让我很是不爽,下面分享给大家,怎么使用请自己摸索,简单的东西就不想当保姆教了.
下载地址:
wget http://www.dwhd.org/script/securityremove.sh
或者
wget http://download.slogra.com/soft_shell/securityremove.sh
securityremove脚本内容:
01
#!/bin/bash
02
#########################################################################
03
# File Name: securityremove.sh
04
# Author: LookBack
05
# Email: admin#dwhd.org
06
# Version:
07
# Created Time: 2015年08月16日 星期日 01时47分37秒
08
#########################################################################
09
10
wget -q http://www.dwhd.org/script/securityremove -O /bin/securityremove
11
chmod 755 /bin/securityremove
12
[ -f /etc/bash.bashrc ] && (sed -i "/securityremove/d" /etc/bash.bashrc && echo'alias rm="/bin/securityremove"' >> /etc/bash.bashrc && . /etc/bash.bashrc)
13
[ -f /etc/bashrc ] && (sed -i "/securityremove/d" /etc/bashrc && echo 'alias rm="/bin/securityremove"' >> /etc/bashrc && . /etc/bashrc)
14
[ -f /root/.bashrc ] && (sed -i "/alias rm/d" /root/.bashrc && echo 'alias rm="/bin/securityremove"' >> /root/.bashrc && . /root/.bashrc)
15
[[ -f "~/.bashrc" && "$USER" != "root" ]] &&(sed -i "/alias rm/d" ~/.bashrc &&echo 'alias rm="/bin/securityremove"' >> ~/.bashrc && . ~/.bashrc)
securityremove核心源码:
01
#!/bin/bash
02
#########################################################################
03
# File Name: securityremove.sh
04
# Author: LookBack
05
# Email: admin#dwhd.org
06
# Version:
07
# Created Time: 2015年08月16日 星期日 01时47分37秒
08
#########################################################################
09
10
RMARGS="${@}"
11
RMPATH="/bin/rm"
12
sys1dir=$(ls / | sed 's/^/\//' | tr "\n" " " | sed 's/.$//')
13
[ "${RMARGS}" == "" ] && ${RMPATH} && exit
14
15
SBRUN() {
16
echo -ne "\033[41;37mWhy run this command\033[0m\n"
17
exit 255
18
}
19
20
if grep "$sys1dir" <<< $RMARGS >/dev/null 2>&1; then SBRUN;fi
21
for i in ${@};do [ "$i" = "/" ] && SBRUN ;done
22
23
if [ "${RMARGS}" == '-h' ] || [ "${RMARGS}" == '--help' ];then
24
${RMPATH} ${RMARGS}
25
else
26
while [ "${confirm}" != "yes" ] && [ "${confirm}" != "no" ]; do
27
echo -ne "You are going to execute \"${RMPATH} \033[41;37m${RMARGS}\033[0m\",please confirm (yes or no):"
28
read confirm
29
done
30
[ "${confirm}" == "yes" ] && ${RMPATH} ${RMARGS} || exit
31
fi
使用效果截图:

(责任编辑:IT)
今天发现了个不错的东西,Linux之劫持rm命令实现安全删除和屏蔽删除/、/*,发给群里居然还有人因为不会用而说不好,让我很是不爽,下面分享给大家,怎么使用请自己摸索,简单的东西就不想当保姆教了. 下载地址: wget http://www.dwhd.org/script/securityremove.sh 或者 wget http://download.slogra.com/soft_shell/securityremove.sh securityremove脚本内容:
securityremove核心源码:
使用效果截图: ![]() (责任编辑:IT) |