Shell - 通过hook文件后门实现应用的自动启停
【摘要】
文章目录
启动脚本daemon
启动脚本
#!/bin/bash
set_network_param()
{
sysctl -w fs.file-max=999999
sysc...
启动脚本
#!/bin/bash
set_network_param()
{
sysctl -w fs.file-max=999999
sysctl -w net.ipv4.tcp_tw_reuse=1
sysctl -w net.ipv4.tcp_fin_timeout=15
sysctl -w net.core.netdev_max_backlog=4096
sysctl -w net.core.somaxconn=40960
sysctl -w net.ipv4.tcp_max_syn_backlog=40960
sysctl -w net.ipv4.tcp_syncookies=1
sysctl -w net.ipv4.tcp_syn_retries=2
sysctl -w net.ipv4.tcp_synack_retries=2
return
}
#service start
start()
{
number=`ps -ef | grep "/home/nginx/bin/nginx" | grep -v grep | head -n 1 | wc -l`
if [ $number -ge 1 ];then
fi
set_network_param
ulimit -n 65535
if [ -f "/home/nginx/bin/nginx" ]
then
/home/nginx/bin/nginx -p /home/nginx -c /home/nginx/conf/nginx.conf
fi
number=`ps -ef | grep "/home/nginx/daemon/nginx_daemon" | grep -v grep | head -n 1 | wc -l`
if [ $number -lt 1 ];then
# Do Something
fi
if [ -f "/home/nginx/daemon/nginx_daemon" ]
then
nohup /home/nginx/daemon/nginx_daemon >/dev/null 2>&1 &
fi
}
#service stop
stop()
{
/home/nginx/bin/nginx -p /home/nginx -s stop
}
#parse cmd
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
sleep 1
start
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
;;
esac
exit 0
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
姑且称之为a.sh 在 /home/nginx 目录下
daemon
通过放入hook文件, 在对应的目录下touch start \ stop \restart 文件 , 实现应用的启停
#!/bin/sh
number=`ps -ef | grep "/home/nginx/daemon/nginx_daemon" | grep -v grep | head -n 1 | wc -l`
if [ $number -lt 1 ];then
#do something
fi
while [ 1 -eq 1 ]
do
if [ -f "/home/nginx/daemon/start" ]; then
rm -rf /home/nginx/daemon/start
/home/nginx/a.sh start
fi
if [ -f "/home/nginx/daemon/stop" ]; then
rm -rf /home/nginx/daemon/stop
/home/nginx/a.sh stop
fi
if [ -f "/home/nginx/daemon/restart" ]; then
rm -rf /home/nginx/daemon/restart
/home/nginx/a.sh restart
fi
sleep 5
done
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
文章来源: artisan.blog.csdn.net,作者:小小工匠,版权归原作者所有,如需转载,请联系作者。
原文链接:artisan.blog.csdn.net/article/details/108845686
【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)