Advertisement
Snuggledash

gsch.c

Nov 11th, 2024
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 3.32 KB | None | 0 0
  1. #include <string.h>
  2. #include <stdlib.h>
  3. #undef UNICODE
  4. #include <windows.h>
  5. #pragma comment(lib, "bcrypt.lib")
  6. #include <bcrypt.h>
  7.  
  8. #define MEIN_TIMEOUT 2000
  9.  
  10. // das als String niederzuschreiben wäre einfacher gewesen
  11. static const char strings[][60] = {
  12.     {0xbb,0x99,0x94,0x8e,0xdb,0xa7,0x80,0x85,0x83,0x91,0x88,0xd4,0x8a,0x7f,0x7d,0xd0,0x75,0x79,0xcd,0x8a,0x86,0x82,0x80,0x7a,0x83,0x81,0x73,0x70,0xb7,0xc2,0x6c,0x73,0xbf,0x84,0x68,0x76,0x7a,0x6e,0x6d,0x65,0x73,0x75,0x61,0x6f,0x65,0xb2,0x57,0x5b,0xaf,0x69,0x5b,0x52,0x66,0x55,0x62,0x63,0x59, 0},
  13.     {0xbb,0x99,0x94,0x8e,0xdb,0xa7,0x80,0x85,0x83,0x91,0x88,0xd4,0x8a,0x7f,0x7d,0xd0,0x75,0x79,0xcd,0x87,0x7d,0x76,0x77,0x79,0x77,0x7d,0x80,0x71,0x73,0x81,0x6f,0x6d,0x7e,0x71,0xbd,0x76,0xdf,0x68,0xb9,0xa0,0xb7,0x94,0x5c,0x60,0x6e,0x5f,0xb1,0x76,0x5a,0x68,0x6c,0x60,0x5f,0x57,0x65,0x67,0x53,0x61,0x57, 0},
  14.     {0xa8,0x95,0x8f,0x98,0x8c,0x83,0x86,0xd8,0x8e,0x83,0x81,0xd4,0x92,0x84,0x8d,0x8b,0x7d,0x77,0x88,0x83,0x77,0x81,0x82,0xc8,0x7c,0x85,0x75,0x6f,0x6f,0x6e, 0},
  15.     {0xab,0xb9,0xb0,0xac, 0},
  16.     {0xa3,0xb8,0xa5,0xa9,0xba,0xaa,0xb0,0xb4,0x92,0x94,0x80,0x8d,0xa7,0x83,0x8a,0xaa,0x86,0x82,0x88,0xbe,0x77,0x72,0x75, 0},
  17.     {0xb3,0x8f,0x9a,0x9b,0x8f,0x9e,0xb4,0x82,0x92,0x88,0x81,0x95, 0}
  18. };
  19.  
  20. static char *geheimNachricht(int i) {
  21.     char *kopie = strdup(strings[i]);
  22.     if (!kopie) return NULL;
  23.     unsigned laenge = strlen(kopie);
  24.     for (unsigned off = 0; off < laenge; off++) {
  25.         kopie[off] = ~kopie[off] - off;
  26.     }
  27.     return kopie;
  28. }
  29.  
  30. static void zeigeGeheimNachricht(int i) {
  31.     char *ungeheim = geheimNachricht(i);
  32.     if (!ungeheim) return;
  33.     MessageBox(NULL, ungeheim, NULL, MB_ICONERROR);
  34.     // wir sind professionell und räumen vor Programmende niemals auf
  35. }
  36.  
  37. static HANDLE gibMirEinNutzlosesEvent() {
  38.     BCRYPT_ALG_HANDLE datenWurstpresse;
  39.     ULONGLONG esIstEinMysterium;
  40.     char eventName[13 + sizeof(ULONGLONG)];
  41.     HANDLE event;
  42.     strcpy(eventName, geheimNachricht(5));
  43.     eventName[sizeof(eventName) - 1] = 0;
  44.     if (BCryptOpenAlgorithmProvider(&datenWurstpresse, BCRYPT_RNG_ALGORITHM, NULL, 0)) {
  45.         zeigeGeheimNachricht(0);
  46.         exit(1);
  47.     }
  48.     if (BCryptGenRandom(datenWurstpresse, (PUCHAR) &esIstEinMysterium, sizeof(ULONGLONG), 0)) {
  49.         zeigeGeheimNachricht(1);
  50.         exit(1);
  51.     }
  52.     esIstEinMysterium |= 0x4040404040404040L;
  53.     esIstEinMysterium &= 0x7777777777777777L;
  54.     memcpy(eventName + 12, &esIstEinMysterium, sizeof(esIstEinMysterium));
  55.     // würde man im Ernstfall entweder unbenannt lassen, oder einen von außen erratbaren Namen geben
  56.     if (!(event = CreateEvent(NULL, TRUE, FALSE, eventName))) {
  57.         zeigeGeheimNachricht(2);
  58.         exit(1);
  59.     }
  60.     BCryptCloseAlgorithmProvider(datenWurstpresse, 0);
  61.     return event;
  62. }
  63.  
  64. static void macheSchlimmeDinge() {
  65.     // Platzhalter für wirklich schlimme Dinge
  66.     char ueblicherDepp[MAX_PATH + 1];
  67.     char *ungeheim1, *ungeheim2;
  68.     if (!(ungeheim1 = geheimNachricht(3)) || !(ungeheim2 = geheimNachricht(4))) return;
  69.     if (!GetEnvironmentVariable(ungeheim1, ueblicherDepp, MAX_PATH + 1)) return;
  70.     strcat(ueblicherDepp, ungeheim2);
  71.     DeleteFile(ueblicherDepp);
  72. }
  73.  
  74. int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) {
  75.     // halt die Kresse
  76.     (void)hInstance;(void)hPrevInstance;(void)lpCmdLine;(void)nShowCmd;
  77.     HANDLE event = gibMirEinNutzlosesEvent();
  78.     while (WaitForSingleObject(event, MEIN_TIMEOUT));
  79.     CloseHandle(event);
  80.     macheSchlimmeDinge();
  81.     return 0;
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement