| 208 | } |
| 209 | |
| 210 | void encryptFile(const char* payloadPath, char* outputPath) { |
| 211 | |
| 212 | size_t payloadSize = 0; |
| 213 | |
| 214 | BYTE* payloadBuf = peconv::load_file(payloadPath, payloadSize); |
| 215 | if (payloadBuf == NULL) { |
| 216 | std::cerr << "Cannot read payload!" << std::endl; |
| 217 | return; |
| 218 | } |
| 219 | |
| 220 | unsigned char* lpszEncryptedString = nullptr; |
| 221 | DWORD dwEncryptedSize = EncryptString(payloadBuf, "Hagrid29", lpszEncryptedString, payloadSize); |
| 222 | char outputPath2[sizeof(payloadPath) + 5]; |
| 223 | if (outputPath == nullptr) { |
| 224 | const char* suffix = ".enc"; |
| 225 | strcpy(outputPath2, payloadPath); |
| 226 | strcat(outputPath2, suffix); |
| 227 | outputPath = outputPath2; |
| 228 | } |
| 229 | FILE* file = fopen(outputPath, "wb"); |
| 230 | fwrite(lpszEncryptedString, 1, dwEncryptedSize, file); |
| 231 | } |
| 232 | |
| 233 | BYTE* decryptFile(const char* payloadPath, OUT size_t& r_size) { |
| 234 | |