Shell - 通过hook文件后门实现应用的自动启停
生活随笔
收集整理的這篇文章主要介紹了
Shell - 通过hook文件后门实现应用的自动启停
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
文章目錄
- 啟動腳本
- daemon
啟動腳本
#!/bin/bashset_network_param() {sysctl -w fs.file-max=999999sysctl -w net.ipv4.tcp_tw_reuse=1sysctl -w net.ipv4.tcp_fin_timeout=15sysctl -w net.core.netdev_max_backlog=4096sysctl -w net.core.somaxconn=40960sysctl -w net.ipv4.tcp_max_syn_backlog=40960sysctl -w net.ipv4.tcp_syncookies=1sysctl -w net.ipv4.tcp_syn_retries=2sysctl -w net.ipv4.tcp_synack_retries=2return }#service start start() {number=`ps -ef | grep "/home/nginx/bin/nginx" | grep -v grep | head -n 1 | wc -l`if [ $number -ge 1 ];thenfiset_network_paramulimit -n 65535if [ -f "/home/nginx/bin/nginx" ]then/home/nginx/bin/nginx -p /home/nginx -c /home/nginx/conf/nginx.conffinumber=`ps -ef | grep "/home/nginx/daemon/nginx_daemon" | grep -v grep | head -n 1 | wc -l`if [ $number -lt 1 ];then# Do Somethingfiif [ -f "/home/nginx/daemon/nginx_daemon" ]thennohup /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" instart)start;;stop)stop;;restart)stopsleep 1start;;*)echo "Usage: $0 {start|stop|restart}"exit 1;; esacexit 0姑且稱之為a.sh 在 /home/nginx 目錄下
daemon
通過放入hook文件, 在對應的目錄下touch start \ stop \restart 文件 , 實現應用的啟停
#!/bin/shnumber=`ps -ef | grep "/home/nginx/daemon/nginx_daemon" | grep -v grep | head -n 1 | wc -l` if [ $number -lt 1 ];then#do something fiwhile [ 1 -eq 1 ] doif [ -f "/home/nginx/daemon/start" ]; thenrm -rf /home/nginx/daemon/start/home/nginx/a.sh startfiif [ -f "/home/nginx/daemon/stop" ]; thenrm -rf /home/nginx/daemon/stop/home/nginx/a.sh stopfiif [ -f "/home/nginx/daemon/restart" ]; thenrm -rf /home/nginx/daemon/restart/home/nginx/a.sh restartfisleep 5 done總結
以上是生活随笔為你收集整理的Shell - 通过hook文件后门实现应用的自动启停的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Shell - 监控某个进程的内存占用情
- 下一篇: APM - 使用JavaAgent+Ja