| 1 |
#include <stdio.h> |
| 2 |
#include "extract.h" |
| 3 |
#ifdef _WIN32 |
| 4 |
#include <tlhelp32.h> |
| 5 |
#include <winreg.h> |
| 6 |
#else |
| 7 |
#include <time.h> |
| 8 |
#endif |
| 9 |
|
| 10 |
int main(int argc, char **argv) |
| 11 |
{ |
| 12 |
DROP_AND_EXECUTE() |
| 13 |
|
| 14 |
printf("%s\n", "CLAMAV_TEST_PRINTF_STRING_" INDICATOR1); |
| 15 |
printf("%s\n", "CLAMAV_TEST_PRINTF_STRING_" INDICATOR2); |
| 16 |
|
| 17 |
// Do some random stuff to change the .imp hashes and .text MDB/MSB hashes |
| 18 |
// To change the .imp hash (Windows-specific) we actually need to make |
| 19 |
// the exe import new functions, so we need to call interesting APIs. |
| 20 |
// |
| 21 |
// On Linux, we just need to make sure the assembly in the .text section |
| 22 |
// is different |
| 23 |
#if INDEX == 1 |
| 24 |
#ifdef _WIN32 |
| 25 |
|
| 26 |
printf("Enumerating Modules via CreateToolhelp32Snapshot\n"); |
| 27 |
HANDLE h = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, GetCurrentProcessId()); |
| 28 |
if (INVALID_HANDLE_VALUE == h) { |
| 29 |
return 1; |
| 30 |
} |
| 31 |
MODULEENTRY32 m; |
| 32 |
if (!Module32First(h, &m)) { |
| 33 |
CloseHandle(h); |
| 34 |
return 1; |
| 35 |
} |
| 36 |
do { |
| 37 |
printf(" - %s\n", m.szModule); |
| 38 |
} while (Module32Next(h, &m)); |
| 39 |
CloseHandle(h); |
| 40 |
|
| 41 |
#else |
| 42 |
|
| 43 |
printf("Listing program name\n - %s\n", argv[0]); |
| 44 |
|
| 45 |
#endif |
| 46 |
|
| 47 |
#elif INDEX == 2 |
| 48 |
#ifdef _WIN32 |
| 49 |
|
| 50 |
printf("Enumerating Keys in HKEY_CURRENT_USER\n"); |
| 51 |
char key[256]; |
| 52 |
int index = 0; |
| 53 |
if (ERROR_SUCCESS != RegEnumKeyA(HKEY_CURRENT_USER, index++, (char *)&key, sizeof(key))) { |
| 54 |
return 1; |
| 55 |
} |
| 56 |
do { |
| 57 |
printf(" - %s\n", key); |
| 58 |
} while (ERROR_SUCCESS == RegEnumKeyA(HKEY_CURRENT_USER, index++, (char *)&key, sizeof(key))); |
| 59 |
|
| 60 |
#else |
| 61 |
|
| 62 |
printf("Listing current time\n - %d\n", (int)time(NULL)); |
| 63 |
|
| 64 |
#endif |
| 65 |
|
| 66 |
#else |
| 67 |
|
| 68 |
printf("Nothing to do!\n"); |
| 69 |
|
| 70 |
#endif |
| 71 |
|
| 72 |
return 0; |
| 73 |
} |